API Keys & IAM Rules
API keys are the primary method for authenticating with the LLM API. This guide covers creating API keys, managing them, and configuring IAM rules for fine-grained access control.
Overview
LLM API provides comprehensive API key management with the following features:
- Basic API Key Management: Create, list, update, and delete API keys
- Usage Limits: Set spending limits on individual API keys
- IAM Rules: Fine-grained access control for models, providers, and pricing
- Usage Tracking: Monitor API key usage and costs
- Status Management: Enable/disable keys without deletion
Creating API Keys
Via Dashboard
At this time, API keys can only be created via the dashboard.
- Navigate to your project in the LLM API dashboard
- Go to the API Keys section
- Click Create API Key
- Provide a description for your key
- Optionally set a usage limit
- Click Create
WARNING
API keys are shown in full only once during creation. Make sure to copy and store them securely.
Using API Keys
Once you have an API key, use it in the Authorization header of your requests:
curl -X POST "https://api.llmapi.ai/v1/chat/completions" \
-H "Authorization: Bearer llmapi_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'
API Key Management
Disabling/Enabling API Keys
You can disable an API key to stop it from being used, but the key is not deleted and can be re-enabled later.
Rotating API Keys
Rotate a key when it may have been exposed, or on a schedule. In the dashboard, open the key's menu and choose Rotate:
- Pick how long the current key keeps working: 1 hour, 24 hours, 7 days, 30 days, or stop it now.
- Copy the new key. It works immediately and is shown only once.
- Update your integrations before the grace period ends. After that, the old key stops working.
Rotation keeps the key's usage, limits, IAM rules and IP restrictions. Regenerate is the immediate variant: the old key stops working at once, and any IP restriction is removed.
If a key shows a Rotate by date, LLM API has scheduled its current secret to stop working then, for example after a security incident. Rotate it before that date to avoid interruptions. Organization API keys (for the Usage API) also support Rotate from their actions menu. Choose a grace period, save the replacement shown once, and update your integrations. The key keeps its existing scopes and expiry. Rotation never extends an earlier campaign deadline.
INFO
LLM API stores only a fingerprint of each key, never the key itself, so a lost key cannot be
recovered. Rotate it to get a new one.
Usage Limits
Usage is tracked per API key and shown on the API Keys page. It counts the LLM API credits the key spends. Requests served with your own provider keys (BYOK) are billed by that provider and do not count toward usage limits.
You can set a maximum usage limit for each API key, either once or resetting daily, weekly, or monthly. When the limit is reached, requests using that key return 429 with the code usage_limit_exceeded.
Project spend limits
A project can have its own spend limit, shared by every API key in the project. Use it to cap a team, an environment, or a client app without splitting the budget across keys: keys you add later are covered automatically.
Organization owners and admins set it in Projects → project settings → Spend limit. Choose an amount in USD and a period:
- Daily, Weekly, or Monthly: spend resets automatically at the end of each period. A period starts when you set the limit, so a monthly limit set on the 15th resets on the 15th of the next month.
- One-time: the limit never resets. Raise or remove it to continue.
Adding a limit or changing its period starts a new period with $0.00 spent. Changing only the amount keeps the current period's spend. Developers can see the limit and the current spend but cannot change it.
Project spend counts the same costs as key usage limits, summed over the project's credit-billed keys. Keys on a subscription plan neither count toward the project limit nor are blocked by it. Key limits and the project limit both apply, so a request is rejected when either is exhausted. Other projects in the organization are not affected.
When a project reaches its limit, requests from all of its keys return 429:
{
"error": {
"message": "Project spend limit reached. It resets at 2026-12-01T09:30:00Z.",
"type": "usage_limit_exceeded",
"code": "project_usage_limit_exceeded"
}
}
For a recurring limit, the Retry-After header gives the seconds until the reset. Organization owners and admins are notified in the app and by email when a project passes 80% of its limit and when it reaches the limit. You can change this in notification preferences.
Spend is counted as requests are billed, and in-flight requests reserve their estimated cost, so concurrent requests near the limit overshoot it by at most a small margin.
Model availability
Every request is checked against the settings below before it reaches a provider. They apply on /v1/chat/completions, /v1/responses, /v1/messages, /v1/messages/count_tokens and /v1/embeddings.
| Setting |
Who controls it |
Error code |
| The model is in the active model catalog. Models that were never listed, or have been retired, are not served |
LLM API |
model_not_found (HTTP 404) |
| The model is blocked for your organization |
LLM API support |
model_blocked (HTTP 403) |
| The model is on your partner's allowlist (partner client organizations only; an empty allowlist allows every model) |
Your partner |
org_model_not_allowed (HTTP 403) |
| The key's IAM rules |
Whoever manages the key |
model_access_denied (HTTP 403) |
A <provider>:<key name>/<model> model needs your own provider key of that name, in a project that uses your own provider keys |
Organization admins |
provider_key_required (HTTP 400) |
| The IAM rules of the app plan a key was issued under |
The app that issued the key |
model_access_denied (HTTP 403) |
| The model is in the key's subscription plan (subscription keys only) |
Your plan |
rejected_not_in_plan (HTTP 403) |
| The provider is not blocked on the Providers page, and is enabled for your organization if it needs approval |
Organization admins; LLM API support for approval |
provider_blocked (HTTP 403) |
| The model is offered in the region the request is served from, and that region is allowed for the key, project and organization |
LLM API; allowed request regions |
model_not_available_in_region (HTTP 404), region_not_allowed (HTTP 403) |
| An organization funded only by bonus credits uses providers that accept bonus credits |
LLM API |
bonus_credits_not_applicable (HTTP 402) |
Exceptions:
/v1/embeddings reports a blocked provider as HTTP 403 EMBEDDING_MODEL_FORBIDDEN, and a catalog model that is not an embedding model as HTTP 400 EMBEDDING_UNKNOWN_MODEL.
/v1/messages/count_tokens checks provider rules and provider blocks only when the model carries a provider prefix, such as anthropic/claude-sonnet-4-5.
/v1/rerank checks the catalog, model blocks, the partner allowlist, IAM rules and provider blocks. It reports an unknown model as HTTP 400 validation_error and does not accept <provider>:<key name>/<model> models.
/v1/multimodalembeddings applies the same checks as /v1/rerank, with the same unknown-model error and no <provider>:<key name>/<model> models.
/v1/batches checks the catalog, model blocks, the partner allowlist and IAM rules when the batch is created, and does not accept <provider>:<key name>/<model> models.
- On
/v1/chat/completions, a fallback policy hop whose provider no longer serves its model is skipped.
The gateway caches IAM rules and partner allowlists for up to 30 seconds, so a change can take that long to apply.
IAM Rules
IAM (Identity Access Management) rules provide fine-grained access control over what models, providers, and pricing tiers an API key can access.
Rule Types
Model Access Rules
Control access to specific models:
- Allow Models: Only allow access to specific models
- Deny Models: Block access to specific models
Provider Access Rules
Control access to specific providers:
- Allow Providers: Only allow access to specific providers
- Deny Providers: Block access to specific providers
Pricing Rules
Control access based on model pricing:
- Allow Pricing: Set constraints on what pricing tiers are allowed
- Deny Pricing: Block specific pricing tiers
- Free vs Paid: Allow or deny access to free vs paid models
Error Handling
When a request breaks an IAM rule, the gateway answers HTTP 403 with code model_access_denied in the endpoint's own error format. The message names the rule that refused the request. On /v1/chat/completions:
{
"error": {
"message": "Model claude-opus-4-8 is not in the allowed models list … (Rule ID: …)",
"type": "access_denied_error",
"param": "model",
"code": "model_access_denied"
}
}
On /v1/messages the same denial uses the Anthropic format:
{
"type": "error",
"error": {
"type": "permission_error",
"message": "… Model claude-opus-4-8 is not in the allowed models list … (Rule ID: …)",
"code": "model_access_denied"
}
}
Common error scenarios:
- Model not allowed by IAM rules (
model_access_denied)
- Provider not allowed by IAM rules (
model_access_denied; a block on the Providers page is provider_blocked)
- Pricing limits exceeded
- API key disabled or deleted
- Usage limit reached (API key or project)
Migration from Legacy Keys
If you have existing API keys without IAM rules:
- Backward Compatibility: Existing keys continue to work without restrictions
- Gradual Migration: Add IAM rules incrementally
- Testing: Test IAM rules in development before applying to production
- Monitoring: Monitor for access denied errors after implementing rules
INFO
API keys without IAM rules have unrestricted access to all models and providers.