Skip to main content

Error Handling

All errors extend KugelAudioError: Every error carries statusCode, errorCode (compare with the exported ErrorCodes map; it can be undefined, for example on network failures), requestId (quote it to support), and retryAfter (seconds) when known. The package also exports WsCloseCodes for matching WebSocket close codes. When the SDK can replay a turn transparently after a rolling deploy, it calls the onServerRestart callback instead of failing; see the callback interfaces below.

KugelAudioOptions

GenerateOptions

Using normalize: true without language may cause incorrect normalizations. Always specify language when you know it.

AudioChunk

WordTimestamp

AudioResponse

Unlike the Python SDK, AudioResponse has no usage. Per-request usage is available from stream() as GenerationStats.usage.

GenerationStats

SessionUsage

Per-conversation usage for billing your own customers. Available on StreamingSession.lastUsage (per session), MultiContextSession.usageFor(...) and the onContextClosed callback (per context), and GenerationStats.usage (per one-shot stream() request).
costCents is null (and costAvailable is false) when the charge cannot be determined at session end (for example a transient billing error or an internal session). It is never a misleading 0. audioSeconds is always reported.

StreamCallbacks

Used with the one-shot client.tts.stream() endpoint:

StreamConfig

Configuration for client.tts.streamingSession() (LLM integration endpoint):

StreamingSessionCallbacks

Model

VoiceListResponse

Paginated response from voices.list():

Voice

The listing does not send sampleText, isPublic, or verified, so they always hold their defaults on Voice.
VoiceCategory and VoiceAge are legacy SDK declarations, not the API’s current write-value set. The API can return newer category strings and uses middle_age (not the declared middle_aged); the JavaScript mapper does not transform those values, so runtime data can fall outside these unions. Use the Voice API reference for accepted create/update values.

VoiceDetail

Extended voice information returned by create, update, get, and publish. get receives the listing shape, so generativeVoiceDescription, isPublic, verified, pendingVerification, and sampleText hold defaults there; create, update, and publish populate them.

VoiceReference

CreateVoiceOptions

UpdateVoiceOptions

The SDK serializes isPublic from UpdateVoiceOptions, but the current API ignores that field on voice updates. Use voices.publish() to make a voice public. The API’s generative_voice_description write field is not exposed by CreateVoiceOptions or UpdateVoiceOptions.

TranscriptionResponse

Returned by client.asr.transcribe(). Its fields keep the server’s snake_case names:
Dictionary types live on the Dictionaries page; multi-context types live on the Streaming page.

Next steps

  • Quickstart: install and first generation
  • Streaming: where StreamConfig and SessionUsage are used
Last modified on September 23, 2026