CanalAPI
User GuideDeveloper GuideExamples

Errors

Error model, status codes, and recommended handling.

CanalAPI returns errors in the same shape as OpenAI: a non-2xx HTTP status code plus a JSON body containing an error object.

{
  "error": {
    "message": "Invalid API key.",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

HTTP status codes

StatusMeaningTypical cause
400Bad RequestMalformed JSON, missing required fields, invalid parameters.
401UnauthorizedMissing, malformed, or revoked API key.
403ForbiddenValid key but model not allowed / IP not in allowlist / key disabled.
404Not FoundUnknown endpoint or model.
408Request TimeoutClient took too long to send the request.
409ConflictIdempotency or state conflict.
413Payload Too LargeRequest body or context exceeds limits.
422Unprocessable EntityValidation error on a structurally valid request.
429Too Many RequestsRate limit or quota exceeded.
500Internal Server ErrorUnexpected server-side error — safe to retry with backoff.
502 / 503 / 504Bad Gateway / Service Unavailable / Gateway TimeoutUpstream provider problem — retry with backoff.

Error fields

  • error.message — human-readable description (do not string-match on it in production code).
  • error.type — broad category, e.g. invalid_request_error, rate_limit_error, api_error.
  • error.code — machine-readable code; branch on this.

code can be either an OpenAI-style string (invalid_api_key, rate_limit_exceeded, …) or a numeric platform error code.

Platform error-code ranges

When the error originates from the CanalAPI platform (rather than the upstream model), code is numbered into ranges so you can quickly identify the failing domain:

RangeNumbersDomain
1xxx1000 – 1099Auth / account / API key / quota (e.g. key revoked, account disabled, quota exhausted)
2xxx2100 – 2199Gateway / channel / adapter (e.g. model not found, upstream unreachable)
3xxx3000 – 3099Billing / balance / pricing (e.g. insufficient balance, missing price)
4xxx4000 – 4099Top-up / payment orders (e.g. order timeout, webhook validation failed)
5xxx5000 – 5099Log query / export
6xxx6000 – 6099Invoice generation / billing profile
7xxx7000 – 7099Referrals / withdrawals
8xxx8000 – 8099Notifications / announcements
11xxx11500 – 11599Subscription plans / orders

On the API call path you'll typically see 1xxx, 2xxx, and 3xxx; 4xxx and above mostly appear during console flows (top-up, invoice, withdrawal, subscription).

Retryable vs non-retryable

  • Retryable: 408, 429, 500, 502, 503, 504. 409 depends on the situation.
  • Do not retry without changing the request: 400, 401, 403, 404, 413, 422.

Use exponential backoff with jitter (for example: 1s, 2s, 4s, 8s, max ~30s, plus ±25% jitter). Cap the number of retries (typically 5). When 429 returns a Retry-After header, respect it — see Rate Limits.

Reporting

When opening a support ticket, include:

  • The request ID (from response headers and visible in Usage Logs)
  • A rough timestamp (UTC or local timezone)
  • The model and endpoint used

This drastically shortens diagnosis. CanalAPI never includes your prompt / completion content in tickets.

On this page