Skip to main content

API keys

Every request sends an API key in the Authorization header:
GET /models is the only endpoint that works without an API key.
  • Create API keys in the console. An API key starts with cz_. Give each key a name, such as the app or environment that uses it; an account can have up to 10 API keys.
  • The full key is shown only once, when you create it. Codzen stores only a hash, so a lost key cannot be shown again: create a new one and revoke the old one.
  • Revoking a key in the console removes it for good. Requests with a revoked key fail with 401 invalid_api_key.
  • API keys do not expire, and every key can call every endpoint for its account.
Use API keys only on your server. The API does not allow cross-origin (CORS) requests from browsers, and a key shipped in a web page or mobile app can be copied and spent by anyone. Call Codzen from your backend, and keep the key in an environment variable or secret store, never in source control.

Authentication errors

Generations submitted before a suspension still finish, are charged and send their webhooks. See Errors for the error format.

Rate limits

  • Every request with an API key counts toward its rate limit, including GET requests that poll a generation.
  • The concurrency limit is per account, across all of its API keys. A generation stops counting once it succeeds or fails.
  • The API does not queue for you. A request over a limit fails right away with 429 and a Retry-After header: the number of seconds to wait before trying again.
  • Responses carry no X-RateLimit-* headers. Rely on 429 and Retry-After.
A simple strategy: on 429, wait for Retry-After seconds, then send the same request again. To stay under the concurrency limit, keep your own queue of pending work and submit a new generation when one finishes.
If your workload needs higher limits, contact Codzen.

Request IDs

Every response carries an x-request-id header, and every error body repeats it as request_id. Quote it when you contact support about a request.