Fish Audio Python SDK
[!IMPORTANT]Changes to PyPI Versioning
For existing users on Fish Audio Python SDK, please note that the starting version is now1.0.0. The last version before this was2025.6.3. You may need to adjust your version constraints accordingly. The original API in thefish_audio_sdkpackage has NOT been removed, but you will not receive any updates if you continue using the old versioning scheme. The simplest fix is to update your dependency tofish-audio-sdk>=1.0.0to continue receiving updates, or by pinning to a specific version likefish-audio-sdk==1.0.0when installing via your package manager. There are no changes to the API itself in this transition. If you’re using the legacyfish_audio_sdkand would like to switch to the newer, more robustfishaudiopackage, see the migration guide to upgrade.
Installation
Authentication
Get your API key from fish.audio/app/api-keys:Quick Start
Synchronous:play runs the ffplay program from FFmpeg, which must be on your PATH; without it, play raises DependencyError. To play without FFmpeg, install the [utils] extra (on Linux, sounddevice also needs the PortAudio library, such as libportaudio2) and pass use_ffmpeg=False.
Core Features
Text-to-Speech
Selecting a model:[sigh]) still produces audio, but the API has no timings for it: segments is then empty and result.duration is None.
s1 and transcribe-1 are deprecated and will be retired on December 31, 2026. After that date, requests that specify them are served by s3-pro and transcribe-2-pro. Using a deprecated model emits a FutureWarning; with Python’s default warning filters it is shown once per calling line. A coroutine scheduled with asyncio.create_task or gather runs from asyncio’s code, so its warning points there and is shown once in all. See Model Deprecations.
Learn more
Speech-to-Text
transcribe-stream-1 and get the transcript turn by turn. Send 16-bit mono PCM in 20–40 ms chunks as you capture it:
AsyncFishAudio, pass an async iterator and use async for. The returned stream also sends control messages during the session, such as stream.finalize() for push-to-talk and stream.agent_speaking(True) for voice agents.
Learn more
Real-time Streaming
Stream dynamically generated text for conversational AI and live applications: Synchronous:Voice Cloning
Instant cloning:Resource Clients
Tracing
To continue your trace in the Fish Audio API, send a W3Ctraceparent header on each request. Use one of the ways below. A traceparent that the OpenTelemetry instrumentation sends replaces one you set yourself.
With OpenTelemetry, configure a tracer provider and enable opentelemetry-instrumentation-httpx. HTTP calls and the WebSocket handshakes of tts.stream_websocket() and asr.stream_websocket() then carry the current trace: the same trace id, under a client span that the instrumentation creates. A WebSocket stream connects when you first iterate it, so iterate it inside your span.
httpx_client with a request event hook, which runs for HTTP calls and WebSocket handshakes alike (with AsyncFishAudio, use an httpx.AsyncClient and an async hook). A client you pass in keeps its own settings, so set its timeout: httpx’s default is 5 seconds.
Error Handling
APIError carries the headers of the error response. When you contact support, include the trace id and the error code. Either can be absent.
tts.stream_websocket handshake that the server refuses raises httpx_ws.WebSocketUpgradeError; read the same headers from e.response.headers.
Trace IDs
Responses to speech and transcription requests carry anx-fish-trace-id header. Include it when you contact support about a request, also one that succeeded but sounds wrong. The stream that tts.stream() returns has the response headers:
headers attribute is on the streams of tts.stream_with_timestamps() and asr.stream_websocket() (empty until the connection opens on the first iteration), and on the results of tts.convert_with_timestamps() and asr.transcribe() (the latter also has request_id). tts.convert() returns only the audio; use tts.stream() as above when you need the headers. tts.stream_websocket() does not expose them yet.
Resources
- Documentation: SDK Guide | API Reference
- Package: PyPI | GitHub
- Legacy SDK: Documentation | Migration Guide

