API reference
Anthropic Messages
Use Anthropic's SDK and /v1/messages format with every chat model.
POST https://api.routerplex.com/v1/messages
RouterPlex accepts Anthropic's Messages API request format and returns Anthropic-format responses for every chat model in the catalog — Claude, GPT, Gemini, DeepSeek, Kimi, Qwen, and more. The same RouterPlex key and prepaid balance work across both API formats.
Anthropic SDK base URL: https://api.routerplex.com — do not append /v1; the SDK adds /v1/messages itself.
curl #
curl https://api.routerplex.com/v1/messages \-H "x-api-key: $ROUTERPLEX_KEY" \-H "anthropic-version: 2023-06-01" \-H "content-type: application/json" \-d '{"model": "gpt-5.4","max_tokens": 256,"messages": [{"role": "user", "content": "Explain HTTP in one line"}]}'
Authorization: Bearer $ROUTERPLEX_KEY also works if your HTTP client already uses bearer authentication.
Python SDK #
import osfrom anthropic import Anthropicclient = Anthropic(base_url="https://api.routerplex.com",api_key=os.environ["ROUTERPLEX_API_KEY"],)message = client.messages.create(model="gemini-3.5-flash",max_tokens=256,messages=[{"role": "user", "content": "Explain HTTP in one line"}],)print(message.content[0].text)
TypeScript SDK #
import Anthropic from "@anthropic-ai/sdk";const client = new Anthropic({baseURL: "https://api.routerplex.com",apiKey: process.env.ROUTERPLEX_API_KEY,});const message = await client.messages.create({model: "deepseek-v4-pro",max_tokens: 256,messages: [{ role: "user", content: "Explain HTTP in one line" }],});console.log(message.content);
Streaming #
Set stream: true or use the Anthropic SDK's streaming helper. RouterPlex returns Anthropic SSE events such as message_start, content_block_delta, and message_stop, including when the selected model is not a Claude model.
Which format should I use? #
| Client | Base URL | Format |
|---|---|---|
| OpenAI SDKs and OpenAI-compatible tools | https://api.routerplex.com/v1 | /v1/chat/completions |
| Anthropic SDK and Claude Code | https://api.routerplex.com | /v1/messages |
Both formats reach the same 36 chat models and deduct from the same balance. gpt-image-2 is image-generation only and uses /v1/images/generations, not a chat endpoint. Tool use, vision, thinking, and structured-output support still depend on the selected model.