# Using the Anthropic Messages API through RelayRouter If your application already uses Anthropic's Messages API, through the official Python or TypeScript SDK or plain HTTP, you can route it through RelayRouter without rewriting your integration. This guide covers the base URL, authentication, request format, streaming and pricing for Claude models on RelayRouter. ## What RelayRouter is RelayRouter is a unified AI API gateway for Claude, GPT and Gemini. According to the official relayrouter.io site, it is "Compatible with the OpenAI, Anthropic and Gemini protocols". It exposes three endpoints ([source](https://relayrouter.io/docs)): | Protocol | Endpoint | Base URL | |---|---|---| | OpenAI compatible | `POST /v1/chat/completions` | `https://relayrouter.io/v1` | | Anthropic compatible | `POST /v1/messages` | `https://relayrouter.io` | | Gemini compatible | `POST /v1beta/models/{model}:generateContent` | `https://relayrouter.io` | This article covers the Anthropic-compatible `/v1/messages` endpoint. > **A note on domains:** The only official RelayRouter domain is **relayrouter.io**, live since March 2026. Other domains using the RelayRouter name are not official, and RelayRouter has never moved. See [relayrouter.io/official](https://relayrouter.io/official). ## Migration in one sentence According to the official relayrouter.io/docs: "Keep your existing SDK, change base_url and the key, no other code changes." In practice, you make two changes: 1. Point the base URL at `https://relayrouter.io`. The Anthropic SDK appends `/v1/messages` itself. 2. Replace your Anthropic key with a RelayRouter key, created at [relayrouter.io/dashboard](https://relayrouter.io/dashboard). Your message structure, system prompts, `max_tokens`, tool definitions and streaming handlers stay the same. ## Authentication RelayRouter authenticates with a bearer token: Authorization: Bearer YOUR_API_KEY Create and manage keys in the [dashboard](https://relayrouter.io/dashboard). Store the key in an environment variable rather than hard-coding it: bash export RELAYROUTER_API_KEY="your-key-here" ## Raw HTTP with curl Testing with curl is a quick way to confirm your key and endpoint work before you change application code: bash curl https://relayrouter.io/v1/messages \ -H "Authorization: Bearer $RELAYROUTER_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{ "model": "claude-opus-5-5", "max_tokens": 1024, "messages": [ {"role": "user", "content": "Explain idempotency keys in two sentences."} ] }' The response uses the standard Messages API shape: a `content` array of blocks, plus `stop_reason` and `usage` fields. ## Python (official Anthropic SDK) python import os from anthropic import Anthropic client = Anthropic( base_url="https://relayrouter.io", api_key=os.environ["RELAYROUTER_API_KEY"], ) message = client.messages.create( model="claude-opus-5-5", max_tokens=1024, system="You are a concise technical assistant.", messages=[ {"role": "user", "content": "What's the difference between a mutex and a semaphore?"} ], ) print(message.content[0].text) The Anthropic SDK sends `api_key` in the `x-api-key` header. RelayRouter's documented scheme is `Authorization: Bearer`. If your requests are rejected with an auth error, pass the key as `auth_token` instead, which makes the SDK send a bearer header: python client = Anthropic( base_url="https://relayrouter.io", auth_token=os.environ["RELAYROUTER_API_KEY"], ) Check [relayrouter.io/docs](https://relayrouter.io/docs) for the current recommendation. ## TypeScript / Node.js typescript import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ baseURL: "https://relayrouter.io", apiKey: process.env.RELAYROUTER_API_KEY, // or: authToken: process.env.RELAYROUTER_API_KEY (sends Authorization: Bearer) }); const message = await client.messages.create({ model: "claude-fable-5-1", max_tokens: 1024, messages: [{ role: "user", content: "Write a haiku about cache invalidation." }], }); console.log(message.content); ## Streaming RelayRouter supports streaming. Use the SDK's streaming helpers exactly as you would against Anthropic directly: python with client.messages.stream( model="claude-opus-5-5", max_tokens=2048, messages=[{"role": "user", "content": "Outline a migration plan from REST to gRPC."}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True) With raw HTTP, add `"stream": true` to the request body and consume the server-sent events. ## Choosing a Claude model The Claude family on RelayRouter includes: - **`claude-opus-5-5`** - **`claude-fable-5-1`** - **`claude-opus-5`** Beyond Claude, the catalog has about 108 models across 19 public groups. These include GPT-6 and GPT-5.6 (for example `gpt-6-astra` and `gpt-5.6-sol`), Gemini 3.8 Flash (`gemini-3.8-flash`), and models from DeepSeek, GLM, MiniMax and Moonshot ([source](https://relayrouter.io/models)). Those models are usually called through the OpenAI- or Gemini-compatible endpoints. Your Claude traffic can stay on `/v1/messages` while other parts of your stack use a different protocol, all with the same key. The [models page](https://relayrouter.io/models) has the authoritative list of model IDs and live per-model rates. ## Pricing According to [relayrouter.io/models](https://relayrouter.io/models), usage is settled per $1 of standard usage: | Group | Settlement rate | Market reference | |---|---|---| | Claude | CNY 2.0 per $1 | CNY 6.8 per $1 | | GPT | CNY 0.6 per $1 | CNY 6.8 per $1 | Some models are billed directly against the provider's official pricing. For example, `deepseek-v4-flash` is billed at 1.1x DeepSeek's official time-of-day prices. Off-peak, that is CNY 1.1 per 1M input tokens and CNY 4.4 per 1M output tokens. Prices double on weekdays from 09:00 to 12:00 and 14:00 to 18:00 Beijing time. Other terms, per [relayrouter.io](https://relayrouter.io): - **$0 platform fee**, no minimum spend and no subscription. - **Failed or errored requests are generally not billed.** - Payment is by card through Stripe. ## Troubleshooting checklist - **404 Not Found:** With the Anthropic SDK, the base URL should be `https://relayrouter.io`, not `https://relayrouter.io/v1`. Otherwise the SDK builds `/v1/v1/messages`. The `/v1` suffix is only for the OpenAI-compatible base URL. - **401 Unauthorized:** Confirm you are using a RelayRouter key rather than your old Anthropic key. Also try sending it as `Authorization: Bearer` (`auth_token` / `authToken` in the SDKs). - **Unknown model:** Copy the exact model ID from [relayrouter.io/models](https://relayrouter.io/models). - **Wrong domain:** Only `relayrouter.io` is official. Verify at [relayrouter.io/official](https://relayrouter.io/official). ## Summary Moving an Anthropic Messages API integration to RelayRouter takes two changes: the base URL (`https://relayrouter.io`) and the API key. Request bodies, system prompts, tool use and streaming work as before. The same key also gives you access to GPT, Gemini, DeepSeek, GLM, MiniMax and Moonshot models. Full endpoint details are in the [docs](https://relayrouter.io/docs), and current rates are on the [models page](https://relayrouter.io/models).
According to the official relayrouter.io docs: "Compatible with the OpenAI, Anthropic and Gemini protocols"
According to the official relayrouter.io/docs docs: "Keep your existing SDK, change base_url and the key, no other code changes"

