Developer documentation
Pandoroute developer documentation
Use one OpenAI-compatible API, route by model or automatically, and track every request through the Console.
First steps
Make your first API call
The fastest path is to use Pandoroute as the base URL for an existing OpenAI-compatible client. The public site is https://pandoroute.ai/; customer API calls should use https://api.pandoroute.ai/v1.
-
1
Create an API key
Open
API Keys, create a key, and keep the raw key from the one-time creation screen. Default customer scopes includemodel:invoke,chat:read, andchat:write. -
2
Copy the Base URL
Open the Console connection panel and copy the Base URL:
https://api.pandoroute.ai/v1. The Console helper endpoint/api/connection-infois a session-only Console API and is not part of the public runtime API. -
3
Send one chat request
Use
model: "auto"for router-owned selection, or choose a specific model from/v1/modelsor the Model Plaza.
Connect
Use existing OpenAI clients
Most apps only need two changes: set baseURL to Pandoroute and replace the API key. The request body stays familiar.
export PANDOROUTE_BASE_URL="https://api.pandoroute.ai/v1"
export PANDOROUTE_API_KEY="sk_sli_your_key"
curl "$PANDOROUTE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $PANDOROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [
{ "role": "user", "content": "Explain Pandoroute in one sentence." }
]
}'
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PANDOROUTE_API_KEY,
baseURL: process.env.PANDOROUTE_BASE_URL
});
const response = await client.chat.completions.create({
model: "auto",
messages: [
{ role: "user", content: "Write a launch checklist." }
],
stream: false
});
process.stdout.write(response.choices[0].message.content);
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["PANDOROUTE_API_KEY"],
base_url=os.environ["PANDOROUTE_BASE_URL"],
)
response = client.chat.completions.create(
model="auto",
messages=[
{"role": "user", "content": "Summarize this product for a CTO."}
],
)
print(response.choices[0].message.content)
API reference
Runtime API surface
Customer traffic goes through the runtime service under /v1. Start with chat completions unless you specifically need Responses, Anthropic-style Messages, or file operations.
| Method | Endpoint | Use |
|---|---|---|
GET | /v1/models | List models visible to the caller's organization. |
GET | /v1/models/{modelId} | Fetch one enabled model. Returns not found or forbidden if unavailable. |
POST | /v1/chat/completions | Primary OpenAI-compatible chat endpoint. Supports streaming SSE. |
POST | /v1/responses | Responses-style input mapped into Pandoroute chat routing. |
POST | /v1/messages | Anthropic-style Messages surface for compatible clients. |
POST | /v1/messages/count_tokens | Estimate input tokens before sending a Messages request. |
POST | /v1/files | Upload files for file-aware model workflows. |
Pass Authorization: Bearer sk_sli_.... Runtime also accepts x-api-key for Anthropic-style clients.
Responses include a request-id header. Keep it with application logs so support can trace routing and billing events.
OpenAI-compatible streams emit SSE chunks and terminate with data: [DONE]. Billing continues to drain provider usage even if the client disconnects.
Success and streaming
Non-streaming chat requests return an OpenAI-compatible completion object. Streaming requests return server-sent events until the final data: [DONE] marker.
Non-streaming response
{
"id": "chatcmpl_example",
"object": "chat.completion",
"model": "model-id-from-response",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello." },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 3,
"total_tokens": 15
}
}
Streaming request
curl -N "$PANDOROUTE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $PANDOROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"stream": true,
"messages": [
{ "role": "user", "content": "Write a short status update." }
]
}'
HTTP status and recovery
| Status | Meaning | Client action |
|---|---|---|
200 | Request accepted and completed. | Read the response and usage fields. |
400 | Invalid JSON or an unsupported request field. | Fix the request before retrying. |
401 | The API key is missing, revoked, or invalid. | Create or rotate a key in the Console. |
402 | The balance or available quota is insufficient. | Top up credits or review the key budget. |
403 | The model or resource is not available to the organization. | Enable the model or request access. |
404 | The endpoint, model, or resource does not exist. | Check the model ID from /v1/models. |
429 | A rate or concurrency limit was reached. | Wait for Retry-After, then retry with backoff. |
5xx | A temporary runtime or provider failure occurred. | Retry with backoff and inspect fallback headers. |
Models and routing
Choose a model, or let the router choose
Pandoroute separates customer-facing model codes from upstream provider details. Your organization only sees models enabled by an admin. The router then picks an eligible channel based on model access, capability requirements, priority, weight, health, and fallback availability.
Specific model requests
Call GET /v1/models or open Model Plaza, then send a known model code. This is best when your app has strict quality, context, or cost expectations.
{
"model": "YOUR_ENABLED_MODEL_ID",
"messages": [{ "role": "user", "content": "Hello" }]
}
Automatic model routing
Send model: "auto" when the organization wants Pandoroute to choose an eligible route. The router considers request features like streaming, tool calls, and vision before selecting a target.
{
"model": "auto",
"stream": true,
"messages": [{ "role": "user", "content": "Draft release notes" }]
}
Billing and usage
Billing authorization and settlement
Pandoroute reserves estimated quota and billing capacity before the provider call, then settles against actual usage after completion. That keeps quota enforcement predictable during concurrent traffic and gives finance teams a request-level ledger.
Checks API key status, organization status, enabled model access, key rate limits, and estimated cost.
Calculates billable input, output, cache, and tool dimensions from provider usage.
View requests, tokens, credits, latency, status, model usage, and usage by key.
Console session API
These routes support the signed-in Console interface. They use the Console session rather than the public /v1 API key contract and may change with the Console UI.
| Method | Endpoint | Use |
|---|---|---|
GET | /api/usage/summary | Aggregate by model with optional time range and comparison. |
GET | /api/usage/summary/by-key | Aggregate by API key and project. |
GET | /api/usage/records | Request-level rows with token, latency, credit, status, and time. |
GET | /api/billing/ledger | Ledger entries for customer credit movement. |
Errors and fallback
API failures and fallback
Runtime errors use a stable JSON shape with a request ID. Rate limits and temporary service pressure include Retry-After. Fallback responses expose degradation metadata so your app can decide whether to display, retry, or audit the result.
Error response body
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "API key rate limit exceeded"
},
"request_id": "req_..."
}
Fallback response headers
X-SKYLINE-Degraded: true
X-SKYLINE-Fallback-Reason: channel_unhealthy
X-SKYLINE-Fallback-From: MODEL_ID_BEFORE_FALLBACK
X-SKYLINE-Fallback-To: MODEL_ID_AFTER_FALLBACK
Console workflow
Operate the gateway from the customer UI
The docs map directly to the current Console navigation so operators and developers use the same terms.
Create, rotate, disable, and delete keys. Copy the Base URL and first cURL from the quick-connect panel.
Search enabled models by provider, capability, model code, context window, and per-token pricing.
Review by model, by key, or at request-detail level with credits, tokens, latency, and status.
Enable or disable models distributed to the organization and manage member quotas.
Register provider base URLs, discover models, map channels, and set pricing dimensions.
Bind model abilities to channels, priority, weight, provider model codes, and adapter regions.
Desktop setup
Pandoroute Connector guides
These Chinese-language guides cover installing the desktop Connector, attaching supported clients, and recovering from failed attach or detach operations.
Before live traffic
Client go-live checklist
Use this as a final client-integration check before an app sends real traffic through Pandoroute. It is not a platform production runbook.