Service endpoints

Service URL: https://api.fourhz.ai

Method / ProtocolPathContent-Type / FramesAuth
GET/v1/tokenqueryAuthorization: <API Key>
POST/auth/v1/ephemeral-tokensapplication/jsonAuthorization: <API Key>

ASR single-use token

curl -X GET 'https://api.fourhz.ai/v1/token?expires_in_seconds=60' \
  -H "Authorization: $FOURHZ_API_KEY"
{"token":"temporary-token"}

Run on your server with the raw key in Authorization, without Bearer. The token is single-use; mint another for every reconnect. expires_in_seconds: 1–600, default 60. Connection-ticket expiry is distinct from recording duration.

const params = new URLSearchParams({token, sample_rate:"16000", encoding:"pcm_s16le", speech_model:"fourhz-spectrum"});
const ws = new WebSocket("wss://api.fourhz.ai/v1/asr/realtime?" + params);

Portal exchange for this Playground

Sign in to Portal and POST /api/playground/ephemeral-token using your login session and API key ID, with resource asr.clean_stream. Pass access_token in the ASR WebSocket token query parameter.

Response fields

FieldTypeMeaning and availability
tokenstringSingle-use ASR ticket from GET /v1/token; pass as the token query parameter.
access_tokenstringTemporary ASR credential returned by the Playground token exchange.
resourcestringAuthorized resource; not interchangeable across resources.
token_typestringGeneric credential type; does not change raw-key endpoint authentication.
expires_inintegerGeneric credential TTL in seconds, used for connection authentication.
expires_atstringGeneric credential expiration in RFC3339.
scope / protocolstringResource scope and protocol returned by the server.
max_session_secondsinteger?WebSocket session duration limit, separate from the credential TTL.

Expiry, reconnects and credential boundaries

Do not interchange credentials across accounts, keys or resources. Mint a new ticket after connection failure or disconnection. A disconnect does not prove that audio was unprocessed or unbilled; do not automatically replay the full recording. Do not persist tokens or full credential-bearing URLs in logs or analytics.