Skip to main content
POST
Mint a short-lived, one-time (single-use) ek-fish- ephemeral token from your backend so an untrusted client (browser, mobile app, or desktop app) can connect directly to Fish Audio inference endpoints without exposing your sk-fish- API key. For end-to-end browser WebSocket and fetch examples, see One-Time Ephemeral Tokens.

Authentication

Send a Scoped API key in Authorization: Bearer <sk-fish-...> that carries:
  1. tokens:mint, and
  2. Every scope listed in the requestโ€™s scopes array.
  • Classic API keys are rejected with 403 (code: "classic_key_cannot_mint").
  • One-time ek-fish- tokens cannot mint new tokens (403, code: "ephemeral_token_cannot_mint").
  • Responses include Cache-Control: no-store and Pragma: no-cache.

Constraints and rate limit

  • Rate limit: Each team can mint up to 600 ephemeral tokens per minute. Exceeding this limit returns 429 (code: "rate_limit_exceeded") with Retry-After: 60.
  • Single-use only: single_use defaults to true; passing false returns 400 (multi_use_not_supported).
  • Allowed scopes: tts:write, stt:write, voice_design:write, realtime:write, and agents:session (reserved for gateway-routed agent sessions; REST POST /v1/agent/sessions uses a sk-fish- key).
  • allowed_origins: Up to 20 exact http://host[:port] or https://host[:port] origins (no wildcards, credentials, paths, queries, fragments, or custom app schemes such as capacitor:// or tauri://; max 256 characters each). Omit for native mobile or desktop clients that do not send an Origin header.
  • max_session_duration_seconds: 60โ€“14400 (default 3600). Cannot extend an endpointโ€™s own maximum session cap (for example, 3,600 seconds on /v1/asr/realtime); whichever limit is lower fires first.

Errors

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
scopes
string[]
required

Requested ephemeral inference/session scopes. Must be a non-empty subset of both the parent API key's scopes and allowed ephemeral scopes (tts:write, stt:write, voice_design:write, realtime:write, agents:session).

Required array length: 1 - 16 elements
Required string length: 1 - 64
single_use
boolean
default:true

Whether the token is consumed atomically on its first connection. Phase 1 requires true.

ttl_seconds
integer
default:900

Time-to-live before the token must be redeemed, in seconds (30-900, default 900).

Required range: 30 <= x <= 900
max_session_duration_seconds
integer
default:3600

Maximum duration of a WebSocket session established with this token, in seconds (60-14400, default 3600).

Required range: 60 <= x <= 14400
allowed_origins
string[] | null

Optional list of allowed browser Origin values (e.g. https://app.example.com). When set, redemption requires a matching Origin.

Maximum array length: 20
Required string length: 1 - 256
end_user_id
string | null

Optional customer-supplied end-user identifier for audit and attribution.

Maximum string length: 128

Response

Document created, URL follows

token
string
required

Single-use ephemeral token plaintext (ek-fish-...). Returned once.

token_id
string
required

Stable non-secret identifier (etk_...).

expires_at
string<date-time>
required

UTC timestamp after which this token can no longer be redeemed.

expires_in
integer
required

Remaining lifetime in seconds at issuance.

scopes
string[]
required

Granted scopes for this ephemeral token.

single_use
boolean
required

Whether this token is single-use.

max_session_duration_seconds
integer
required

Maximum session duration in seconds once connected.