Skip to main content

Official Python SDK for the Relay AI Gateway. One key, every model.

Project description

Relay AI SDK

Official Python SDK for the Relay AI Gateway. One key, every model.

pip install relay-ai

Quick start

from relay_ai import Relay

client = Relay(api_key="sk-relay-...")

# Chat
response = client.chat("claude-sonnet-4.6", messages=[
    {"role": "user", "content": "Explain quantum computing in one sentence."}
])
print(response.text)

# Streaming
for chunk in client.chat("gemini-3.5-flash", messages=[
    {"role": "user", "content": "Write a haiku about code."}
], stream=True):
    print(chunk.text, end="", flush=True)

# Image generation
result = client.images("flux-schnell", prompt="A cat astronaut on Mars")
print(result.images[0])  # URL

Async

from relay_ai import AsyncRelay

async with AsyncRelay(api_key="sk-relay-...") as client:
    resp = await client.chat("claude-opus-4.8", messages=[
        {"role": "user", "content": "Hello!"}
    ])
    print(resp.text)

Environment variable

Set RELAY_API_KEY to skip passing it explicitly:

export RELAY_API_KEY=sk-relay-...
client = Relay()  # picks up from env

Available models

client = Relay()
print(client.models())

Chat, image, voice, and video models — all through one API key. See the full list at relay.ai5labs.com/models.

Tool calling

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        },
    }
]

resp = client.chat("claude-sonnet-4.6", messages=[
    {"role": "user", "content": "What's the weather in Tokyo?"}
], tools=tools)

print(resp.raw["choices"][0]["message"]["tool_calls"])

License

MIT

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

ai5labs_relay-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

ai5labs_relay-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file ai5labs_relay-1.0.0.tar.gz.

File metadata

  • Download URL: ai5labs_relay-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for ai5labs_relay-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c6e4c3871b5aed8abc6c4386a675f4799be52b8598cdc5dc7fd5b82839980caf
MD5 dc726ade8e05660676b7ed20d9ccbd36
BLAKE2b-256 87b3402d18cce2945340072a9d4f19e099cbaaace2894790bca25908a1f0c6b3

See more details on using hashes here.

File details

Details for the file ai5labs_relay-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ai5labs_relay-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for ai5labs_relay-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cab2a257279acf234fdddf4ed8adbf9c4b9ba4ea7b885052c6701bf2fea4d08f
MD5 aeccfecfc302bfcadd3cb97fbd0e78ed
BLAKE2b-256 e773ab007cce1b83be3a7869f77885f2ecbfd35abc799ea833ee8929caa3d523

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