Quickstart

Get started with TheRouter.ai

TheRouter.ai provides a unified, OpenAI-compatible API that gives you access to multiple AI models through a single endpoint. Available routes and fallback behavior depend on your model and configuration. Get started with a short request.

Before your first request
Create an account or sign in, then create an API key in the dashboard. Store the key securely and set THEROUTER_API_KEY in your environment. Check the model catalog for an available model and its current price before sending a request.
OpenAI SDK Compatible
Use the OpenAI SDK with TheRouter.ai's base URL and API key. Check model availability and supported parameters for your application.
API Endpoint
Use the global endpoint for all requests: https://api.therouter.ai/v1. The legacy China accelerated endpoint is retired and should not be used for new integrations.

Using a coding client instead of an SDK?

If your first successful request will happen inside a coding tool instead of code, take the dedicated setup path now and come back to SDK details later.

Using the OpenAI SDK

The fastest way to get started. Use the official OpenAI SDK with TheRouter.ai's base URL.

TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'https://api.therouter.ai/v1',
  apiKey: '<THEROUTER_API_KEY>',
});

async function main() {
  const completion = await openai.chat.completions.create({
    model: 'anthropic/claude-sonnet-4.5',
    messages: [
      {
        role: 'user',
        content: 'What is the meaning of life?',
      },
    ],
  });

  console.log(completion.choices[0].message);
}

main();

Using the API Directly

Send requests directly to the TheRouter.ai API endpoint.

Base URL: https://api.therouter.ai/v1

cURL
curl https://api.therouter.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $THEROUTER_API_KEY" \
  -d '{
  "model": "anthropic/claude-sonnet-4.5",
  "messages": [
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
}'

Streaming

TheRouter.ai supports streaming responses via Server-Sent Events (SSE). Add stream: true to your request to receive tokens as they're generated.

TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'https://api.therouter.ai/v1',
  apiKey: '<THEROUTER_API_KEY>',
});

const stream = await openai.chat.completions.create({
  model: 'anthropic/claude-sonnet-4.5',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content || '';
  process.stdout.write(content);
}

Model Naming

TheRouter.ai uses a standard provider/model-name format. For example:

Available Models
anthropic/claude-opus-4.6     # Claude Opus 4.6
anthropic/claude-sonnet-4.5  # Claude Sonnet 4.5
anthropic/claude-haiku-4.5   # Claude Haiku 4.5
openai/gpt-4o                # GPT-4o
openai/gpt-4o-mini           # GPT-4o Mini

Browse all available models on the Models page.

Next Steps

  • Principles β€” Learn about TheRouter.ai's architecture and design decisions
  • Model Fallbacks β€” Configure automatic failover between providers
  • Coding Tools Setup β€” Open the hub for Cursor, Claude Code, cc-switch, OpenClaw, and other coding clients
  • cc-switch Integration β€” Use TheRouter presets when one team switches across multiple local coding clients
  • API Reference β€” Complete endpoint documentation
  • Streaming β€” Detailed guide to streaming responses
Help & contact