CanalAPI
Developer Guide

Authentication

How to authenticate requests to CanalAPI.

Protected inference requests use API-key authentication. One key can be used with supported OpenAI, Anthropic, and Gemini endpoints, subject to key restrictions and model capabilities. Public GET /v1/models does not validate the key.

Where to get a key

See API Keys for the console workflow. Copy the complete key shown in the dashboard, preserving its prefix and all characters. Do not replace its prefix with an example placeholder.

How to send the key

Works for every endpoint:

POST /v1/chat/completions HTTP/1.1
Host: api.canalapi.com
Authorization: Bearer YOUR_CANALAPI_KEY
Content-Type: application/json

Any client that accepts a custom baseURL + apiKey works the same way:

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.CANALAPI_API_KEY,
  baseURL: 'https://api.canalapi.com/v1',
});

2. x-api-key (Anthropic clients)

If your codebase already uses the Anthropic SDK:

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.CANALAPI_API_KEY,
  baseURL: 'https://api.canalapi.com',
});

The server accepts both Authorization: Bearer and x-api-key; no further changes are needed.

3. Gemini — x-goog-api-key / Authorization: Bearer

Native Gemini uses https://api.canalapi.com/v1beta. Send your CanalAPI key in the Authorization: Bearer or x-goog-api-key header. The ?key= query parameter is not supported.

GET /v1beta/models
x-goog-api-key: YOUR_CANALAPI_KEY

Per-key access controls

Keys may be subject to the controls below. The current creation dialog exposes spending limits and expiration; configure other access restrictions only through available controls or confirmed support guidance:

  • Quota cap — total USD a key may spend (independent of the account balance)
  • Allowed models — model allowlist; calls to other models return 403
  • IP allowlist — restrict callers by IP / CIDR
  • Expiration — auto-invalidate after a date

See API Keys for the full set; rate-limit behaviour is in Rate Limits.

Failure modes

StatusCause
401 UnauthorizedMissing, invalid, expired, or disabled key, or disallowed source IP
402 Payment RequiredInsufficient available account balance; inspect the error body
403 ForbiddenModel/scope permission denied or key spending cap exhausted
429 Too Many RequestsRequest throughput or upstream capacity limit, not a spending-cap error

Full error model: Errors.

Console login vs. API key

Console sign-in and API requests use two independent credentials:

  • The console at https://www.canalapi.com uses email + password, with optional 2FA and active-session management — see Security.
  • The API is authenticated by API key only; no cookies / sessions.

Revoking a key does not sign you out of the console. Changing the password does not invalidate existing keys.

Operational notes

  • Never commit a key to source control or paste it into screenshots / tickets.
  • Never embed a key in browser JavaScript or a mobile app. Use a server-side proxy.
  • Inject keys via Secrets / environment variables in CI and production.
  • Rotate keys when team members leave or when you suspect leakage.
  • Use separate keys per environment (dev / staging / prod) for surgical revocation and clean billing attribution.

On this page