Skip to main content
Fish Audio inference APIs accept the standard W3C Trace Context traceparent header. Send this header when your application already has an active trace and you want Fish Audio edge, inference, alignment, and upstream ASR spans to appear under the same trace ID. Supported inference surfaces:
  • POST /v1/tts
  • POST /v1/tts/stream/with-timestamp
  • POST /v1/asr
  • wss://api.fish.audio/v1/tts/live
  • wss://api.fish.audio/v1/asr/realtime
If traceparent is omitted or invalid, Fish Audio starts a new trace for the request. Tracing does not change authentication, rate limits, billing, request priority, or generated output.

Header Format

Use the W3C traceparent format:
Example:
In this example, 4bf92f3577b34da6a3ce929d0e0e4736 is the trace ID. Fish Audio continues that trace ID when it calls the inference backend and related services.
Prefer letting your tracing SDK inject traceparent instead of hand-building it. For each Fish Audio request, create a child span in your business service and inject that span context into the outgoing HTTP or WebSocket headers.

Bind Business and Inference Traces

To bind your business-side trace to Fish Audio’s inference-side trace:
  1. Start or continue a trace in your application for the user workflow.
  2. Create a child span around the Fish Audio request.
  3. Inject that span context into the request headers.
  4. Send the request with traceparent.
  5. Use the same trace ID in your observability tool to inspect both your business spans and Fish Audio inference spans.
For multiple Fish Audio calls in one workflow, keep the same trace ID by using the same parent trace, but let your tracing SDK create a fresh parent/span ID for each outgoing request.

REST Example

OpenTelemetry Examples

SDK Examples

The official SDKs send traceparent in two ways: OpenTelemetry instruments the HTTP library the SDK uses, or you pass the header yourself. These examples assume that your application already configures an OpenTelemetry tracer provider and exporter.
OpenTelemetry auto-instrumentation. The SDK sends every request through httpx, including the WebSocket upgrades of tts.stream_websocket and asr.stream_websocket. Install opentelemetry-instrumentation-httpx and instrument httpx once at startup. Each Fish Audio request then gets its own child span and traceparent.
By hand. Inject the current span context into additional_headers:
tts.stream_websocket and asr.stream_websocket do not take request_options. To add the header there without auto-instrumentation, pass your own httpx client with a request hook. A client you pass in does not get the SDK’s base_url or timeout, so set both on it.
Some SDK calls cannot carry traceparent yet:
  • TypeScript textToSpeech.convertRealtime (/v1/tts/live) does not send headers you set on the client. It carries traceparent only when @opentelemetry/instrumentation-http is active.
  • Go TTS.StreamWebSocket (/v1/tts/live) cannot send traceparent.
  • Go TTS.Convert, TTS.Stream and ASR.Transcribe do not take per-request headers. Use a custom transport as shown above.
For these calls, use the raw WebSocket example or the REST example.

WebSocket Tracing

Pass traceparent on the WebSocket upgrade request:
Browser WebSocket APIs do not allow custom headers. For browser clients, inject traceparent from a trusted server-side proxy or use REST endpoints where your frontend can send the header through fetch.

Trace ID in Responses

Inference responses include an x-fish-trace-id header with the trace ID Fish Audio used for the request. This applies to the inference endpoints listed above, including the WebSocket upgrade response. When you send a valid traceparent, the value is your trace ID. When you omit traceparent or send an invalid one, it is the new trace ID Fish Audio started. Include it when you contact support about a request.

Speech-to-Text Request IDs

transcribe-1-pro responses from POST /v1/asr include a request_id field in the JSON body, on success and on its own error responses, and the same value in the x-request-id response header. Platform errors, such as authentication, credit, and concurrency errors, and errors from the network edge do not carry it. Include it when you contact support about a transcription request. See Speech to Text.

Enterprise Performance Analysis

Fish Audio supports trace-based performance analysis for enterprise customers with a signed enterprise agreement. When this support is enabled, share the W3C trace ID with Fish Audio support so we can correlate your business span with Fish Audio edge routing, backend inference, reference-audio encoding, TTFT, response-time, alignment, and upstream ASR spans.
Only share the trace ID or traceparent value needed for investigation. Do not place API keys, user identifiers, transcripts, audio URLs, or other sensitive data in trace IDs or span names.