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 memory — memory={"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.

Metadata

Release files for relayhq 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for relayhq 0.2.0
File Size Uploaded
relayhq-0.2.0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for relayhq 0.2.0
File Interpreter ABI Platform
relayhq-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / relayhq-0.2.0.tar.gz

Download URL relayhq-0.2.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
36db523861798606a4ad2f2ed995578e0aed60b475963ed18133b508ef3347eb
BLAKE2b-256 checksum
How to use checksums
c76e795ac1a6befbc0a8dca2ae8ba326b99bbde32b1e9ca11095e18d830b90f4
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / relayhq-0.2.0-py3-none-any.whl

Download URL relayhq-0.2.0-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42390d9822581a4ed917616ea50e8918b404cbdebce0271edbd3ac4dcb8123e7
BLAKE2b-256 checksum
How to use checksums
6737908e85e2ae76a61a2a2d0e1adc61ae279d6e8cbad8470db61d533f8a3223
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page