Quickstart
Cerebra is a drop-in OpenAI-compatible API. Change the base URL and API key, and your existing code works.
Base URL
https://api.cerebrafi.xyz/v1All endpoints live under /v1 and speak JSON over HTTPS. Responses follow the OpenAI schema, with extra cost fields added.
Your first request
Fund your balance
Deposit CEREBRA to receive a USD API balance.
Create a key
Sign the key message from the dashboard, or follow Authentication. Keys start with
cerebra_.Send a request
Pick any model from Models and call chat completions.
curl https://api.cerebrafi.xyz/v1/chat/completions \
-H "Authorization: Bearer $CEREBRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-flash",
"messages": [{ "role": "user", "content": "Say hello in one sentence." }],
"max_cost": 0.02
}'The response is a standard chat completion. usage.cost is the exact USD charged for the call.
{
"id": "chatcmpl-cerebra-0b5f6f1e-3a52-4f2c-9c1b-7f3d1c1e2a10",
"object": "chat.completion",
"model": "deepseek/deepseek-flash",
"choices": [
{ "index": 0, "message": { "role": "assistant", "content": "Hello! How can I text-sm text-muted?" }, "finish_reason": "stop" }
],
"usage": { "prompt_tokens": 9, "completion_tokens": 8, "total_tokens": 17, "cost": 0.0000123 }
}Streaming
Set stream: true to receive server-sent events. Cerebra requests usage from the provider automatically, so the final chunk carries usage.cost. Your balance is settled when the stream closes.
curl -N https://api.cerebrafi.xyz/v1/chat/completions \
-H "Authorization: Bearer $CEREBRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-flash",
"stream": true,
"messages": [{ "role": "user", "content": "Write a haiku about ledgers." }]
}'Capping spend
Add max_cost (USD) to any request to cap what that call can cost. If the cap is below the worst case, the gateway lowers max_tokens to fit. Details are in the reference.
Compatibility
temperature, top_p and tools keep working where the model supports them.Next steps
| Topic | Where |
|---|---|
| How keys are derived and rotated | Authentication |
| Every endpoint with examples | Endpoint reference |
| Status codes and rate limits | Errors and limits |
| Prices per million tokens | Models and pricing |