跳转到主要内容

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 元任务 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 the Authorization header and the gateway validates it before routing your request.

Get your API key

API keys are created and managed from the dashboard.
  1. Log in to napi.origintask.cn.
  2. Open Settings → API Keys.
  3. Click Create API key.
  4. Enter a descriptive name (for example, production-app or local-dev).
  5. Copy the key immediately — the full value is only shown once.
You can create multiple keys for different environments or applications and revoke any of them individually from the same page.

Authenticate your requests

Pass your API key as a Bearer token in the Authorization header of every request.
Authorization: Bearer YOUR_API_KEY

Examples

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

Error responses

If the gateway cannot authenticate your request, it returns one of these HTTP error codes:
StatusErrorCause
401 UnauthorizedMissing or malformed Authorization headerThe request did not include a Bearer token, or the header was formatted incorrectly.
401 UnauthorizedInvalid API keyThe key does not exist or has been revoked.
403 ForbiddenInsufficient permissionsThe key exists but does not have access to the requested resource or model.
Check the response body for a JSON error object with a message field that explains the specific problem.

Security tips

Your API key grants full access to your gateway account, including spending your balance. Treat it like a password.
  • 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:
    export METASK_API_KEY="YOUR_API_KEY"
    
    Then reference the variable in your code:
    import os
    from openai import OpenAI
    
    client = OpenAI(
        api_key=os.environ["METASK_API_KEY"],
        base_url="https://napi.origintask.cn/v1",
    )
    

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.