Authentication
How to authenticate APISea API requests with Bearer tokens, x-api-key and Gemini key headers, and how to manage, rotate and revoke keys.
← Semua dokumentasiEvery request to https://api.apisea.ai must include an APISea API key. Keys start with sk-sea- and are created in the console.
Supported header formats
APISea accepts the header style used by each major SDK, so you can keep using the client you already have.
| Format | Header | Typical client |
|---|---|---|
| Bearer token | Authorization: Bearer sk-sea-... | OpenAI SDKs, cURL, most HTTP tools |
| API key header | x-api-key: sk-sea-... | Anthropic SDK and Claude-compatible tools |
| Google key header | x-goog-api-key: sk-sea-... | Google GenAI SDK |
| Query parameter | ?key=sk-sea-... | Gemini REST examples (avoid in production) |
If more than one is present, the Authorization header wins.
curl https://api.apisea.ai/v1/chat/completions \
-H "Authorization: Bearer $APISEA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gemini-3.5-flash","messages":[{"role":"user","content":"ping"}]}'Key management
- One key per environment. Create separate keys for development, staging and production so you can rotate one without touching the others.
- Last used. The console shows when each key was last used, which helps you find stale or leaked keys.
- Revocation is immediate. A revoked key stops working on the next request. Revocation cannot be undone; create a new key instead.
- Keys are hashed. APISea stores only a SHA-256 hash of each key. If you lose a key, revoke it and create a new one.
Warning
Never embed API keys in front-end JavaScript, mobile apps or public repositories. Anyone with the key can spend your balance. Call APISea from your own backend instead.
Balance and authorization errors
| Status | Code | Meaning |
|---|---|---|
| 401 | invalid_api_key | The key is missing, malformed or revoked. |
| 402 | insufficient_balance | Your balance is too low for this request. Top up in the console. |
| 404 | task_not_found | The task id does not belong to your account. |
All errors use the OpenAI error shape:
{"error": {"message": "Invalid or missing API key.", "type": "authentication_error", "code": "invalid_api_key"}}Checking your balance from code
curl https://api.apisea.ai/v1/user/balance -H "Authorization: Bearer $APISEA_API_KEY"{"success": true, "remain_balance": 48.21, "remain_credits": 482.1, "used_balance": 1.79, "used_credits": 17.9}GET /v1/balance returns the same fields with used_balance scoped to the key that makes the call. See Account endpoints for usage and request-log queries.
Menemui masalah dalam dokumentasi ini? E-mel support@apisea.ai.