Skip to main content
Fish Audio supports two API key types — Scoped and Classic — along with per-key USD spend limits and a self-introspection endpoint so you can enforce least-privilege access and cap usage per service or environment. Manage your keys on API Keys.

Classic vs. Scoped API keys

Use Scoped keys for production workloads and any backend that mints ephemeral tokens. Reserve Classic keys for quick prototyping or existing integrations that expect broad access.

API key scopes

Every scoped API key carries one or more flat resource:action scopes. Compatible API endpoints (such as /v1/audio/speech, /v1/audio/transcriptions, and /v1/chat/completions) require the scope of their underlying inference product (tts:write for speech/chat, stt:write for transcriptions).
For browser or mobile voice-agent clients, create a session on your backend with your sk-fish- key via POST /v1/agent/sessions (which issues its own short-lived client join token); see Authenticated Sessions.

Admin-only scopes and editing scopes

  • Only team owners and admins can create, edit, or delete a scoped key that grants billing:read or audit_log:read.
  • You can edit the scopes of an existing Scoped key at any time from API Keys. Changes take effect immediately for POST /v1/auth/tokens and ephemeral token redemption, and within 60 seconds on cached inference gateway routes.
  • A non-admin team member editing another member’s scoped key cannot widen its scope set.
  • Classic keys cannot be converted to scoped keys or assigned explicit scopes; create a new scoped key and rotate instead.

Per-key USD spend limits

You can set an optional USD spend cap when creating any Classic or Scoped key to bound costs per service, environment, or customer integration. Editing, removing, or resetting a spend cap on an existing key requires team owner or admin role:
  • Range: $0.01 to $1,000,000,000.00 (rounded to 2 decimal places).
  • Reset cadence (UTC, defaults to monthly when omitted):
    • daily — resets at 00:00 UTC every day
    • weekly — resets on Monday at 00:00 UTC
    • monthly — resets on the 1st of each month at 00:00 UTC
    • never — cumulative lifetime cap until raised or manually reset
  • Unified attribution: Usage from both direct sk-fish- requests and any ek-fish- ephemeral tokens minted by that key counts toward the parent key’s spend limit.
  • Manual reset: Team owners and admins can reset the current window’s spend counter to $0.00 at any time using Reset spend on API Keys.
When a key reaches its limit:
  • New HTTP requests and WebSocket upgrades return 402 Payment Required (api_key_spend_limit_exceeded).
  • Calling POST /v1/auth/tokens fails fast with 402 (code: "api_key_spend_limit_exceeded").
  • Active WebSocket inference sessions that cross the limit mid-stream are closed cleanly at a frame boundary with WebSocket close code 4002 (reason api_key_spend_limit_exceeded).
Streaming inference usage is settled in short batches, so actual spend can slightly exceed the configured cap by the in-flight request or settlement window.

Inspecting your key programmatically

Any valid Classic or Scoped key can inspect its own type, effective scopes, expiration, and live spend-limit balance by calling GET /apikey/self. No additional scope is required.

Handling scope and spend errors

Error responses differ depending on whether the check runs at the inference edge gateway or the platform API:

Inference edge gateway (/v1/tts, /v1/asr, /v1/asr/realtime, /v1/tts/live, /v1/voice-design)

Gateway errors keep the JSON body fixed to {"status": <int>, "message": <string>} for SDK compatibility and put machine-readable codes in response headers:

Platform API (/v1/auth/tokens, /model/*, /wallet/*, /v1/agent/*, /v1/pronunciation-dictionaries/*)

Platform API scope and spend errors return structured JSON fields (note that GET /v1/audit-logs returns {"status": 403, "message": "This endpoint requires an API key with the audit_log:read scope."} instead):
403 Missing scope
402 Spend limit exceeded (POST /v1/auth/tokens)

Next steps

Ephemeral Tokens

Mint single-use ek-fish- tokens for browsers, mobile, and desktop clients.

Get Current API Key

Monitor scopes and spend-limit remaining budget via GET /apikey/self.