CanalAPI
Getting started

Introduction

CanalAPI is a unified gateway over 600+ LLM, image, and audio models. Use any OpenAI-compatible client — point base_url at https://api.canalapi.com/v1, pass your key, and ship.

Ready in 60 seconds
Grab a key from the console, run the snippet below, done.
Get API key
→ Chat completions
OpenAI / Claude / Gemini and more — one consistent shape
→ Endpoints
Chat, Embeddings, Images, Audio, Moderations — full surface area
→ Authentication
Bearer token or x-api-key — both headers accepted
→ Streaming
SSE, token-by-token, OpenAI-compatible

Quickstart

You need two things: an API key (from the console) and a model slug. Here's the simplest possible request:

cURL
# Any OpenAI-compatible client works — just swap the base URL
curl https://api.canalapi.com/v1/chat/completions \
  -H "Authorization: Bearer $CANAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-4-sonnet",
    "messages": [{"role":"user","content":"Hello"}]
  }'

Response

application/json
{
  "id": "chatcmpl_8K2m3",
  "object": "chat.completion",
  "created": 1745078400,
  "model": "claude-4-sonnet",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hi there!" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 8, "completion_tokens": 3, "total_tokens": 11 }
}

Authentication

Authenticated endpoints accept either Authorization: Bearer <key> (OpenAI-style) or x-api-key: <key> (Anthropic SDK style); Authorization wins when both are present. Keys are prefixed with ca_sk_live_ — create separate keys per environment (dev / staging / prod) from the console.

i
Tip: Set your key in an environment variable (e.g. CANAL_KEY). Any OpenAI-compatible SDK just needs its base URL pointed at https://api.canalapi.com/v1 — no other code change required.

Chat completionsPOST/v1/chat/completions

Create a chat completion. Compatible with OpenAI's chat/completions — same parameters, same response shape, with automatic upstream-channel selection.

Request body

FieldTypeDescription
modelrequiredstringModel slug. Call /v1/models for the live list, or browse the pricing page.
messagesrequiredarrayConversation as an array of { role, content } objects. Roles: system, user, assistant.
streamoptionalbooleanIf true, tokens are streamed via SSE. Default false.
temperatureoptionalnumber0–2. Higher = more random. Default is model-dependent.
max_tokensoptionalintegerCap on completion tokens. Model-dependent default.
toolsoptionalarrayFunction-calling tool definitions. Request schema follows OpenAI / Anthropic native shapes.

Streaming example

Python · SSE
stream = client.chat.completions.create(
  model="claude-4-sonnet",
  messages=[{"role": "user", "content": "Write a haiku."}],
  stream=True,
)
for chunk in stream:
  print(chunk.choices[0].delta.content or "", end="")

Endpoints at a glance

All endpoints share the same key and auth scheme. The table below lists the OpenAI-compatible and vendor-native endpoints currently live:

MethodPathPurpose
POST/v1/embeddingsText embeddings (OpenAI Embeddings compatible)
POST/v1/images/generationsImage generation (DALL·E compatible; /edits and /variations also live)
POST/v1/audio/transcriptionsSpeech-to-text (Whisper compatible; /audio/translations also live)
POST/v1/audio/speechText-to-speech (TTS)
POST/v1/moderationsContent moderation (typically free)
POST/v1/responsesOpenAI Responses API compatible endpoint
POST/v1/messagesAnthropic Messages API — native endpoint for the Claude SDK; the count_tokens sub-route is free
GET/v1/modelsList available models (public, no auth required)
GET/v1/dashboard/billing/credit_grantsOpenAI-compatible account balance summary

Request parameters and vendor-specific fields follow the upstream API spec; CanalAPI forwards all standard fields.

Errors & retries

CanalAPI uses conventional HTTP status codes; errors follow the OpenAI shape { error: { message, type, code } }. On 5xx upstream failures we auto-retry across healthy channels — you only see an error after the routing pool is exhausted.

CodeMeaningWhat to do
400bad_requestCheck request body — likely a bad model or malformed messages.
401unauthenticatedMissing, invalid, or revoked key. Create a new one in the console.
402insufficient_balanceInsufficient balance — top up and retry.
429rate_limitedRate limit exceeded. Back off using the Retry-After and X-RateLimit-* headers.
502/503upstream_errorAll upstreams unavailable and already retried. Open a support ticket if it persists.
Auto-retry: CanalAPI automatically retries 5xx upstream failures across healthy channels in the routing pool. Clients only need standard exponential backoff for 429 / 502 / 503.

SDK integration

CanalAPI ships no proprietary SDK — it's a drop-in replacement for the major vendor SDKs. Swap the base URL and your existing code keeps working.

OpenAI Official SDK
Use for /v1/chat/completions, /v1/embeddings, /v1/images/*, /v1/audio/*, /v1/moderations, /v1/responses. Just set base_url to https://api.canalapi.com/v1.
pip install openai • npm i openai
Anthropic Official SDK
Use for the native /v1/messages endpoint. Set base_url to https://api.canalapi.com and pass your CanalAPI key via x-api-key.
pip install anthropic • npm i @anthropic-ai/sdk
Ready to build?
Grab your first API key and make a request in under 2 minutes.
Get API key
IntroductionChat completions