Skip to content

API reference: overview and authentication

Base URLs and authentication headers for the three API formats, streaming, error formats, the full list of endpoints, and the settings for an API key.

The CodaAPI gateway serves three API formats: the OpenAI-compatible format, the Claude format (Anthropic Messages) and the native Gemini format. All three use the same API key and bill the same account balance. This page covers what the three formats have in common: addresses, authentication, streaming and errors. Each endpoint's parameters and examples are on its own page; see Endpoints.

Addresses and authentication

API format Base URL Authentication
OpenAI-compatible https://codaapi.com/v1 Authorization: Bearer sk-…
Claude (Anthropic Messages) https://codaapi.com (the SDK and Claude Code append /v1/messages themselves) x-api-key: sk-… or Authorization: Bearer sk-…
Native Gemini https://codaapi.com (endpoint paths start with /v1beta/) x-goog-api-key: sk-…, or add ?key=sk-… after the address; Authorization: Bearer sk-… also works

The main difference is whether the Base URL has /v1. Clients that use the OpenAI format (the OpenAI SDK, Cursor and so on) generally want the address with /v1. The Anthropic and Gemini SDKs want the root address and add the version path themselves. Some tools add /v1 themselves, so follow the setup page for each tool. An extra /v1 (the request becomes /v1/v1/…) returns a 404 "Invalid URL". A missing /v1 sends the request to the console's web pages, which may return 200 with a web page instead of JSON; the client then usually reports a JSON parsing error.

You can also see and copy the endpoint addresses by clicking API Addresses at the top right of the API Keys page in the console.

A minimal request:

curl https://codaapi.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-5.4-mini", "messages": [{"role": "user", "content": "Hello"}]}'

Where each authentication header works

The gateway only reads the Anthropic and Gemini key headers on certain paths. Everywhere else it only reads Authorization:

Form Works on Notes
Authorization: Bearer sk-… Every endpoint The general form. The OpenAI SDK and Claude Code's ANTHROPIC_AUTH_TOKEN use it
x-api-key: sk-… Endpoints whose path contains /v1/messages or /v1/models Used by the Anthropic SDK and Claude Code's ANTHROPIC_API_KEY
x-goog-api-key: sk-… /v1beta/models/…, /v1/models and the paths under it, /v1beta/openai/models Used by the google-genai SDK
?key=sk-… Same as above Keys in the address are easily recorded by logs and proxies, so use a header when you can

If you send x-api-key or x-goog-api-key on any other path (for example x-api-key to /v1/chat/completions), the gateway finds no key and returns 401. One form per request is enough.

Streaming

All three formats support streaming responses, delivered as SSE (Content-Type: text/event-stream):

Endpoint How to turn it on What comes back
OpenAI Chat Completions "stream": true in the request body One data: {…} line per chunk, ending with data: [DONE]. By default the last chunk carries usage; send "stream_options": {"include_usage": false} if you don't want it
OpenAI Responses "stream": true in the request body Events in the OpenAI Responses format; see Responses
Claude Messages "stream": true in the request body Events such as message_start, content_block_delta … message_stop; see Claude format
Gemini Change the path to :streamGenerateContent?alt=sse One data: {…} line per chunk, each a GenerateContentResponse; see Gemini format

For long answers and reasoning models the first token can take a while, so don't set the client's read timeout too short. If an error happens after the stream has started, it arrives as the last message in the stream (event: error in the Claude format, data: {"error": …} in the others) rather than as a different HTTP status code.

Error formats

For most errors the HTTP status code isn't 200, and the response body gives the reason, ending with the request's ID (request id). The same ID is in the X-Oneapi-Request-Id response header. Including it when you contact us makes troubleshooting much faster. Two exceptions: the 404 "Invalid URL" for a wrong address has no request id in the message (the response header still has it), and GET /v1/models/{model} returns 200 when the model isn't found, with the error in the body's error.

The error body comes in two formats, depending on the step where the request fails:

  • Entry checks: every request first goes through entry checks: whether the key is valid, whether the source IP is on the whitelist, whether the key may use this model, whether the group is available, whether the model is in the group, and whether a channel is available. Errors at this step are in the OpenAI format, whatever the endpoint's format.
  • Inside the relay flow: errors after the entry checks have passed. Besides the upstream rejecting the request, this includes failures before anything is sent upstream, such as a balance too low for the pre-charge (403), the key's own quota running short (403, token quota is not enough), a model whose price isn't configured yet (400), or a request missing a required field (400). Errors at this step follow the endpoint's format: the Claude format on /v1/messages, the OpenAI format on the others.

OpenAI format (every error on the OpenAI-compatible and native Gemini endpoints, and errors on /v1/messages that are stopped at the entry checks):

{
  "error": {
    "message": "Invalid token (request id: 20261130…)",
    "type": "new_api_error",
    "code": ""
  }
}

The native Gemini endpoints return this structure on errors too, not Google's error.status form. The google-genai SDK raises an exception based on the HTTP status code, with the reason in error.message.

Claude format (errors on /v1/messages inside the relay flow, for example a balance too low for the pre-charge, or the upstream rejecting the request):

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "… (request id: 20261130…)"
  }
}

Platform endpoints (endpoints that start with /api/; see Usage and logs and Status and pricing):

