Skip to main content
This page covers authenticating API requests. For signing in to the dashboard itself, see Signing In. DeepInfra supports two authentication methods:
  1. API keys — long-lived tokens for your own use, limited to the scopes you give them
  2. Scoped JWTs — short-lived, scope-limited tokens you can issue to third parties

API keys

Get your API keys from the Dashboard. Use them in the Authorization header:

Scopes

Each API key has scopes that say what it may do, or is unrestricted. You choose them when you create the key and can change them at any time on the key’s page in the dashboard. A new key starts with inference, models:read, account:read, lora:read and voice:read: enough to run and look up models. Where an area has two scopes, the :read one only reads and the full one also creates, changes and deletes. The full one includes its :read scope, so a key never needs both. Speaking with a voice runs a model, so it needs inference as well as voice:read. Each endpoint’s page in the API Reference names the scope a key needs to call it. The interactive API explorer can also filter endpoints by scope. A request the key’s scopes do not allow is refused with 403 and names the missing scope:
Some actions are never open to an API key, whatever its scopes, unrestricted included: changing payment details, setting spending limits and topping up all need a dashboard login.

Unrestricted keys

A key can be unrestricted instead of scoped: it has every scope that is not sensitive, including whatever scopes DeepInfra adds later. Choose Unrestricted when you create the key or on its page in the dashboard, which then shows it as unrestricted. Through the API, set scopes to ["unrestricted"], on its own: combined with other scopes it is refused with 422.
Anyone holding an unrestricted key can do everything a non-sensitive scope allows on your account, now and as new scopes arrive. Prefer a key with only the scopes it needs.
Keys created before scopes existed are unrestricted. To limit one, choose Scoped on the key’s page and pick its scopes.

Sensitive scopes

A sensitive scope grants power over the account itself, so it is off by default. Today the only one is account_api_key.
  • It can be set on a key only once the account owner has enabled it. Until then the dashboard does not offer it, and setting it through the API is refused with 422 (scopes not enabled for this account: account_api_key).
  • unrestricted does not grant it. A key that needs it must be scoped and hold it by name.
  • An API key can never grant it: not to a key it creates, nor to a key it changes. A key created by another API key can never hold it, even when changed from the dashboard. Such requests are refused with 422:
The dashboard shows sensitive scopes in red. On an account with a sensitive scope enabled, it labels unrestricted keys “All non-sensitive”.
Enable account_api_key
Only the account owner can enable it, signed in to the dashboard. For a team, that is the team owner. No API key can enable it, whatever its scopes.
  1. Open Account → Danger zone.
  2. Tick Allow API keys to manage API keys and confirm.
  3. Confirm your password when asked. An account without a password (Google, GitHub or SSO sign-in) is asked to sign in again if its last sign-in was more than 10 minutes ago.
The scope is then offered when you create a key or change a key’s scopes, and POST /v1/api-tokens and PATCH /v1/api-tokens/id/{token_id} accept it in scopes. To turn it off, untick the box. The dashboard lists the keys that hold the scope: turning it off deletes them, and anything using them stops working.

Manage API keys with an API key

A key with account_api_key:read may list the account’s API keys (GET /v1/api-tokens) and read one key’s details (GET /v1/api-tokens/id/{token_id}). Neither ever returns a key’s secret. Every unrestricted key has this scope, and so does every key holding account_api_key. A key with account_api_key may also create keys (POST /v1/api-tokens), change their scopes (PATCH /v1/api-tokens/id/{token_id}) and delete them (DELETE /v1/api-tokens/id/{token_id}), for every key of the account. When an API key creates a key:
  • scopes is required. Any scopes that are not sensitive may be given, unrestricted included.
  • The new key has no IP allow-list, whatever the creating key’s.

Scoped JWT

Scoped JWT tokens let you grant limited inference access to third parties without sharing your API key. You can restrict the token by:
  • Models allowed — specific model(s) only
  • Expiration — time-limited (up to 1 year)
  • Spending limit — maximum USD spend
The JWT is signed by the API key you create it with, and usage is counted against that key. A scoped JWT can do no more than the key that signed it: it has that key’s scopes, as they are at the time of each request. Creating a JWT needs the account_scoped_jwt scope and inspecting one needs account_scoped_jwt:read. A JWT signed by a key without inference cannot run models.

Create a scoped JWT

Response:
This creates a token limited to deepseek-ai/DeepSeek-V4-Flash-0731, expiring in 1 hour, with a $1.00 spending limit. Optional fields (omit to remove restriction):
  • models — allow any model
  • expires_delta — no expiration (defaults to 1 year)
  • spending_limit — no spending limit
  • Use expires_at (unix timestamp) instead of expires_delta if preferred
api_key_name is deprecated. It used to choose the signing key. Omit it: a JWT is signed by the key that creates it, and naming a different key will be refused.

Inspect a JWT

Use a scoped JWT

Use it exactly like a regular API key in the Authorization header:
Requests using disallowed models, expired tokens, or over-budget tokens will be rejected.