Skip to main content
POST
  • Create a new API token via API
  • Customize token name and expiration time
  • Configure quota limits and model restrictions
  • Token key is only returned once upon creation
Security NoticePlease securely store the returned token key (key field). It is only displayed once upon creation and cannot be retrieved later.

Authorizations

string
required
All endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:

Body

string
required
Token name, maximum 50 charactersExample: "My New Token"
integer
default:"-1"
Token expiration time (Unix timestamp in seconds)
  • Set to -1 for never expires
  • Set to a specific timestamp to expire at that time
Example: 1738483200 (2025-02-02 00:00:00 UTC)
integer
default:"0"
Token remaining quota (internal units)Conversion: 500000 = $1 USDExample: 500000 (equivalent to $1)
float
default:"0"
Token remaining credits. If provided, it overrides remain_quotaConversion: 200 credits = $1 USD = 500000 internal quotaExample: 200 (equivalent to $1)
float
default:"0"
Daily token limit in credits. If provided, it is converted to daily_quotaExample: 100 (equivalent to $0.5 daily limit)
float
default:"0"
Monthly token limit in credits. If provided, it is converted to monthly_quotaExample: 1000 (equivalent to $5 monthly limit)
boolean
default:"false"
Whether the token has unlimited quota
  • true: Unlimited quota, no restrictions
  • false: Limited quota, uses remain_quota value
Example: false
boolean
default:"false"
Whether to enable model restrictions
  • true: Enable model restrictions, only models in model_limits can be used
  • false: No model restrictions
Example: false
string
default:""
List of allowed models (comma-separated)Only effective when model_limits_enabled is trueExample: "gpt-4o,gpt-4o-mini,claude-3-5-sonnet"
string
default:""
Token group nameUsed to specify the channel group for this tokenExample: "default"

Response

boolean
Whether the request was successful
string
Error message (only returned on failure)
object
Created token information (returned on success)

Use Cases

  • Automate creation of multiple API tokens
  • Create separate tokens for different applications or services
  • Batch manage token lifecycle through scripts
Token Key FormatThe key field returned upon success is a 48-character random string. When using, add the sk- prefix for the complete format: sk-xxxxxxxx...
Best Practices
  • Create different tokens for different purposes for easier tracking and management
  • Set reasonable expiration times and rotate tokens regularly
  • Enable model limits if you only need access to specific models for enhanced security

Common Errors

Security Notice
  • The created token key is only returned once in the response, save it immediately
  • Do not hardcode API Keys in client-side code
  • Always use HTTPS in production
  • Create separate tokens for each application for easier management and revocation