Skip to content
Questa pagina non è ancora disponibile nella tua lingua, quindi viene mostrata in inglese.

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.

← Tutta la documentazione

Every 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.

FormatHeaderTypical client
Bearer tokenAuthorization: Bearer sk-sea-...OpenAI SDKs, cURL, most HTTP tools
API key headerx-api-key: sk-sea-...Anthropic SDK and Claude-compatible tools
Google key headerx-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
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

StatusCodeMeaning
401invalid_api_keyThe key is missing, malformed or revoked.
402insufficient_balanceYour balance is too low for this request. Top up in the console.
404task_not_foundThe task id does not belong to your account.

All errors use the OpenAI error shape:

json
{"error": {"message": "Invalid or missing API key.", "type": "authentication_error", "code": "invalid_api_key"}}

Checking your balance from code

cURL
curl https://api.apisea.ai/v1/user/balance -H "Authorization: Bearer $APISEA_API_KEY"
json
{"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.

Hai trovato un problema in questa documentazione? Scrivi a support@apisea.ai.