Getting Started
Quick start
If you already use the OpenAI SDK, migrating takes two lines. Point baseURL at the Celon gateway and swap your API key for an sk-celon-* key. The rest of your code runs unchanged.
A two-line migration
Celon exposes a drop-in OpenAI-compatible API. Request and response formats, streaming, and function calling all stay compatible with your existing code, while the gateway handles routing, caching, and governance in between.
const client = new OpenAI({
- baseURL: "https://api.openai.com/v1",
- apiKey: process.env.OPENAI_API_KEY,
+ baseURL: "https://api.celon.ai/v1", // ← Celon gateway
+ apiKey: process.env.CELON_API_KEY, // ← sk-celon-…
});Sending your first request — curl
Pass "celon/auto" as the model and the classifier scores the prompt’s difficulty and routes it to the cheapest model in an appropriate tier. If you want a specific model, just use its catalog id (for example openai/gpt-5.2).
curl https://api.celon.ai/v1/chat/completions \
-H "Authorization: Bearer sk-celon-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "celon/auto",
"messages": [
{ "role": "user", "content": "Explain PostgreSQL indexes in one sentence" }
]
}'The celon field in the response body and the x-celon-* headers tell you which model handled the request and how much it cost and saved. For the full picture, see the Smart routing guide.
Python — openai SDK
from openai import OpenAI
client = OpenAI(
base_url="https://api.celon.ai/v1", # Celon gateway
api_key="sk-celon-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
res = client.chat.completions.create(
model="celon/auto", # the classifier picks the tier that matches the difficulty
messages=[{"role": "user", "content": "Explain PostgreSQL indexes in one sentence"}],
)
print(res.choices[0].message.content)TypeScript — openai package
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.celon.ai/v1", // Celon gateway
apiKey: process.env.CELON_API_KEY, // sk-celon-…
});
const res = await client.chat.completions.create({
// "celon/code" for coding, "celon/quality" for quality, "celon/nitro" for speed, "celon/floor" for the lowest price
model: "celon/auto",
messages: [{ role: "user", content: "Explain PostgreSQL indexes in one sentence" }],
});
console.log(res.choices[0].message.content);Running the gateway locally
Three lines at the monorepo root bring the gateway up. Because CELON_ENABLE_MOCK=1 is the default, you can demo the entire routing and caching flow with the built-in mock model (celon/mock) even without a single upstream provider key.
cp .env.example .env # CELON_ENABLE_MOCK=1 by default — runs without upstream keys
pnpm install
pnpm dev:gateway # → http://localhost:8787Provider keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, and so on) are all optional — only the adapters for providers you hold a key for get registered.