Skip to navigation

Authentication

View as Markdown

OpenModels authenticates API requests with an OpenModels API key in the Authorization header. API keys use the ale-... format.

API key format

ale-your-api-key

Keys are shown once when created. Store them in a secrets manager or environment variable before leaving the creation screen.

Authorization header

Send the key as a Bearer token:

curl https://api.getopenmodels.com/v1/chat/completions \
-H "Authorization: Bearer $OM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5-flash",
"route": { "provider": "<provider-for-this-model>" },
"route_mode": "balanced",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'

Environment variables

Use an environment variable for local development:

export OM_API_KEY="ale-your-api-key"

Then pass it to an OpenAI-compatible SDK:

import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.getopenmodels.com/v1",
api_key=os.environ["OM_API_KEY"],
)

Key management

Use separate keys for development, staging, and production. This makes it easier to rotate a key without disrupting every environment.

Recommended practices:

  • Store keys in a secrets manager.
  • Do not commit keys to source control.
  • Rotate a key immediately if it may have leaked.
  • Revoke unused keys.
  • Use monthly spend limits to cap the maximum spend for each key.
  • Use separate keys for different applications or workloads when you need cleaner usage tracking.

Common authentication errors

StatusCodeMeaning
401invalid_api_keyThe key is missing, malformed, invalid, revoked, or no longer active
401key_market_key_invalidThe OpenModels key is invalid when returned by a Key Market-specific error path

If a request fails with 401, check that the Authorization header uses the exact Bearer <key> format and that the key still exists in the OpenModels dashboard.

If authentication succeeds but a request is blocked by credits or spend limits, see Credits & Billing, Rate Limits, and Errors.