{ "success": false, "message": "…" }

For the usual causes of each status code and what to do, see Troubleshooting.

Endpoints

OpenAI format (Base URL https://codaapi.com/v1)

Method and path Purpose Notes
POST /v1/chat/completions Chat (Chat Completions) Chat Completions
POST /v1/responses Chat (Responses), used by Codex Responses
tools and response_format on the two endpoints above Function calling, structured output Tools and structured output
Image input on the two endpoints above Vision Vision
POST /v1/embeddings Text embeddings Embeddings
POST /v1/audio/transcriptions Speech to text Speech to text
GET /v1/models List the models this key can use; not billed List models

Claude format

Method and path Purpose Notes
POST /v1/messages Native Claude chat (Anthropic Messages) Messages API
POST /v1/chat/completions Call Claude models in the OpenAI format Via the OpenAI format

Gemini format

Method and path Purpose Notes
POST /v1beta/models/{model}:generateContent Native Gemini chat and image generation generateContent
POST /v1beta/models/{model}:streamGenerateContent?alt=sse Same, streamed generateContent
GET /v1beta/models List models in the Gemini format Not billed
POST /v1/chat/completions Call Gemini models in the OpenAI format Via the OpenAI format

Images and video

Method and path Purpose Notes
POST /v1/images/generations, POST /v1/images/edits Generate and edit images with gpt-image gpt-image
See the page Gemini image models (Nano Banana) Nano Banana
See the page Grok image and video models Grok Imagine
POST /v1/videos Submit a video generation task (asynchronous), currently for the Grok Imagine video models Grok Imagine video
GET /v1/videos/{task id} Check a video task's progress, and get the video address once it's complete Check a task

Platform API

Method and path Purpose Notes
GET /api/usage/token/, GET /api/log/token Look up this key's quota and usage records with the API key Usage and logs
GET /v1/dashboard/billing/subscription, GET /v1/dashboard/billing/usage Quota lookup in the legacy OpenAI format Usage and logs
GET /api/status, GET /api/pricing The site's public settings and the Model Square data; no key needed Status and pricing

Other

Method and path Purpose Notes
POST /v1/audio/speech Speech synthesis The gateway provides this endpoint; it only works when Model Square has a matching model. No example yet
POST /v1/rerank Reranking Same as above

Whether a call works also depends on whether the requested model supports that endpoint. For example, an image model can't use the chat endpoint, and a chat model can't generate images. Model Square marks the endpoint types each model supports.

Models and prices

The models currently available and their prices are in Model Square. You can filter by provider and endpoint type, and view prices by group; you can also compare the groups in the price list. In code you can call GET /v1/models to get the model names this key can use, or call the public GET /api/pricing (see Status and pricing).

A key's group decides which models it can use; see Groups. This documentation doesn't copy specific prices. For how charges work, see Pricing and multipliers.

API key settings

Manage API keys in the console under General → API Keys (open it directly). Click Create API Key, or the edit button on an existing key's row:

Setting What it does
Name For your own reference, to tell keys for different purposes apart
Group Decides which models this key can use, which kind of channel it uses and which group rate applies. Always choose a group that contains the models you want; see Choosing a group by model. Left empty, the key inherits your account's own group, which may not let you call any model at all
Expiration Time Defaults to Never. After the expiration time the key stops working and requests return 401
Quantity How many keys with the same settings to create at once
Unlimited Quota On by default, meaning the key itself has no spending cap (it is still limited by your account balance). Turn it off to set a quota on the key, and it stops when the quota is used up
Model Limits Only allows this key to call the models on the list. Leave it empty for no limit
IP Whitelist (supports CIDR) Only accepts requests from these addresses, which suits servers with a fixed outbound IP
Allow querying user quota Under Advanced Settings. When on, calling /api/usage/token/ with this key also returns the account balance; see Usage and logs

The status shown in the list is one of four values: Enabled, Disabled, Expired or Exhausted. Only Enabled keys can call models.

In the menu on a key's row, Copy Key copies the full key, and you can copy it again at any time. CC Switch imports the key into CC Switch; see CC Switch for how to use it. Once you delete a key, requests that use it fail immediately.

We recommend creating one key per application and per machine, with a quota and model limits where needed. That way, if one key leaks, you only have to stop that one.

What the gateway does

  • Protocol conversion: your request arrives in the format you chose, and the gateway converts it to the upstream provider's format. A Claude or Gemini model that you can call in its native format can usually also be called in the OpenAI format (the endpoint types marked in Model Square are authoritative). For the differences, see Claude via the OpenAI format and Gemini via the OpenAI format.
  • Streaming: all three formats support streaming responses; see Streaming.
  • Tool calling and multimodal input: tool definitions, images and other content in your request are forwarded to the model. Whether they work depends on the model itself.
  • Usage records: the time, key, model, token counts, charge and duration of each request are written to the usage logs, and you can also query them with the key. Request content for chat and the synchronous image endpoints isn't stored; asynchronous tasks such as video generation store the submitted content and the task result so you can check their progress (see Data and privacy).
  • Quota and permissions: set a quota, model limits and an IP whitelist on the key to stop calls that shouldn't happen before the request reaches the upstream.

Updated