跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.metask.ai/llms.txt

Use this file to discover all available pages before exploring further.

Every request to the 元任务 AI 网关 API must be authenticated. The gateway uses Bearer token authentication: you pass your API key in the Authorization header of each request. There are no cookies, sessions, or other authentication mechanisms — just your key in the header.

How to authenticate

Set the Authorization header to Bearer YOUR_API_KEY on every request:
Authorization: Bearer YOUR_API_KEY
To get an API key, log in to your dashboard and open the Settings → API Keys section. You can create multiple keys and revoke them individually.

Examples

curl https://napi.origintask.cn/v1/chat/completions \
  --request POST \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'

Authentication failures

When a request fails authentication, the API returns a 401 Unauthorized response. This happens when:
  • The Authorization header is missing entirely.
  • The token format is incorrect (for example, missing the Bearer prefix).
  • The API key has been revoked or does not exist.
Example 401 response:
{
  "error": {
    "message": "Incorrect API key provided. You can find your API key at https://napi.origintask.cn/account/api-keys.",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
A 403 Forbidden response indicates your key is valid but the request was blocked — most commonly because your account balance is zero. Top up your balance from the dashboard to resume making requests.

Security best practices

  • Store your API key in an environment variable, not hardcoded in source code.
  • Do not expose your key in client-side JavaScript or public repositories.
  • Rotate keys periodically from the Settings → API Keys section in your dashboard.
  • Create separate keys for different applications so you can revoke one without affecting others.