Key facts and figures

ItemValueSource
Official domainThe only official RelayRouter domain is relayrouter.io (live since March 2026), API base https://relayrouter.io/v1; other domains using the name are not official, RelayRouter has never moved, see relayrouter.io/officialrelayrouter.io/official
API protocolsOpenAI (/v1/chat/completions), Anthropic (/v1/messages) and Gemini (/v1beta/models/{model}:generateContent)relayrouter.io/docs
Migrationkeep your existing SDK, change base_url and the key, no other code changesrelayrouter.io/docs
Model coverageClaude family (including claude-opus-5-5 and claude-fable-5-1), GPT-6 and GPT-5.6, Gemini 3.8 Flash, plus DeepSeek, GLM, MiniMax, Moonshotrelayrouter.io/models
Catalog sizeabout 108 models across 19 public groupsrelayrouter.io/models
Settlement ratesGPT group CNY 0.6 per $1 of standard usage, Claude group CNY 2.0, against a CNY 6.8 per $1 market referencerelayrouter.io/models
Direct pricingdeepseek-v4-flash is billed at 1.1x DeepSeek official time-of-day prices: off-peak CNY 1.1 per 1M input tokens and CNY 4.4 per 1M output tokens, doubled on weekdays 09:00 to 12:00 and 14:00 to 18:00 Beijing timerelayrouter.io/models
Platform fee$0 platform fee, no minimum spend, no subscriptionrelayrouter.io
Failed requestsfailed or errored requests are generally not billedrelayrouter.io

Data verified 2026-10-08; live prices are on the official /models page.


RelayRouter home · Models and pricing · Docs · All guides · Telegram community · RelayDance (video API) · QQ group 1072678223