diff --git a/.mintlify/skills/fish-audio-api/SKILL.md b/.mintlify/skills/fish-audio-api/SKILL.md index acfc4985..fbab66b0 100644 --- a/.mintlify/skills/fish-audio-api/SKILL.md +++ b/.mintlify/skills/fish-audio-api/SKILL.md @@ -20,7 +20,7 @@ This file condenses those into rules an agent can apply directly. - Optional distributed tracing for inference APIs: see `https://docs.fish.audio/api-reference/observability`. - Get API keys: `https://fish.audio/app/api-keys` - Never hardcode keys. Read from an env var like `FISH_API_KEY`. -- Errors are JSON with at least `{status, message}` (for example 401 / 402 / 404 / 429). Speech-to-text errors from `transcribe-1-pro` and `transcribe-2-pro` also carry `code` and `request_id`. Errors from the network edge in front of the API (some 413 and 5xx responses) may not be JSON. `422` validation errors, on the endpoints that return them, are an array of `{loc, type, msg, ctx, in}`. +- Errors are JSON with at least `{status, message}` (for example 401 / 402 / 404 / 429). Speech-to-text errors from `transcribe-1-pro` and `transcribe-2-pro` also carry `code` and `request_id`. Errors from the network edge in front of the API (some 413 and 5xx responses) may not be JSON. `422` validation errors from the endpoints in this skill add an `errors` array (up to 20 entries) of `{field, in, code, message}` to `status` and `message`. The Voice Agents API (`/v1/agent/*`) is different: its `422` body is a top-level array of `{type, loc, msg}` entries; see `https://docs.fish.audio/api-reference/agent-errors`. ## Endpoint map @@ -638,11 +638,8 @@ S2-Pro and the S2.1-Pro models use free-form `[bracket]` natural-language tags i - 401 → missing / bad `Authorization` header. - 402 → out of credit. Check `/wallet/self/api-credit`. - 404 → bad `model/{id}` (voice model doesn't exist or isn't visible to you). -- 422 → validation. The response is an array; each item's `loc` points at the offending field. Most common causes: - - `reference_id` is an array but model is `s1` (multi-speaker requires `s3-pro`, `s2-pro`, an S2.1-Pro model, or `drama-3`). - - `references` sent with `Content-Type: application/json` (must be msgpack). - - Numeric param out of range (`temperature`, `top_p`, `chunk_length`, `min_chunk_length`, `prosody.speed`, `early_stop_threshold`). - - `mp3_bitrate` / `opus_bitrate` set without matching `format`. +- 400 on `POST /v1/tts` → also invalid parameters; `message` names the problem. Seen: an unknown `format` or `latency`, a value out of range (`top_p`, `chunk_length`, `prosody.speed`, `mp3_bitrate`), `references` that are not valid audio (send them as msgpack), a `reference_id` that doesn't exist (`Reference not found`). +- 422 → field validation on other endpoints, for example `GET /model?page_size=0` or `POST /model` without `title`; the response's `errors` array lists up to 20 invalid fields, each with `field`, `in` (where it was sent, such as `query`, `body` or `header`), `code` and `message`; `message` summarizes the first one and counts the rest. - WebSocket: a `finish` event with `reason: "error"` means the server failed mid-stream. Surface the message and reconnect rather than retrying on the same socket. - `POST /v1/asr` (`transcribe-1-pro`, `transcribe-2-pro`): branch on the HTTP status and on `code`, never on `message`. New `code` values may be added; handle unknown codes by HTTP status. With `transcribe-1`, rely only on `status` and `message`. - 400 → fix the request; do not retry. Codes: `invalid_request` (unreadable body, missing or repeated `audio`), `invalid_parameter` (bad or conflicting field values), `invalid_audio` (undecodable or unsupported format), `audio_too_long` (over 60 minutes), `audio_too_short` (under about 0.08 s). diff --git a/.mintlify/skills/fish-audio-sdk/SKILL.md b/.mintlify/skills/fish-audio-sdk/SKILL.md index 6934c51c..b7da8136 100644 --- a/.mintlify/skills/fish-audio-sdk/SKILL.md +++ b/.mintlify/skills/fish-audio-sdk/SKILL.md @@ -18,7 +18,7 @@ If the user wants raw `curl` / HTTP / WebSocket without installing an SDK, use t - **Auth:** both SDKs read the API key from the `FISH_API_KEY` environment variable automatically. Get keys at `https://fish.audio/app/api-keys`. Never hardcode a key. - **Base URL:** `https://api.fish.audio` (override with `base_url=` in Python / `baseUrl:` in JS). -- **TTS models:** the API supports `s1` (deprecated), `s2-pro`, `s2.1-pro`, `drama-3`, `s3-pro` (recommended), and `s3-pro-free` (the same model at $0 under fair-use limits, for testing and prototyping). Pass `s3-pro` explicitly: the current SDK releases default to `s2.1-pro`. Do not choose `s1` for new code: S1 is deprecated and will be retired on December 31, 2026. After that date, requests that specify `s1` are served by `s3-pro` (migration: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1`). The Python SDK (`fish-audio-sdk` 1.4.0 and later) defaults to `s2.1-pro`; its `Model` type names `s1`, `s2-pro`, `s2.1-pro`, `s2.1-pro-free` and `drama-3` and accepts any other string, so no `# type: ignore` is needed (1.3.0 and earlier defaulted to `s2-pro` and typed only `s1` / `s2-pro`). The JS SDK (`fish-audio` 0.2.0) defaults to `"s2.1-pro"`, and its `Backends` type names `s2.1-pro`, `s2.1-pro-free`, `drama-3`, `s2-pro`, `s1` and accepts any other string, so no cast is needed. `fish-audio` 0.1.0 defaulted to the deprecated `"s1"`; if a project is on 0.1.0, upgrade it or pass the model explicitly. `speech-1.5` / `speech-1.6` are **deprecated**. In Python pass `model="s3-pro"` (keyword); in JS pass `"s3-pro"` as the **positional** `backend` argument. +- **TTS models:** the API supports `s1` (deprecated), `s2-pro`, `s2.1-pro`, `drama-3`, `s3-pro` (recommended), and `s3-pro-free` (the same model at $0 under fair-use limits, for testing and prototyping). Pass `s3-pro` explicitly: it is the default only in the current SDK releases (the `fishaudio` client in `fish-audio-sdk` 1.8.0+, `fish-audio` 0.4.0+; the legacy `fish_audio_sdk.Session` sends `speech-1.5`); older versions default to other models, some to `s1` (table: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1#default-model-by-sdk-version`). Do not choose `s1` for new code: S1 is deprecated and will be retired on December 31, 2026. After that date, requests that specify `s1` are served by `s3-pro` (migration: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1`). The Python SDK's `Model` type is the literals `s1`, `s2-pro`, `s2.1-pro`, `s2.1-pro-free`, `drama-3`, `s3-pro` and `s3-pro-free`; the TTS methods take `model: Model | str`, so passing any other string needs no `# type: ignore` (a variable annotated `Model` still only takes the listed literals). The JS SDK's `Backends` type names `s1`, `s2-pro`, `s2.1-pro`, `s2.1-pro-free`, `drama-3`, `s3-pro` and `s3-pro-free` and accepts any other string from `fish-audio` 0.4.0, so no cast is needed there; on 0.1.0 and earlier `"s3-pro"` needs `as Backends`. `speech-1.5` / `speech-1.6` are **deprecated**. In Python pass `model="s3-pro"` (keyword); in JS pass `"s3-pro"` as the **positional** `backend` argument. - **ASR models:** use `transcribe-2-pro` (recommended: speaker turns, long recordings, emotion cues, plus key terms and written or spoken numbers through the API); `transcribe-1-pro` is the previous Pro model. The model is selected by the `model` HTTP header: in JS pass `model: "transcribe-2-pro"` in the `convert()` request (`fish-audio` 0.2.0+), in Python send the header with `RequestOptions(additional_headers=...)`. A request without it is served and billed as `transcribe-1`, the model for short recordings. See [references/speech-to-text.md](references/speech-to-text.md). - **`transcribe-2-pro`:** another ASR model, selected the same way as `transcribe-1-pro` with the header value `transcribe-2-pro`. It returns the same response format; its `text_format`, `verbatim`, and `keyterms` fields need raw HTTP (see the `fish-audio-api` skill). - **Audio formats:** `mp3` (default), `wav`, `pcm`, `opus`. @@ -124,7 +124,7 @@ The two SDKs do **not** use the same names. Use this map when porting code betwe ## Gotchas (verified against the SDK source) -- Python `latency` accepts only **`"normal"` or `"balanced"`** (default `"balanced"`); there is no `"low"`. +- Python `latency` accepts `"normal"`, `"balanced"` (default) and, from `fish-audio-sdk` 1.8.1, `"low"`; 1.8.0's `TTSConfig` rejects `"low"`. `"low"` is not available on `s3-pro-free`. - The Python client has **no `max_retries`** and does **not** auto-retry; the JS client **does** auto-retry (configurable via per-call `requestOptions.maxRetries`). See [errors](references/errors.md). -- Python defines a `ValidationError` class but **never raises it**, so don't catch it expecting validation failures; a 422 surfaces as `APIError`. The JS SDK throws `UnprocessableEntityError` on 422. +- Python defines a `ValidationError` class but **never raises it**, so don't catch it expecting validation failures. Invalid `TTSConfig` values raise pydantic's `ValidationError` before any request (not a `FishAudioError`); values the API rejects surface as `APIError` (`400` from text to speech, also for an unknown `reference_id`). The JS SDK throws `UnprocessableEntityError` on 422. - ASR segment `start` / `end` and `duration` are all in **seconds**. In `fish-audio-sdk` 1.3.0 and earlier, the `ASRResponse` docstring says milliseconds; that is wrong. See [speech-to-text](references/speech-to-text.md). diff --git a/.mintlify/skills/fish-audio-sdk/references/errors.md b/.mintlify/skills/fish-audio-sdk/references/errors.md index 6ff8d946..8c8568fe 100644 --- a/.mintlify/skills/fish-audio-sdk/references/errors.md +++ b/.mintlify/skills/fish-audio-sdk/references/errors.md @@ -11,7 +11,7 @@ Hierarchy (all subclasses of `FishAudioError`): | `APIError` | base for HTTP errors | `.status`, `.message`, `.body` | | `AuthenticationError` | 401 (bad/missing key) | (APIError) | | `PermissionError` | 403 | (APIError) | -| `NotFoundError` | 404 (voice id not found) | (APIError) | +| `NotFoundError` | 404 (e.g. `voices.get()` with an unknown id) | (APIError) | | `RateLimitError` | 429 | (APIError) | | `ServerError` | 5xx | (APIError) | | `WebSocketError` | realtime stream failed | — | @@ -35,14 +35,14 @@ except AuthenticationError: except RateLimitError: ... # slow down / out of quota except NotFoundError: - ... # reference_id doesn't exist + ... # 404, e.g. voices.get() with an unknown id except APIError as e: - print(e.status, e.message) # any other HTTP error + print(e.status, e.message) # any other HTTP error; 400 for an unknown reference_id except FishAudioError as e: print("SDK error:", e) # non-HTTP (e.g. WebSocketError, DependencyError) ``` -> **Do not catch `ValidationError`.** The class exists and is exported, but the SDK **never raises it**. Invalid input comes back as an `APIError` (HTTP 422). Catch `APIError` (and read `.status == 422`) instead. +> **Do not catch `fishaudio.exceptions.ValidationError`.** The class exists and is exported, but the SDK **never raises it**. Invalid `TTSConfig` values raise pydantic's `ValidationError` before any request is sent (not a `FishAudioError`). Values the API rejects come back as an `APIError`: `400` from text to speech (an unknown `format`, an out-of-range value, an unknown `reference_id`), `422` for an invalid query parameter such as `voices.list(page_size=0)`. ### Retries & timeouts (Python) @@ -76,8 +76,8 @@ try { }); } catch (err) { if (err instanceof UnprocessableEntityError) { - const body = err.body as { detail?: unknown } | undefined; - console.error("422 validation:", body?.detail); // [{ loc, msg, type }] + const body = err.body as { errors?: { field: string; in: string; code: string; message: string }[] } | undefined; + console.error("422 validation:", body?.errors); // e.g. [{ field: "page_size", in: "query", code: "out_of_range", ... }] } else if (err instanceof FishAudioError) { if (err.statusCode === undefined) { console.error("no status:", err.message); // a timeout or a network error @@ -94,7 +94,7 @@ What the JS client actually throws for ordinary HTTP requests (`convert`, `voice | Error | When | | ----------------------------------------------------- | ------------------------------------------------------------------------------------------- | -| `UnprocessableEntityError` (extends `FishAudioError`) | 422, the **only** typed HTTP subclass thrown; `.body` is `{ detail: [{ loc, msg, type }] }` | +| `UnprocessableEntityError` (extends `FishAudioError`) | 422, the **only** typed HTTP subclass thrown; `.body` is `{ status, message, errors: [{ field, in, code, message }] }` | | `FishAudioError` | every other non-2xx response; read `.statusCode`, `.body`, `.rawResponse` | | `FishAudioError` with no `statusCode` | no usable response: the request exceeded the timeout or the network failed. with Node.js's built-in `fetch`, 0.2.0 does not throw the exported `FishAudioTimeoutError`; a `fetch` that rejects with `AbortError` does | diff --git a/.mintlify/skills/fish-audio-sdk/references/text-to-speech.md b/.mintlify/skills/fish-audio-sdk/references/text-to-speech.md index c4446759..b6ac1f91 100644 --- a/.mintlify/skills/fish-audio-sdk/references/text-to-speech.md +++ b/.mintlify/skills/fish-audio-sdk/references/text-to-speech.md @@ -34,10 +34,10 @@ All keyword-only: | `reference_id` | `str \| None` | `None` | Voice model id to speak with. | | `references` | `list[ReferenceAudio] \| None` | `None` | Inline clone samples; see [voice-cloning.md](voice-cloning.md). | | `format` | `"mp3" \| "wav" \| "pcm" \| "opus"` | `"mp3"` | Output format. | -| `latency` | `"normal" \| "balanced"` | `"balanced"` | `normal` = higher quality, `balanced` = faster. (No `"low"`.) | +| `latency` | `"normal" \| "balanced" \| "low"` | `"balanced"` | `normal` = higher quality, `balanced` = faster, `low` = earliest first audio on `s3-pro` (not on `s3-pro-free`). `TTSConfig` accepts `"low"` from 1.8.1. | | `speed` | `float` | — | Shortcut for prosody speed (0.5–2.0). | | `config` | `TTSConfig` | `TTSConfig()` | Reusable bundle of the settings below. | -| `model` | `"s2.1-pro" \| "s2.1-pro-free" \| "s2-pro" \| "drama-3" \| "s1"` or any `str` | `"s2.1-pro"` | Synthesis model (`fish-audio-sdk` 1.4.0 and later; 1.3.0 and earlier defaulted to `"s2-pro"`). `s1` is deprecated and will be retired on December 31, 2026; after that date, requests that specify `s1` are served by `s3-pro`. `speech-1.5` / `speech-1.6` are deprecated. | +| `model` | `"s3-pro" \| "s3-pro-free" \| "s2.1-pro" \| "s2.1-pro-free" \| "s2-pro" \| "drama-3" \| "s1"` or any `str` | `"s3-pro"` | Synthesis model (default in `fish-audio-sdk` 1.8.0 and later; older versions: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1#default-model-by-sdk-version`). `s1` is deprecated and will be retired on December 31, 2026; after that date, requests that specify `s1` are served by `s3-pro`. `speech-1.5` / `speech-1.6` are deprecated. | | `request_options` | `RequestOptions \| None` | `None` | Per-request timeout / headers; see [errors.md](errors.md). | Direct params (`reference_id`, `format`, `latency`, `speed`) override the matching field on `config` when set. @@ -102,7 +102,7 @@ with client.tts.stream_with_timestamps(text="Long passage...", format="opus") as ## JavaScript: `client.textToSpeech` -`convert(request, backend?, requestOptions?)` resolves to a `ReadableStream` you can `play()` or pipe to a file. `backend` is the **second positional** argument, **not** a named option. It defaults to `"s2.1-pro"` in `fish-audio` 0.2.0 (0.1.0 defaulted to the deprecated `"s1"`, so pass it explicitly if a project is still on 0.1.0). +`convert(request, backend?, requestOptions?)` resolves to a `ReadableStream` you can `play()` or pipe to a file. `backend` is the **second positional** argument, **not** a named option. It defaults to `"s3-pro"` in `fish-audio` 0.4.0 and later; older versions default to other models, some to the deprecated `"s1"` (see the table linked under Model & expression notes), so pass it explicitly. ```ts import { FishAudioClient, play } from "fish-audio"; @@ -132,9 +132,9 @@ await writeFile("out.mp3", audio2); `TTSRequest` (the first argument) fields: `text` (required), `reference_id?` (a voice ID, or an array of IDs for multi-speaker text with `<|speaker:N|>` tags, on `s3-pro`, the S2 models, and `drama-3`), `references?`, `format?`, `latency?` (`"low" | "normal" | "balanced"`), `prosody?: { speed?; volume?; normalize_loudness? }`, `temperature?`, `top_p?`, `chunk_length?`, `mp3_bitrate?`, `opus_bitrate?` (bits per second: `-1000 | 24000 | 32000 | 48000 | 64000`), `sample_rate?`, `normalize?`, plus the advanced generation knobs (`max_new_tokens`, `repetition_penalty`, `min_chunk_length`, `condition_on_previous_chunks`, `early_stop_threshold`, `features`). Field names are `snake_case`, matching the API. -> The JS `Backends` type (`fish-audio` 0.2.0) is `'s1' | 's2-pro' | 's2.1-pro' | 's2.1-pro-free' | 'drama-3'` plus any other string, so do not cast. Prefer `s3-pro`, the recommended model. Do not choose `s1`. Code written for 0.1.0 may still have `as Backends` casts; they are harmless but unnecessary. +> The JS `Backends` type (`fish-audio` 0.4.0) is `'s1' | 's2-pro' | 's2.1-pro' | 's2.1-pro-free' | 'drama-3' | 's3-pro' | 's3-pro-free'` plus any other string, so do not cast. Prefer `s3-pro`, the recommended model. Do not choose `s1`. On 0.1.0 and earlier the type has no `s3-pro`, so `"s3-pro"` needs `as Backends` there; after upgrading to 0.4.0, such casts are harmless but unnecessary. ## Model & expression notes -- `s3-pro` is the recommended model; pass it explicitly. `s2.1-pro` is the Python SDK default (`fish-audio-sdk` 1.4.0 and later). `s1` is the previous generation: S1 is deprecated and will be retired on December 31, 2026. After that date, requests that specify `s1` are served by `s3-pro`. Migration: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1`. +- `s3-pro` is the recommended model; pass it explicitly. `s3-pro` is the default of the current SDKs; for older versions see `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1#default-model-by-sdk-version`. `s1` is the previous generation: S1 is deprecated and will be retired on December 31, 2026. After that date, requests that specify `s1` are served by `s3-pro`. Migration: `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1`. - Emotion/expression is controlled inline in `text` (S2-Pro uses free-form `[bracket]` tags; the deprecated S1 uses legacy `(parenthesis)` tags, and the API does not convert between them); there is no separate SDK parameter. Full tag list: `https://docs.fish.audio/api-reference/emotion-reference`. diff --git a/.mintlify/skills/fish-audio-sdk/references/websocket.md b/.mintlify/skills/fish-audio-sdk/references/websocket.md index ff3a0bde..d422bb98 100644 --- a/.mintlify/skills/fish-audio-sdk/references/websocket.md +++ b/.mintlify/skills/fish-audio-sdk/references/websocket.md @@ -47,7 +47,7 @@ async def main(): asyncio.run(main()) ``` -`stream_websocket` keyword params mirror `convert`: `reference_id`, `references`, `format`, `latency`, `speed`, `config`, `model` (default `"s2.1-pro"`), plus `ws_options` (a `WebSocketOptions` for keepalive/message-size tuning). The sync version also accepts `max_workers` (default `10`) for its background sender thread; the async version does not. +`stream_websocket` keyword params mirror `convert`: `reference_id`, `references`, `format`, `latency`, `speed`, `config`, `model` (default `"s3-pro"` from `fish-audio-sdk` 1.8.0; `"s2.1-pro"` in 1.7.x, see `https://docs.fish.audio/developer-guide/models-pricing/migrate-from-s1#default-model-by-sdk-version`), plus `ws_options` (a `WebSocketOptions` for keepalive/message-size tuning). The sync version also accepts `max_workers` (default `10`) for its background sender thread; the async version does not. For manual control, yield events instead of strings: diff --git a/api-reference/errors.mdx b/api-reference/errors.mdx index 947b5bb2..be7bb37d 100644 --- a/api-reference/errors.mdx +++ b/api-reference/errors.mdx @@ -22,7 +22,7 @@ Some endpoints add fields. For example, `transcribe-1-pro` and `transcribe-2-pro | `401` | Invalid or missing API key | Send `Authorization: Bearer `; check it on [API Keys](https://fish.audio/app/api-keys). | | `402` | No API credit for the model you called | On a $0 balance, use the model `s3-pro-free`. For paid models, add API credit on [API Billing](https://fish.audio/app/developers/billing/). New developer accounts may receive a one-time free API credit on [Get Started](https://fish.audio/app/developers/get-started/?utm_source=docs&utm_medium=errors&utm_content=signup-credit), which works with every model. | | `403` | Not permitted for this key/resource | Check the key's scope and the resource owner. | -| `404` | Model or voice not found | Verify the `model_id` / `reference_id`. | +| `404` | Resource not found, for example a voice model on `GET /model/{id}` (text to speech with an unknown `reference_id` returns `400`) | Verify the ID in the path. | | `413` | Request body too large | Send a smaller request body. | | `429` | Too many requests, for example when your account is at its [concurrency limit](/developer-guide/models-pricing/pricing-and-rate-limits#concurrent-request-limits) | Back off and retry (see below). | | `5xx` | Server error | Retry with backoff; if it persists, contact support. | @@ -74,9 +74,9 @@ except AuthenticationError: except RateLimitError: ... # back off and retry except NotFoundError: - ... # bad reference_id / model id + ... # 404, e.g. client.voices.get() with an unknown id except APIError as e: - print(e.status, e.message) # 400, 402, 5xx, ... + print(e.status, e.message) # 400 (incl. unknown reference_id), 402, 5xx, ... ``` ```javascript JavaScript @@ -90,7 +90,7 @@ try { await client.textToSpeech.convert({ text: "Hello!" }); } catch (err) { if (err instanceof UnprocessableEntityError) { - console.error(err.body?.detail); // invalid parameters + console.error(err.body?.errors); // [{ field, in, code, message }], e.g. GET /model?page_size=0 } else if (err instanceof FishAudioError) { if (err.statusCode === undefined) { // no status: usually a timeout or a network error; see err.message diff --git a/developer-guide/getting-started/changelog.mdx b/developer-guide/getting-started/changelog.mdx index 66d05e4a..fa55b1ee 100644 --- a/developer-guide/getting-started/changelog.mdx +++ b/developer-guide/getting-started/changelog.mdx @@ -58,6 +58,14 @@ rss: true [Models overview](/developer-guide/models-pricing/models-overview) | [S3 Pro model card](/developer-guide/models-pricing/models/s3-pro) | [Quick Start](/developer-guide/getting-started/quickstart) + + ## Python SDK 1.8: S3 Pro by default + + `fish-audio-sdk` 1.8.0 changes the default text-to-speech model from `s2.1-pro` to `s3-pro`, and 1.8.1 accepts `latency="low"` in `TTSConfig`, which gives earlier first audio on `s3-pro`. Passing `model="s1"` or `model="transcribe-1"`, both retiring on December 31, 2026, emits a `FutureWarning`. `asr.transcribe()` also warns when `transcribe-1` comes from a `model` header in `RequestOptions(additional_headers=...)`. When neither the argument nor the header is set, it sends no model header and runs on `transcribe-1` without a warning, so pass `model="transcribe-2-pro"`; see [Migrate from transcribe-1](/developer-guide/models-pricing/migrate-from-transcribe-1). Response headers, such as `x-fish-trace-id`, are on `APIError` and on the streams of `tts.stream()`, `tts.stream_with_timestamps()`, and `asr.stream_websocket()`, and the results of `tts.convert_with_timestamps()` and `asr.transcribe()`; `tts.convert()` returns only the audio, so use `tts.stream()` when you need them. `WebSocketOptions` takes extra handshake headers. An HTTP error response whose body is not a JSON object or not valid UTF-8, as a proxy may send, now raises `APIError` or one of its subclasses instead of an unrelated exception. Since 1.7.0, the SDK sends `User-Agent: fish-audio-python/`. + + [Errors & Retries](/developer-guide/sdk-guide/python/errors) | [Release notes](https://github.com/fishaudio/fish-audio-python/releases/tag/fish-audio-sdk-v1.8.1) + + ## Voice Agents native iOS and Android SDKs diff --git a/developer-guide/integrations/n8n.mdx b/developer-guide/integrations/n8n.mdx index fe42e31b..9778d36c 100644 --- a/developer-guide/integrations/n8n.mdx +++ b/developer-guide/integrations/n8n.mdx @@ -42,8 +42,8 @@ On n8n Cloud, an instance owner or admin opens the nodes panel, searches for **F The node supports: -- **Text-to-Speech**: Generate audio from text using any voice model. Choose the model: new nodes use `s2.1-pro`, and `drama-3` is also in the list. Under **Additional Options**, **Language** sets the language used to read out numbers, dates, units and symbols while **Normalize Text** is on; see [Supported normalization languages](/features/text-to-speech#supported-normalization-languages). -- **Speech-to-Text**: Transcribe audio files. New nodes use `transcribe-1-pro`. +- **Text-to-Speech**: Generate audio from text using any voice model. Choose the model: from package 0.6.0 (node version 1.3), new nodes use `s3-pro`, and `s3-pro-free` and `drama-3` are also in the list. Nodes already in your workflows keep their model when you upgrade from 0.5.x to 0.6.0. Before 0.5.0 the node had a single version, so a node saved with no model chosen follows the package: it sent `s1` on 0.3.1 and sends `s2-pro` from 0.4.0 on. Under **Additional Options**, **Language** sets the language used to read out numbers, dates, units and symbols while **Normalize Text** is on; see [Supported normalization languages](/features/text-to-speech#supported-normalization-languages). +- **Speech-to-Text**: Transcribe audio files. New nodes use `transcribe-1-pro` from package 0.5.0 (node version 1.2); on 0.4.0 and earlier the node sends no model, so requests run on `transcribe-1`. From package 0.6.0, `transcribe-2-pro` is also in the list. - **Voice Models**: List, get, create, and delete custom voices - **Account**: Check credit balance @@ -51,7 +51,7 @@ The node is also available as an AI tool for use with n8n's AI Agent nodes. When a request fails and stops the workflow, the error's description shows the Fish Audio trace ID and error code if the API returned them. Include them when you contact support. With **Continue On Fail**, the output item carries only the error message, and older n8n versions that drop the API response from the error do not show these details. -These model choices, the **Language** option, and the trace ID in errors require version 0.5.0 or later of the node. +The `drama-3` and `s2.1-pro` model choices, the **Language** option, and the trace ID in errors require version 0.5.0 or later of the node; `s3-pro`, `s3-pro-free` and `transcribe-2-pro` require 0.6.0. ## Workflow templates diff --git a/developer-guide/models-pricing/migrate-from-s1.mdx b/developer-guide/models-pricing/migrate-from-s1.mdx index cb30f28f..74d837a1 100644 --- a/developer-guide/models-pricing/migrate-from-s1.mdx +++ b/developer-guide/models-pricing/migrate-from-s1.mdx @@ -33,7 +33,27 @@ The steps below cover each of these changes. In the API, you select the model with the `model` request header. Change `s1` to `s3-pro` wherever you set the model, including SDK and integration settings. -If you use the JavaScript SDK (`fish-audio` on npm) 0.1.0 without passing a model, your requests use `s1`, because that is its default backend. Upgrade to 0.2.0 or later, which defaults to `s2.1-pro` (check the [upgrade notes](/api-reference/sdk/javascript/api-reference#upgrade-notes) for other breaking changes first), and pass `"s3-pro"` explicitly. +If you call an SDK without passing a model, the SDK version decides which model your requests use. Look up your version in the table below: where it says `s1`, your requests use S1 although your code never names it. Upgrade the SDK, or pass `s3-pro` explicitly. For the JavaScript SDK, upgrading to `fish-audio` 0.4.0 is recommended; check the [upgrade notes](/api-reference/sdk/javascript/api-reference#upgrade-notes) for breaking changes first. If you stay on `fish-audio` 0.1.0 or earlier, its `Backends` type does not list `s3-pro`, so TypeScript rejects the plain string: pass `"s3-pro" as Backends`. + +### Default model by SDK version + +The model each published SDK version sends when you don't pass one: + +| SDK | Version | Default model | +|---|---|---| +| Python (`fish-audio-sdk`, `fishaudio` client) | 1.0.0 to 1.2.0 | `s1` | +| | 1.3.0 | `s2-pro` | +| | 1.4.0 to 1.7.0 | `s2.1-pro` | +| | 1.8.0 and later | `s3-pro` | +| Python, legacy `fish_audio_sdk.Session` (in the same package) | 0.1.0 to 2025.1.8 | no `model` header: the API's default applies | +| | 2025.2.11 and later, including every 1.x release | `speech-1.5` (deprecated) | +| JavaScript (`fish-audio`) | 0.0.1 to 0.1.0 | `s1` | +| | 0.2.0 and 0.3.0 | `s2.1-pro` | +| | 0.4.0 and later | `s3-pro` | +| Go (`fish-audio-go`) | v1.0.0 | no `model` header: the API's default applies | +| | v1.1.0 and v1.1.1 | `s2-pro` | +| | v1.2.0 | `s2.1-pro` | +| | v1.3.0 and later | `s3-pro` | This example also converts the emotion tags, as described in the next step: diff --git a/developer-guide/sdk-guide/python/errors.mdx b/developer-guide/sdk-guide/python/errors.mdx index 72a2fa15..5103295a 100644 --- a/developer-guide/sdk-guide/python/errors.mdx +++ b/developer-guide/sdk-guide/python/errors.mdx @@ -18,18 +18,24 @@ Every SDK error inherits from [`FishAudioError`](/api-reference/sdk/python/excep | --- | --- | --- | | `AuthenticationError` | `401` | Missing or invalid API key | | `PermissionError` | `403` | Key lacks permission for the resource | -| `NotFoundError` | `404` | Voice model id not found | +| `NotFoundError` | `404` | Voice model id not found, for example in `client.voices.get()` | | `RateLimitError` | `429` | Rate limit / quota exceeded | | `ServerError` | `5xx` | Transient server-side failure | -| `APIError` | any other non-2xx | Base for the above; `status == 422` for invalid parameters | +| `APIError` | any other non-2xx | Base for the above; e.g. `status == 400` for an invalid text-to-speech parameter or an unknown `reference_id`, `422` for an invalid query parameter such as `voices.list(page_size=0)` | | `WebSocketError` | realtime stream failed mid-session | Reconnect rather than retrying the same socket | | `ASRRealtimeError` | a realtime speech-to-text session ended with an error | Subclass of `WebSocketError`; carries `.error_type`, `.code`, `.request_id`, and `.close_code`, each `None` when not sent | | `DependencyError` | a required system tool is missing (e.g. ffmpeg for `play()`) | Carries `.dependency` and `.install_command` | - Invalid request parameters come back as an `APIError` with `status == 422`. - Catch `APIError`, not a separate `ValidationError` (none is raised at - runtime). + Invalid input fails in one of two places. Values the SDK checks itself, such + as `TTSConfig(format="bad")` or `TTSConfig(chunk_length=99)`, raise + pydantic's `ValidationError` before any request is sent; it is not a + `FishAudioError`. Values the SDK passes on, such as `format="bad"` given + straight to `tts.convert()`, are checked by the API and come back as an + `APIError`: `400` from text to speech (also for a `reference_id` that doesn't + exist), `422` for an invalid query parameter such as + `voices.list(page_size=0)`. Catch `APIError`, not + `fishaudio.exceptions.ValidationError` (none is raised at runtime). ## Handling errors @@ -56,9 +62,9 @@ except AuthenticationError: except RateLimitError: print("Rate limited: back off and retry") except NotFoundError: - print("That voice model does not exist") + print("Not found") # 404, e.g. client.voices.get() with an unknown id except APIError as e: - print(f"API error {e.status}: {e.message}") # includes 422 validation + print(f"API error {e.status}: {e.message}") # 400: invalid parameters or unknown reference_id except FishAudioError as e: print(f"SDK error: {e}") # e.g. WebSocketError, DependencyError ``` diff --git a/developer-guide/sdk-guide/quickstart.mdx b/developer-guide/sdk-guide/quickstart.mdx index d9a4746c..1ee4a4d4 100644 --- a/developer-guide/sdk-guide/quickstart.mdx +++ b/developer-guide/sdk-guide/quickstart.mdx @@ -36,6 +36,8 @@ npm install fish-audio ``` +The JavaScript example plays the audio with `play()`, which runs `ffplay`, so install [ffmpeg](https://ffmpeg.org/) first; without it, `play()` throws `ffplay from ffmpeg not found`. + ## 2. Authenticate diff --git a/features/text-to-speech.mdx b/features/text-to-speech.mdx index 1791f4f8..14b73d68 100644 --- a/features/text-to-speech.mdx +++ b/features/text-to-speech.mdx @@ -116,7 +116,7 @@ curl --request POST https://api.fish.audio/v1/tts \ - **`s2-pro`**: previous-generation S2 model with multi-speaker and natural-language expression control. - **`s1`**: previous generation, `(parenthesis)` emotion tags. S1 is deprecated and will be retired on December 31, 2026. After that date, requests that specify `s1` are served by `s3-pro`. See [Migrate from S1](/developer-guide/models-pricing/migrate-from-s1). -In the API, select with the `model` request header; requests without it use `s2.1-pro`. The Python SDK always sends a model and defaults to `model="s2.1-pro"` (`fish-audio-sdk` 1.4.0 and later; earlier versions default to `s2-pro`). The JavaScript SDK defaults to `s2.1-pro` (`fish-audio` 0.2.0 and later). See [Models Overview](/developer-guide/models-pricing/models-overview). +In the API, select with the `model` request header; requests without it use `s2.1-pro`. The current Python SDK client (`fishaudio`), JavaScript SDK and Go SDK default to `s3-pro`; the legacy Python `fish_audio_sdk.Session` sends `speech-1.5`, and earlier SDK versions default to other models, see [Default model by SDK version](/developer-guide/models-pricing/migrate-from-s1#default-model-by-sdk-version). See [Models Overview](/developer-guide/models-pricing/models-overview). ### Output formats @@ -275,7 +275,7 @@ audio = client.tts.convert( - `latency="balanced"` (default): lower time-to-first-audio. Good for interactive use. For the measured time to first audio on `s3-pro` with `balanced` and `low`, see [S3 Pro benchmarks](/developer-guide/models-pricing/models/s3-pro#benchmarks). - `latency="normal"`: most stable output, at slightly higher latency. -- `latency="low"`: lowest latency. Send it in the API request body, or with the JavaScript SDK. The Python SDK's `TTSConfig` accepts `balanced` and `normal`. `latency: "low"` is not available on `s3-pro-free`. +- `latency="low"`: lowest latency. Send it in the API request body, with the JavaScript SDK, or with the Python SDK: `TTSConfig(latency="low")` and the `LatencyMode` type accept it from `fish-audio-sdk` 1.8.1; in 1.8.0, `latency="low"` passed directly to a method is already sent, while `TTSConfig` rejects it. `latency: "low"` is not available on `s3-pro-free`. - `chunk_length` (`100`–`300`): smaller chunks start audio sooner; larger chunks are more efficient for long text. The API default is `300`; the Python SDK's `TTSConfig` sends `200` unless you set it. On `s3-pro`, chunking is managed automatically by the service. diff --git a/features/text-to-speech/realtime.mdx b/features/text-to-speech/realtime.mdx index 10201dfb..e89015be 100644 --- a/features/text-to-speech/realtime.mdx +++ b/features/text-to-speech/realtime.mdx @@ -161,7 +161,7 @@ Both streaming paths take a `latency` mode: - `latency="balanced"` (default): low time-to-first-audio. Use it for voice agents and live LLM output. - `latency="normal"`: slightly higher latency, best audio quality. Use it for narration where you can afford a beat. -- `"latency": "low"`: lowest latency, in the API request body or with the JavaScript SDK. The Python SDK accepts `balanced` and `normal`. `latency: "low"` is not available on `s3-pro-free`. +- `"latency": "low"`: lowest latency, in the API request body, with the JavaScript SDK, or with the Python SDK: `TTSConfig(latency="low")` and the `LatencyMode` type accept it from `fish-audio-sdk` 1.8.1; in 1.8.0, `latency="low"` passed directly to a method is already sent, while `TTSConfig` rejects it. `latency: "low"` is not available on `s3-pro-free`. ```python for chunk in client.tts.stream_websocket(llm_tokens(), latency="balanced"):