Authentication & Virtual Keys

Routic uses API Keys for authentication, following the same format and usage as OpenAI.

How authentication works

Include your API Key in the Authorization header on every request:

Authorization: Bearer sk-xxxxxxxx

Never put your API Key in URL parameters. All requests must use HTTPS.

Get an API Key

  1. Log in to the Routic dashboard
  2. Go to the "API Keys" page
  3. Click "Create new key"
  4. Copy the key and store it securely

The key is only shown once after creation. If you lose it, you'll need to revoke the old key and create a new one.

API Key format

  • Prefix: sk-
  • Length: 48 characters
  • Example: sk-a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6

Routic keys use the sk- prefix, different from OpenAI's sk-proj-. The two are not interchangeable — a Routic key only works with the Routic Base URL:

# ✅ Correct — specify both base_url and api_key
client = OpenAI(
    base_url="https://api.routic.ai/v1",
    api_key="sk-xxxxxxxx",   # Routic key
)

# ❌ Wrong — key without base_url → request goes to OpenAI
client = OpenAI(api_key="sk-xxxxxxxx")

# ❌ Wrong — OpenAI key with Routic base URL
client = OpenAI(
    base_url="https://api.routic.ai/v1",
    api_key="sk-proj-xxxxxxxx",  # This is an OpenAI key
)

Key security

⚠️ Never do this

  • Commit API Keys to Git (including .env files)
  • Hard-code API Keys in frontend code (React, Vue, etc.)
  • Embed API Keys in client-side applications
  • Share API Keys in public issues, forums, or chats

✅ Recommended practices

  • Store keys in environment variables: export ROUTIC_API_KEY="sk-xxxxxxxx"
  • Use .env files and ensure .gitignore includes .env
  • Proxy through your backend — the frontend calls your server, which calls Routic
  • Use separate keys for different environments (dev/staging/production)

If your key is leaked

  1. Revoke the leaked key immediately in your dashboard
  2. Create a new key
  3. Update all services that used the old key
  4. Check usage logs for any unauthorized calls

Key management

ActionDescription
CreateEach user can create multiple keys for different use cases
RevokeTakes effect immediately. In-flight requests are unaffected; new requests are rejected
NameGive keys meaningful names (e.g., prod-backend, dev-testing)

All keys under the same account share the account balance.

Multi-key strategies

ScenarioStrategy
Frontend + backendBackend uses one key; frontend never calls the API directly
Multiple servicesOne key per service — easier to track usage
Dev vs productionUse a separate account for dev to avoid accidental impact on production
Rate limitingWhen one key hits its limit, rotate to another (each key has independent limits)

Authentication errors

Error codeHTTP statusMeaningSolution
invalid_api_key401Key is malformed or doesn't existCheck that the key was copied completely
expired_api_key401Key has expired or been revokedCreate a new key in the dashboard
missing_api_key401No Authorization header providedAdd Authorization: Bearer sk-xxx

See also