Skip to content
Main Site News Console

Authentication and Keys

Authentication Methods

All APIs use Bearer Token authentication. Include your API token in the request header:

Authorization: Bearer sk-xxxxxxxxxxxxxxxx

Tokens are created and managed on the console Tokens (API Keys) page.

Token Capabilities

When creating a token, you can configure the following as needed:

Configuration ItemDescription
NameHelps distinguish usage purposes (e.g. prod-app, test)
Quota LimitThe maximum quota this token can consume; requests are rejected after it is exceeded
Expiration TimeAutomatically becomes invalid when it expires, suitable for temporary authorization
Model GroupRestricts the range of models this token can call
IP AllowlistRestricts the source IPs allowed to call it (optional)

One account can create multiple tokens. It is recommended to split them by environment/project to make usage statistics and revocation easier.

Security Recommendations

  • Keep secrets only in server-side environment variables or secret management services; do not put them in frontend code or public repositories;
  • Use different tokens for different projects so that only a single token needs to be revoked if it is leaked;
  • Set a smaller quota limit and expiration time for test tokens;
  • When abnormal usage is detected, disable the token in the console first, then investigate the source of the calls.

Common Authentication Errors

HTTP StatusMeaningHandling
401Missing or invalid keyCheck whether the Authorization header and key are complete
403Token disabled / the group does not have permission to access this modelCheck the token status and model group
429Rate limit triggered or quota insufficientSee Rate Limits and 429