Docs / API

OpenAI-compatible API: one base URL, one key

An OpenAI-compatible API takes the request an OpenAI SDK sends, so a client built for OpenAI runs on it with a new base URL and key. RelaySwitch's is https://api.relayswitch.io/v1: 313 models answer chat completions on one prepaid key.

Minimum top-up
$10
Pay with
USDT, USDC, BTC, ETH, SOL, or card
Sign-up
An email address, or sign in with Google or GitHub. No phone number, no identity documents.
Models
322 on one key, prices read live
Base URL
https://api.relayswitch.io/v1OpenAI Chat Completions and Responses on 313 models, Anthropic Messages on 313, Gemini generateContent on 313
One message, example
$0.00031 on Manta Flash 1.0; $0.0033 on Claude Sonnet 5.5 for one 2K-in / 300-out turn
Subscription
None. Prepaid credit, billed per token.
Base URLhttps://api.relayswitch.io/v1
Chat completionsPOST https://api.relayswitch.io/v1/chat/completions
API keyAuthorization: Bearer <key>
A working request

Send the first request

Any OpenAI SDK works unchanged. Three ways to say hello.

bash
1curl https://api.relayswitch.io/v1/chat/completions \
2 -H "Authorization: Bearer $RELAYSWITCH_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "claude-fable-5.2",
6 "messages": [{"role": "user", "content": "Hello"}]
7 }'
python
1from openai import OpenAI
2
3client = OpenAI(
4 base_url="https://api.relayswitch.io/v1",
5 api_key="YOUR_RELAYSWITCH_KEY",
6)
7reply = client.chat.completions.create(
8 model="claude-fable-5.2",
9 messages=[{"role": "user", "content": "Hello"}],
10)
11print(reply.choices[0].message.content)
node
1import OpenAI from "openai";
2
3const client = new OpenAI({
4 baseURL: "https://api.relayswitch.io/v1",
5 apiKey: process.env.RELAYSWITCH_KEY,
6});
7const reply = await client.chat.completions.create({
8 model: "claude-fable-5.2",
9 messages: [{ role: "user", content: "Hello" }],
10});
11console.log(reply.choices[0].message.content);

Code that already calls OpenAI

The Python and TypeScript SDKs read two environment variables, so a service switches with no code change.

bash
1export OPENAI_BASE_URL="https://api.relayswitch.io/v1"
2export OPENAI_API_KEY="YOUR_RELAYSWITCH_KEY"

Streaming

Set stream: true and read server-sent events.

node
1const stream = await client.chat.completions.create({
2 model: "claude-fable-5.2",
3 messages: [{ role: "user", content: "Write a haiku" }],
4 stream: true,
5});
6for await (const chunk of stream) {
7 process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
8}
The endpoint

Paths on the base URL

Host api.relayswitch.io. The model id in the request picks the model; every path bills the same prepaid balance.

PathFormatModels
/v1/chat/completionsOpenAI Chat Completions313
/v1/completionsOpenAI Completions313
/v1/messagesAnthropic Messages313
/v1/responsesOpenAI Responses313
/v1beta/models/{model}:generateContentGemini generateContent313
/v1/embeddingsOpenAI Embeddings8
/v1/rerankRerank1

Counted at render from the endpoints each catalog row lists. GET https://api.relayswitch.io/v1/models returns the ids.

Base URL

https://api.relayswitch.io/v1. Paste it with the /v1. The gateway also accepts the doubled /v1/v1 path a client builds when it appends its own.

Key

Sent as Authorization: Bearer, the header every OpenAI SDK writes. Keys start with sk-relay- and each can carry its own budget and rate limit.

Model ids

The developer's own ids, typed as the Models page prints them. An id the catalog does not list answers 404.

Streaming and tools

stream: true returns server-sent events. Tool calls keep the OpenAI shape in the request and in the answer.

Errors

401 for a missing or revoked key, 402 for an empty balance or a key at its budget, 429 for a key over its rate limit. The docs list each code.

Receipts

Every request has a signed receipt with the model, the billed tokens and the charge, fetched by the request id.

Clients

Where it drops in

Any client with a base URL field and a key field. Each guide fills in that client’s own settings.

ClientWhat the guide sets
OpenClawa models.providers block in openclaw.json, a key for OpenClaw alone with a budget, the models to start with and the daily check
Hermes Agenta providers entry in config.yaml with the key in .env, a key for Hermes alone with a budget, an agent turn priced live
OpenCodean opencode.json custom provider with model limits from the catalog, a key for OpenCode alone with a budget
Cursorthe key as the OpenAI key with the base URL overridden
SDKsOpenAI, Anthropic and Vercel AI SDK setup
LibreChata custom endpoint in librechat.yaml with the base URL, an env-var key, a models.default list and a small titleModel
Difythe OpenAI-API-compatible provider: one entry per model with the id, key, endpoint URL and limits from the catalog
New API upstreamthis key as the upstream channel of a New API or One API relay: type OpenAI, base URL, key, models, mapping; a capped key; approval for resale

Claude Code speaks Anthropic's Messages format, which the same base URL answers. The Claude Code guide has its two variables, and the Claude API page has every Claude rate.

Live prices

Models behind the endpoint

USD per million tokens, read from the catalog at render, with the developer’s list price beside ours where the catalog has it.

ModelInputCachedOutputDeveloper list in / outContext
Claude Fable 5.2$4.00 (50% under)$0.10$20.00 (50% under)$8.00 / $40.001M tokens
Claude Opus 5.5$2.716 (32% under)$0.1455$9.70 (51% under)$4.00 / $20.001M tokens
DeepSeek V4.1 Flash 1017$0.2425 (19% under)$0.0058$1.164 (3% under)$0.30 / $1.201M tokens
GLM 5.3 Flash$0.0873 (41% under)$0.0109$0.1455 (70% under)$0.15 / $0.501M tokens
GPT-6 Luna$0.0625 (37% under)$0.0125$0.20 (60% under)$0.10 / $0.501.1M tokens
Qwen3.8 Max$0.80 (60% under)$0.60$2.40 (60% under)$2.00 / $6.00991K tokens
Minimax M3.1 Flash$0.105 (30% under)$0.0105$0.42 (30% under)$0.15 / $0.601M tokens
Gemini 3.8 Flash$0.4925 (34% under)$0.0493$2.25 (40% under)$0.75 / $3.751M tokens
Grok 4.7$0.60 (70% under)$0.15$1.80 (70% under)$2.00 / $6.00500K tokens
Kimi K3$0.90 (70% under)$0.12$4.50 (70% under)$3.00 / $15.001M tokens

USD per million tokens, read from the RelaySwitch catalog when this page was built. Developer list: the catalog's record of the developer's own price.

FAQs

OpenAI-compatible API: questions

The base URL, the key, formats and cost.

Open the console

A key in under a minute

Get a key

Or email hello@relayswitch.io

One base URL, one key

Prepaid from $10 by card or in USDT, USDC, BTC, ETH, SOL. Two values change in your client.

Join on Telegram