Skip to content

Preview: contracts not deployed on Elysium yet. Wallet connect works; no balances or transactions.

Cerebra
API reference

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/v1

All endpoints live under /v1 and speak JSON over HTTPS. Responses follow the OpenAI schema, with extra cost fields added.

Your first request

  1. Fund your balance

    Deposit CEREBRA to receive a USD API balance.

  2. Create a key

    Sign the key message from the dashboard, or follow Authentication. Keys start with cerebra_.

  3. 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.

200 OK
{
  "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

Unknown request fields are forwarded to the provider, so provider-specific options such as temperature, top_p and tools keep working where the model supports them.

Next steps

TopicWhere
How keys are derived and rotatedAuthentication
Every endpoint with examplesEndpoint reference
Status codes and rate limitsErrors and limits
Prices per million tokensModels and pricing