Skip to main content

API Keys

API keys are used to authenticate requests to the OpenGateLLM API. Each user can have multiple API keys for different purposes.

Master Key

The master key is a special administrative API key defined in your configuration file, used to encrypt user API keys. For details on configuring the master key, see Master Key Configuration.

API key properties

  • name: Descriptive name for the API key (required)
  • user: User ID to create the API key for (required, must have ADMIN permission)
  • expires: Unix timestamp when the API key expires (optional)
warning

The API key is only shown once when created. Make sure to save it securely. You will not be able to retrieve the full key value again.

Managing API keys

curl -X POST http://localhost:8000/v1/admin/tokens \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{
"name": "Development API Key",
"user": 1,
"expires": 1735689600
}'

API key format

API keys in OpenGateLLM follow the format: sk-<encoded_token>

The token is a JWT (JSON Web Token) that contains:

  • user_id: The ID of the user who owns the key
  • token_id: The unique identifier for this specific API key
  • expires: The expiration timestamp (if set)