Using the API
Coco Router exposes the standard OpenAI API surface. Anything that can talk to OpenAI can talk to Coco Router by changing two settings: the base URL and the API key.
Connection settings
| Setting | Value |
|---|---|
| Base URL | https://router.cocolevio.com/dash/v1 |
| API key | A virtual key from Virtual Keys (use an auto-* key for auto-routing) |
| Model | auto (recommended) — or any explicit model id to pin one |
curl
curl https://router.cocolevio.com/dash/v1/chat/completions \
-H "Authorization: Bearer sk-YOUR-KEY" \
-H "Content-Type: application/json" \
-d '{"model":"auto","messages":[{"role":"user","content":"Write a Python LRU cache"}]}'
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://router.cocolevio.com/dash/v1",
api_key="sk-YOUR-KEY",
)
resp = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Summarize this meeting…"}],
)
print(resp.choices[0].message.content)
JavaScript / TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://router.cocolevio.com/dash/v1",
apiKey: "sk-YOUR-KEY",
});
const resp = await client.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "hi" }],
});
Reading the routing decision
raw = resp.model_dump() # or resp.json() on raw HTTP
print(raw.get("ai_router")) # {'tier': 'SIMPLE', 'model': 'openrouter/…'}
print(resp.model) # rewritten to the real backend model
Other endpoints
curl https://router.cocolevio.com/dash/v1/audio/transcriptions \
-H "Authorization: Bearer sk-YOUR-KEY" \
-F file=@answer.wav -F model=whisper-1
curl https://router.cocolevio.com/dash/v1/embeddings \
-H "Authorization: Bearer sk-YOUR-KEY" -H "Content-Type: application/json" \
-d '{"model":"text-embedding-3-small","input":"hello"}'
curl https://router.cocolevio.com/dash/v1/models -H "Authorization: Bearer sk-YOUR-KEY"