OpenAI’s official SDKs for Python and Node work unchanged: point the base URL at https://autonomousrelay.com/v1, use an inference key, and name any model in the catalogue by its author/slug id. Quickstart has the two-line change; this page is the rest of the SDK.
Configure it once, with environment variables
Both SDKs read OPENAI_BASE_URL and OPENAI_API_KEY when the client is created without arguments, so code that already uses OpenAI moves without an edit.
export OPENAI_BASE_URL="https://autonomousrelay.com/v1" export OPENAI_API_KEY="$AUTONOMOUSRELAY_API_KEY"
from openai import OpenAI
client = OpenAI() # reads both variables
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
)What each SDK method reaches
chat.completions.create: every model, with streaming, tool calls andresponse_format. Usage arrives in the last chunk of a stream.responses.create: stateless. Leavestoreunset orfalseand send the whole conversation asinput;previous_response_idis refused with a 400 that says so.embeddings.create,images.generate,audio.speech.createandaudio.transcriptions.create: OpenAI’s shapes, on the catalogue’s embedding, image and audio models.completions.create: the legacy endpoint, one prompt per request.models.list(): the catalogue.batches.createdoes not work from the SDK: it takes an uploaded file, and batches here take their requests inline. SendPOST /v1/batcheswith any HTTP client.
Each endpoint’s limits are in Chat completions.
Fields the SDK does not know
A fallback chain (models) and routing preferences (provider) are not OpenAI parameters. Python sends them through extra_body; in Node, add them to the request object, with a cast in TypeScript.
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
extra_body={"models": ["anthropic/claude-sonnet-5", "openai/gpt-5.5"]},
)const resp = await client.chat.completions.create({
model: 'anthropic/claude-sonnet-5',
messages: [{ role: 'user', content: 'Hello' }],
models: ['anthropic/claude-sonnet-5', 'openai/gpt-5.5'],
} as OpenAI.ChatCompletionCreateParamsNonStreaming);See Fallbacks and provider failover and Routing for what each field does.
Errors, retries and the request id
- Errors raise the SDK’s usual exceptions, carrying our message:
AuthenticationError(401),PermissionDeniedError(403),NotFoundError(404, for example no provider key for that model),RateLimitError(429) andBadRequestError(400). Errors lists them. - The SDKs retry a 408, 409, 429 or 5xx twice by default, waiting as
retry-aftersays. A fallback chain already tries other models within one request, so the SDK’s retries only come in once every attempt has failed. Setmax_retries(Python) ormaxRetries(Node) to change it. - A response’s
id(gen-…) is the request id:GET /v1/generation?id=reads its cost and which endpoint served it.