Skip to main content

relayhq

Python SDK for Relay — the backend cloud for reliable AI agents.

pip install relayhq
import asyncio
from relayhq import create_agent, builtin, tool

async def get_user_handler(input):
    return await db.users.find(input["id"])  # runs in your process

get_user = tool(
    name="get_user",
    description="Look up a user by id",
    input_schema={
        "type": "object",
        "properties": {"id": {"type": "string"}},
        "required": ["id"],
    },
    handler=get_user_handler,
)

agent = create_agent(
    api_key="relay_live_...",                   # from relaygh.dev/en/signup
    base_url="https://api.relaygh.dev",
    model="gpt-4o-mini",
    memory={"namespace": f"user:{user_id}"},
    tools=[builtin.calculator, get_user],
)

async def main():
    async for event in agent.run("Look up u_001 and tell me their tier"):
        if event["type"] == "token":
            print(event["text"], end="", flush=True)

asyncio.run(main())

What you get

  • Multi-provider routing — Anthropic, OpenAI, any OpenAI-compatible endpoint (Ollama, vLLM, Groq, Together, OpenRouter). Pick with the model string.
  • Custom function tools — your handler runs in your process. The SDK ships the schema; the runtime pauses; you fulfill locally over the same stream.
  • Semantic memorymemory={"namespace": ...} and the agent recalls relevant past turns automatically (pgvector under the hood).
  • Persistent execution traces — every token, tool call, tool result, and error captured server-side. Replay from the dashboard.

Event stream

agent.run(input) returns an AsyncIterator[dict]. Events:

{"type": "token",       "text": "..."}
{"type": "tool_call",   "id": "...", "name": "...", "input": ...}
{"type": "tool_result", "id": "...", "output": ...}
{"type": "done",        "output": "...", "usage": {"input_tokens": ..., "output_tokens": ...}}
{"type": "error",       "message": "..."}

A tool_call for a custom tool is followed by its tool_result after your handler runs and the POST completes. Order is guaranteed.

Get a key

Free during beta, no credit card. Sign up at https://relaygh.dev/en/signup with your email and an OpenAI/Anthropic key — you get back a relay_live_… key.

Or self-host the whole stack: https://github.com/KevinCorrea5103/relay

License

Apache 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

relayhq-0.2.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

relayhq-0.2.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file relayhq-0.2.0.tar.gz.

File metadata

  • Download URL: relayhq-0.2.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for relayhq-0.2.0.tar.gz
Algorithm Hash digest
SHA256 36db523861798606a4ad2f2ed995578e0aed60b475963ed18133b508ef3347eb
MD5 8a9f0c382e8d7dee16c55ac62c0e6b9a
BLAKE2b-256 c76e795ac1a6befbc0a8dca2ae8ba326b99bbde32b1e9ca11095e18d830b90f4

See more details on using hashes here.

File details

Details for the file relayhq-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: relayhq-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for relayhq-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42390d9822581a4ed917616ea50e8918b404cbdebce0271edbd3ac4dcb8123e7
MD5 24370ffd5b25b2982fda70d48967f2bf
BLAKE2b-256 6737908e85e2ae76a61a2a2d0e1adc61ae279d6e8cbad8470db61d533f8a3223

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page