Skip to main content

The backend cloud for reliable AI agents. Memory, retries, tools, traces and durable execution without building orchestration infrastructure yourself.

Project description

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.

Project details


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.1.0.tar.gz (10.4 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.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: relayhq-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 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":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for relayhq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c6a68f78d53a1ad8756d11a73f982fe83d58691c4c882394a699b156d893622
MD5 282b67be455142315a22898b5459fc26
BLAKE2b-256 2d9918aefec2f397536b384ad96137a4e8bb2bd12ad2a7736b6499aac3980e1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: relayhq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for relayhq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db83e2a7980546e0d2b425b897a1b114eba07e9dc56be7f6e3905bad372d893a
MD5 08b5e8d5bac6aa9dda1aa5aaed7ac9c7
BLAKE2b-256 0e5f208448622ccc7bfa44ca6267c21a0f0e26d9c4d9546c771cc341084d0f6a

See more details on using hashes here.

Supported by

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