Skip to main content

API Keys

All AI Sonar API requests require an API key. For OpenAI-compatible endpoints, send it as:
For Anthropic-compatible /v1/messages requests, you can also use:

Getting Your API Key

  1. Log in to your AI Sonar Dashboard
  2. Open API Keys
  3. Create a new key
  4. Give it a descriptive name
  5. Copy it immediately because it is shown only once
  • Never expose API keys in client-side code
  • Never commit API keys to version control
  • Use environment variables or a secret manager
  • Rotate keys periodically
  • Delete unused keys

Using API Keys

API Key Features

Usage Limits

You can set a usage limit on each API key:

Key Prefix

All AI Sonar API keys start with sk-.

Anthropic Compatibility

For the /v1/messages endpoint, the Anthropic-style header works as expected:
Use Authorization: Bearer ... for OpenAI-compatible endpoints such as /v1/responses, /v1/chat/completions, /v1/models, and most other AI Sonar routes.

Error Responses

Example: