API Keys
All requests to ModelStack require authentication via an API key. Keys are passed in theAuthorization header using the Bearer token format.
Header Format
Key Format
ModelStack API keys follow this format:sk_ followed by a random alphanumeric string.
Getting an API Key
- Sign in to your dashboard
- Navigate to API Keys
- Click Create API Key
- Give your key a descriptive name
- Copy the key immediately — it won’t be shown again
Example Request
API Key Limits
The number of API keys you can create depends on your plan:| Plan | Max API Keys |
|---|---|
| Starter | 5 |
| Pro | 20 |
| Max | Unlimited |
Security Best Practices
Use environment variables
Use environment variables
Store your API key in environment variables rather than hardcoding it:
Use separate keys for different environments
Use separate keys for different environments
Create distinct API keys for development, staging, and production. This lets you revoke a compromised key without affecting other environments.
Rotate keys periodically
Rotate keys periodically
Rotate your API keys regularly. Create a new key, update your applications, then revoke the old key.
Never commit keys to source control
Never commit keys to source control
Add
.env files to .gitignore and use secret management tools for production deployments.Error Responses
If authentication fails, the API returns a401 Unauthorized error: