API Documentation
AI Bridge is a unified, OpenAI-compatible gateway. Point your existing SDK at our endpoint — no code changes required.
Quick Start
Change one line. That's it.
import openai
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.apibridge.cc/v1",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)import OpenAI from 'openai'
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.apibridge.cc/v1',
})
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.choices[0].message.content)curl https://api.apibridge.cc/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'Authentication
All requests require a Bearer token in the Authorization header. Create API keys from Dashboard → API Keys.
Authorization: Bearer sk-...
Keep your API key secret. Never expose it in client-side code or public repositories.
Chat Completions
POST https://api.apibridge.cc/v1/chat/completions
Request body
modelrequiredstring
Model ID. See the Models section for available options.
messagesrequiredarray
Array of message objects with role and content.
streamboolean
If true, returns a Server-Sent Events stream. Default: false.
max_tokensinteger
Maximum tokens to generate.
temperaturenumber
Sampling temperature 0–2. Default: 1.
Example response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1714000000,
"model": "gpt-4o",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 10, "completion_tokens": 8, "total_tokens": 18 }
}Streaming
Set stream: true to receive tokens as they're generated via Server-Sent Events.
stream = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)# Each SSE event:
data: {"id":"...","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: [DONE]Models
Use GET /v1/models to list available models programmatically, or refer to the table below.
| Model ID | Provider | Context |
|---|---|---|
| gpt-4o | OpenAI | 128K |
| gpt-4o-mini | OpenAI | 128K |
| claude-3-5-sonnet-20241022 | Anthropic | 200K |
| claude-3-5-haiku-20241022 | Anthropic | 200K |
| gemini-1.5-pro | 1M | |
| gemini-1.5-flash | 1M | |
| gemini-2.0-flash | 1M | |
| deepseek-chat | DeepSeek | 64K |
| deepseek-reasoner | DeepSeek | 64K |
| moonshot-v1-128k | Moonshot | 128K |
| kimi-k2.5 | Moonshot | 128K |
Error Codes
| HTTP | Code | Meaning |
|---|---|---|
| 401 | invalid_api_key | API key is missing or invalid. |
| 402 | insufficient_balance | Account balance is too low. Top up from the dashboard. |
| 429 | rate_limit_exceeded | RPM or TPM limit reached. Retry after a short delay. |
| 503 | upstream_error | All upstream providers failed. Retry after a short delay. |
// Error response format
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded: 10 RPM"
}
}