Authentication
For model endpoints such as /v1/*, the most common authentication method is to include your API key in the request header:
text
Authorization: Bearer sk-your-api-keyYou can generate and manage your key on the API Tokens page.
When to use an API key
- Connecting clients, plugins, or AI apps.
- Writing scripts that call model APIs.
- Calling chat, completions, embeddings, images, audio, and other AI model endpoints.
Common errors
401 or authentication failure
Check these items first:
- Make sure the key was copied completely.
- Make sure you are using an API key created by the current account.
- Make sure the endpoint is correct. Model calls usually go through
/v1/.... - Make sure the request header includes
Authorization: Bearer sk-your-api-key.
