Every request to 元任务 AI 网关 must include a valid API key. The gateway uses standard Bearer token authentication — the same scheme used by the OpenAI API — so any client or library that already supports OpenAI works without modification. You attach your key to theDocumentation Index
Fetch the complete documentation index at: https://docs.metask.ai/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header and the gateway validates it before routing your request.
Get your API key
API keys are created and managed from the dashboard.- Log in to napi.origintask.cn.
- Open Settings → API Keys.
- Click Create API key.
- Enter a descriptive name (for example,
production-apporlocal-dev). - Copy the key immediately — the full value is only shown once.
Authenticate your requests
Pass your API key as a Bearer token in theAuthorization header of every request.
Examples
Error responses
If the gateway cannot authenticate your request, it returns one of these HTTP error codes:| Status | Error | Cause |
|---|---|---|
401 Unauthorized | Missing or malformed Authorization header | The request did not include a Bearer token, or the header was formatted incorrectly. |
401 Unauthorized | Invalid API key | The key does not exist or has been revoked. |
403 Forbidden | Insufficient permissions | The key exists but does not have access to the requested resource or model. |
error object with a message field that explains the specific problem.
Security tips
- Never commit keys to source control. Use environment variables or a secrets manager instead.
- Use one key per environment. Create separate keys for development, staging, and production so you can revoke them independently.
- Rotate keys if compromised. Go to Settings → API Keys, delete the exposed key, and create a new one. Update your application with the new key before deleting the old one.
-
Set keys as environment variables to avoid hardcoding them:
Then reference the variable in your code:
Two-factor authentication
You can enable TOTP-based two-factor authentication (2FA) to protect your dashboard login. 2FA applies to dashboard access only — API key authentication is not affected. To enable it, go to Settings → Security in your dashboard and follow the setup instructions for your authenticator app.Enabling 2FA is strongly recommended if your account has a significant balance or multiple API keys attached to production services.