---
title: "OpenAI-compatible API: base URL, request, clients"
canonical: https://relayswitch.io/openai-compatible-api
generated: 2026-11-15T03:15:10.363Z
source: https://api.relayswitch.io/v1/catalog
base_url: https://api.relayswitch.io/v1
---

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/v1`OpenAI 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.

Model check

[daily real-model check](https://relayswitch.io/proof)

[Get a key](https://app.relayswitch.io/console)[Quickstart](https://relayswitch.io/docs)

Base URL`https://api.relayswitch.io/v1`

Chat completions`POST https://api.relayswitch.io/v1/chat/completions`

API key`Authorization: Bearer <key>`

A working request

## Send the first request

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

bash

1`curl 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

1`from openai import OpenAI`

2

3`client = OpenAI(`

4 `base_url="https://api.relayswitch.io/v1",`

5 `api_key="YOUR_RELAYSWITCH_KEY",`

6`)`

7`reply = client.chat.completions.create(`

8 `model="claude-fable-5.2",`

9 `messages=[{"role": "user", "content": "Hello"}],`

10`)`

11`print(reply.choices[0].message.content)`

node

1`import OpenAI from "openai";`

2

3`const client = new OpenAI({`

4 `baseURL: "https://api.relayswitch.io/v1",`

5 `apiKey: process.env.RELAYSWITCH_KEY,`

6`});`

7`const reply = await client.chat.completions.create({`

8 `model: "claude-fable-5.2",`

9 `messages: [{ role: "user", content: "Hello" }],`

10`});`

11`console.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

1`export OPENAI_BASE_URL="https://api.relayswitch.io/v1"`

2`export OPENAI_API_KEY="YOUR_RELAYSWITCH_KEY"`

### Streaming

Set `stream: true` and read server-sent events.

node

1`const stream = await client.chat.completions.create({`

2 `model: "claude-fable-5.2",`

3 `messages: [{ role: "user", content: "Write a haiku" }],`

4 `stream: true,`

5`});`

