message and a status:
transcribe-1-pro speech-to-text errors also include code and request_id; see Speech to Text errors. Errors returned by the network edge in front of the API, such as some 413 or 5xx responses, may not be JSON.
Status codes
Retries
Retry429 and 5xx with exponential backoff. Don’t retry other 4xx codes; they won’t succeed without a change to the request. The JavaScript SDK retries by itself: 429 and 5xx responses, and also 408, twice by default (see Request options). The Python SDK does not retry, so add a loop like this one:
Install the Python SDK first: pip install fish-audio-sdk.
Handling errors in the SDKs
The Python SDK raises a typed exception for401, 403, 404, 429, and 5xx, and APIError for every other HTTP error. The JavaScript SDK throws UnprocessableEntityError for 422 and a plain FishAudioError for every other HTTP error, so branch on err.statusCode. Both carry the status and the response body: in Python, e.body is the raw text; in JavaScript, err.body is the parsed JSON when the response is JSON; for any other response it may not be an object, so check it before you read fields.
Audio playback via
play() needs ffmpeg. If it’s missing, the Python SDK raises
DependencyError. Install ffmpeg or save the audio to a file instead.
