Quickstart
Get up and running with the TopRouter API in just a few minutes. This guide shows you how to make your first API call.
Prerequisites
- A TopRouter account (Register here)
- An API key from the API Keys page
Base URL
All API requests are made to:
https://toprouter.ccUsing OpenAI SDK
The easiest way to get started is with the official OpenAI SDK. Just change the base_url to TopRouter.
python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-toprouter-key",
base_url="https://toprouter.cc"
)
response = client.chat.completions.create(
model="google/gemini-3.5-flash",
messages=[
{"role": "user", "content": "Hello! What can you do?"}
]
)
print(response.choices[0].message.content)typescript
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: 'sk-your-toprouter-key',
baseURL: 'https://toprouter.cc'
});
const response = await openai.chat.completions.create({
model: 'google/gemini-3.5-flash',
messages: [
{ role: 'user', content: 'Hello! What can you do?' }
]
});
console.log(response.choices[0].message.content);bash
curl https://toprouter.cc/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-toprouter-key" \
-d '{
"model": "google/gemini-3.5-flash",
"messages": [
{"role": "user", "content": "Hello! What can you do?"}
]
}'Direct HTTP API
You can also make direct HTTP requests without any SDK:
python
import requests
response = requests.post(
"https://toprouter.cc/chat/completions",
headers={
"Authorization": "Bearer sk-your-toprouter-key",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-3.5-flash",
"messages": [
{"role": "user", "content": "Hello!"}
]
}
)
print(response.json())typescript
const response = await fetch('https://toprouter.cc/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-your-toprouter-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'google/gemini-3.5-flash',
messages: [{ role: 'user', content: 'Hello!' }]
})
});
const data = await response.json();
console.log(data);Streaming Responses
TopRouter supports streaming for real-time response output:
python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-toprouter-key",
base_url="https://toprouter.cc"
)
stream = client.chat.completions.create(
model="google/gemini-3.5-flash",
messages=[{"role": "user", "content": "Write a short poem"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Choosing a Model
TopRouter supports 200+ models. Here are some popular choices (updated for 2026):
| Model | Best For |
|---|---|
google/gemini-3.5-flash | Fast, cost-effective general use |
anthropic/claude-4.6-sonnet | Balanced coding & reasoning |
anthropic/claude-4.8-opus | Complex analysis & writing |
openai/gpt-5.5 | Multimodal tasks |
deepseek/deepseek-v4-flash-flash-pro | Deep reasoning |
TIP
Check the Models page for the full list of available models and pricing.
Next Steps
- Authentication — Learn about API key management
- Models — Browse all available models
- Top Up & Redeem — Add credits to your account
- Error Handling — Handle API errors gracefully