6`for 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.

| Path | Format | Models |
| --- | --- | --- |
| `/v1/chat/completions` | OpenAI Chat Completions | 313 |
| `/v1/completions` | OpenAI Completions | 313 |
| `/v1/messages` | Anthropic Messages | 313 |
| `/v1/responses` | OpenAI Responses | 313 |
| `/v1beta/models/{model}:generateContent` | Gemini generateContent | 313 |
| `/v1/embeddings` | OpenAI Embeddings | 8 |
| `/v1/rerank` | Rerank | 1 |

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.

| Client | What the guide sets |
| --- | --- |
| [OpenClaw](https://relayswitch.io/guides/openclaw) | a models.providers block in openclaw.json, a key for OpenClaw alone with a budget, the models to start with and the daily check |
| [Hermes Agent](https://relayswitch.io/guides/hermes-agent) | a providers entry in config.yaml with the key in .env, a key for Hermes alone with a budget, an agent turn priced live |
| [OpenCode](https://relayswitch.io/guides/opencode) | an opencode.json custom provider with model limits from the catalog, a key for OpenCode alone with a budget |
| [Cursor](https://relayswitch.io/guides/cursor) | the key as the OpenAI key with the base URL overridden |
| [SDKs](https://relayswitch.io/guides/sdks) | OpenAI, Anthropic and Vercel AI SDK setup |
| [LibreChat](https://relayswitch.io/guides/librechat) | a custom endpoint in librechat.yaml with the base URL, an env-var key, a models.default list and a small titleModel |
| [Dify](https://relayswitch.io/guides/dify) | the OpenAI-API-compatible provider: one entry per model with the id, key, endpoint URL and limits from the catalog |
| [New API upstream](https://relayswitch.io/guides/new-api-upstream) | this 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 |

More clients

-   [Open WebUI on the key](https://relayswitch.io/guides/open-webui)
-   [n8n on the key](https://relayswitch.io/guides/n8n)
-   [JanitorAI proxy on the key](https://relayswitch.io/guides/janitorai)
-   [SillyTavern on the key](https://relayswitch.io/guides/sillytavern)
-   [Chub on the key](https://relayswitch.io/guides/chub)
-   [RisuAI on the key](https://relayswitch.io/guides/risu)
-   [Agnai Third-Party preset on the key](https://relayswitch.io/guides/agnai)
-   [WyvernChat custom provider on the key](https://relayswitch.io/guides/wyvern)
-   [Sophia's LoreBary proxy with the key](https://relayswitch.io/guides/lorebary)
-   [KoboldAI Lite on the key, no GPU](https://relayswitch.io/guides/koboldai)
-   [Codex CLI on the key](https://relayswitch.io/guides/codex-cli)
-   [LangChain on the key](https://relayswitch.io/guides/langchain)
-   [OpenHands on the key](https://relayswitch.io/guides/openhands)
-   [Cline on the key](https://relayswitch.io/guides/cline)
-   [Roo Code on the key](https://relayswitch.io/guides/roo-code)
-   [Continue on the key](https://relayswitch.io/guides/continue)
-   [Kilo Code on the key](https://relayswitch.io/guides/kilo-code)
-   [Pi coding agent on the key](https://relayswitch.io/guides/pi)
-   [Aider on the key](https://relayswitch.io/guides/aider)
-   [LiteLLM on the key](https://relayswitch.io/guides/litellm)
-   [Vercel AI SDK on the key](https://relayswitch.io/guides/vercel-ai-sdk)
-   [GitHub Copilot on the key](https://relayswitch.io/guides/github-copilot)

Claude Code speaks Anthropic's Messages format, which the same base URL answers. The [Claude Code guide](https://relayswitch.io/guides/claude-code) has its two variables, and the [Claude API page](https://relayswitch.io/cheap-claude-api) 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.

| Model | Input | Cached | Output | Developer list in / out | Context |
| --- | --- | --- | --- | --- | --- |
| [Claude Fable 5.2](https://relayswitch.io/models/claude-fable-5.2) | $4.00 (50% under) | $0.10 | $20.00 (50% under) | $8.00 / $40.00 | 1M tokens |
| [Claude Opus 5.5](https://relayswitch.io/models/claude-opus-5-5) | $2.716 (32% under) | $0.1455 | $9.70 (51% under) | $4.00 / $20.00 | 1M tokens |
| [DeepSeek V4.1 Flash 1017](https://relayswitch.io/models/deepseek-v4.1-flash-1017) | $0.2425 (19% under) | $0.0058 | $1.164 (3% under) | $0.30 / $1.20 | 1M tokens |
| [GLM 5.3 Flash](https://relayswitch.io/models/glm-5.3-flash) | $0.0873 (41% under) | $0.0109 | $0.1455 (70% under) | $0.15 / $0.50 | 1M tokens |
| [GPT-6 Luna](https://relayswitch.io/models/gpt-6-luna) | $0.0625 (37% under) | $0.0125 | $0.20 (60% under) | $0.10 / $0.50 | 1.1M tokens |
| [Qwen3.8 Max](https://relayswitch.io/models/qwen3.8-max) | $0.80 (60% under) | $0.60 | $2.40 (60% under) | $2.00 / $6.00 | 991K tokens |
| [Minimax M3.1 Flash](https://relayswitch.io/models/minimax-m3.1-flash) | $0.105 (30% under) | $0.0105 | $0.42 (30% under) | $0.15 / $0.60 | 1M tokens |
| [Gemini 3.8 Flash](https://relayswitch.io/models/gemini-3.8-flash) | $0.4925 (34% under) | $0.0493 | $2.25 (40% under) | $0.75 / $3.75 | 1M tokens |
| [Grok 4.7](https://relayswitch.io/models/grok-4.7) | $0.60 (70% under) | $0.15 | $1.80 (70% under) | $2.00 / $6.00 | 500K tokens |
| [Kimi K3](https://relayswitch.io/models/kimi-k3) | $0.90 (70% under) | $0.12 | $4.50 (70% under) | $3.00 / $15.00 | 1M 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.

Related

-   [Docs](https://relayswitch.io/docs)
-   [SDK setup](https://relayswitch.io/guides/sdks)
-   [Every model and price](https://relayswitch.io/models)
-   [All guides](https://relayswitch.io/guides)
-   [Claude API, per token](https://relayswitch.io/cheap-claude-api)
-   [OpenRouter alternatives](https://relayswitch.io/alternatives/openrouter)
-   [Pricing](https://relayswitch.io/pricing)

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](https://app.relayswitch.io/console)

Or email [hello@relayswitch.io](mailto: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.

[Quickstart](https://relayswitch.io/docs)[Get a key](https://app.relayswitch.io/console)

