Authentication

All API requests require a valid API key in the Authorization header.

API Key Format

Keys always start with the prefix sk_

sk_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6

Authorization Header

Authorization: Bearer sk_your_api_key

Validity

API keys have a limited validity period. When creating, you can choose between 7, 30, 90 (default), 365 days or unlimited validity.

Expired keys are rejected with 401 Unauthorized. In this case, create a new key in the dashboard.

Restricted keys

A key can be restricted in the dashboard to individual services, and for Donna to individual models. A call outside the selection answers 403 with code key_scope_denied; the message names the allowed services.

A monthly budget in credits caps the key's spend per calendar month (UTC). Once reached, the API answers 402 with code key_budget_exhausted; the response carries the reset instant in the Retry-After header (seconds) and in error.resets_at. The account balance is unaffected. The check runs up front against an estimate, so the last request of a month may slightly exceed the budget.

A list of allowed IP addresses or ranges (CIDR) limits where the key may be used from. Requests from other addresses answer 403 with code key_ip_denied; the message names the address the request came from so it can be added.

Without restrictions

Without restrictions a key may do everything the account may. Changes take effect immediately.

Security Notice

API keys are secret. Never store them in client-side code or public repositories.