Skip to main content
Deploy Qwen3-ASR from the Model Library and transcribe a short recording. Choose batch transcription to upload the file and receive a complete transcript, or real-time transcription to send audio in chunks and receive partial and final transcripts over WebSocket. If Baseten provided a unified speech-to-text (STT) deployment, use the v2 client.

Before you begin

You need a Baseten account and a Baseten API key. The real-time Python client also requires uv. Each model deployment runs on a dedicated GPU; review the instance cost before deploying. The shell commands on this page use macOS or Linux syntax. To download the recording: Run the following command:
This creates jfk.wav, an 11-second excerpt of John F. Kennedy’s inaugural address from the Whisper test assets. The file contains 16 kHz mono, signed 16-bit pulse-code modulation (PCM16) audio. The batch request uploads the WAV file; the real-time client reads the WAV container and sends only the audio samples.

Transcribe a batch

To deploy a batch transcription model:
  1. Sign in to your workspace, then open Qwen3-ASR in the Model Library and choose Deploy Batch.
  2. Enter a Model name, review Hardware and pricing and Autoscaling, then choose Deploy.
  3. Wait for the deployment to become active. Open the model’s overview and choose Copy ID next to its name.
To transcribe the recording: Set your API key and the batch model ID, then run the following command:
The JSON response contains the transcript in text. Compare it with the recording transcript shown alongside the request. Check that the full recording is present before accepting the result; wording and punctuation can vary. This request sends the whole file without real-time pacing. Batch transcription uses HTTP; the real-time procedure uses a separate deployment and WebSocket client. Deactivate the tutorial deployment when you’re finished unless you plan to keep using it.

Deactivate the tutorial deployment

To stop the tutorial deployment:
  1. In your workspace, choose Dedicated Inference, then select the model you deployed for this procedure.
  2. Open its deployment and choose Deactivate deployment.
  3. Confirm the action to stop its replicas.
For more information, see Deployment lifecycle.

Deploy a real-time model

This Model Library deployment uses the model-specific v1 protocol. A unified STT deployment uses v2 instead; the clients aren’t interchangeable. To deploy a real-time transcription model:
  1. Sign in to your workspace, then open Qwen3-ASR in the Model Library and choose Deploy Streaming, the library’s label for the real-time deployment.
  2. Enter a Model name, review Hardware and pricing and Autoscaling, then choose Deploy.
  3. Wait for the deployment to become active. Open the model’s overview and choose Copy ID next to its name.
The batch and real-time deployments use different endpoints. Use the real-time model ID for the WebSocket client below.

Connect to the endpoint

To configure the streaming client: Set your API key and the real-time model ID you copied:
These commands set environment variables without printing them. Keep the API key on your server; don’t embed it in browser code. Save the following as transcribe.py. The client connects to your model’s production WebSocket endpoint, sends audio while receiving transcripts, and closes after the server finishes processing the recording. See the Qwen3-ASR API reference for the message schema and audio requirements. The client declares its Python requirement and WebSocket dependency in inline script metadata. The uv run command selects Python 3.11 and installs the dependency in an isolated environment. uv downloads Python if needed.

Stream the audio

To transcribe the recording in real time: Run the client with the supplied recording:
The client sends 100 ms of audio per chunk at real-time pace. It wraps each chunk in an input_audio_buffer.append JSON message with base64 audio. After the last chunk, it sends input_audio_buffer.commit to flush the remaining speech. Sending and receiving run concurrently so you can receive partial transcripts while audio is still arriving. The client waits up to 60 seconds for each response and also bounds the total session time. If the connection fails before any transcript appears, check that the real-time deployment is active and the model ID and API key belong to the same workspace. An HTTP 500 during model startup can mean the replica hasn’t finished loading; inspect the deployment’s Logs and retry after it becomes ready. A format error means your WAV differs from the supplied 16 kHz mono PCM16 recording.

Read the transcript

The client prints updates labeled with a transcription number. A partial is a revisable hypothesis for that number. A final completes that segment. Store finals once per number instead of concatenating every partial update. One run with the supplied recording produced these final lines (partial updates omitted):
A recording can produce multiple final segments. The client joins them into the last Transcript: line. Partial wording and the number of updates can vary between runs.

Finish the session

The client waits for a final message with is_end_of_audio_flush: true before closing the WebSocket. Closing immediately after sending the audio can lose the last transcript. If you interrupt the client with Ctrl+C, run the file again to get a complete result. Your real-time transcription is complete when the client prints Transcript: and exits. Closing the connection releases the session; the deployment remains active according to its autoscaling settings.

Deactivate the tutorial deployment

To stop the tutorial deployment:
  1. In your workspace, choose Dedicated Inference, then select the model you deployed for this procedure.
  2. Open its deployment and choose Deactivate deployment.
  3. Confirm the action to stop its replicas.
For more information, see Deployment lifecycle.

Transcribe with the unified API

Use this client for a unified STT server deployment provided by Baseten. Contact Baseten support to obtain a deployment and its model and deployment IDs. The Qwen3-ASR Deploy Streaming option in the Model Library uses v1 and doesn’t work with this client. The client targets a specific published deployment so you can validate v2 before promoting it to an environment. Unified STT presets use custom Docker servers and don’t support development deployments.

Configure the v2 client

To connect to your unified deployment: Set your API key and the model and deployment IDs provided by Baseten:
Keep the API key on your server. Save the following code as transcribe-v2.py. It checks the deployment’s advertised audio format and waits up to 60 seconds for session.created; a v1 deployment doesn’t send that event.
transcribe-v2.py

Stream the recording

To transcribe the recording with v2: Run the client with the jfk.wav recording from Before you begin. It contains 16 kHz mono PCM16 audio, which the Qwen3-ASR unified deployment accepts. Convert it first if your deployment advertises a different input format.
The client reads session.created, requests client_flush, and prints any refused settings. It sends 100 ms audio chunks at real-time pace while receiving partial transcripts. Each turn contains at most 10 seconds of audio and stays below the deployment’s max_turn_s limit. On the Qwen3-ASR unified deployment, the supplied recording spans 2 client turns. Deployments with shorter turn limits produce more turns. Transcript text and partial updates depend on the model. The client flushes each turn and waits for its transcription.done before sending the next turn. This keeps flush results unambiguous when a recording exceeds the model’s turn limit. Fixed boundaries can split words; in a voice application, flush at your application’s utterance boundaries instead.

Confirm completion

Accept the result only when the client prints Transcript: and exits successfully. That line contains the joined final transcripts, without partial updates. Compare it with the recording transcript in Transcribe a batch. A failed turn, a missing result, or an early socket close causes the client to exit with an error. Each receive has a 60-second timeout, and each turn has an overall timeout of its audio duration plus 120 seconds. Adjust these limits for your workload. The client sends close only after every turn has a final result; close code 1000 alone doesn’t confirm complete transcription. If the connection fails, check that the deployment is active and that both IDs and the API key belong to the same workspace. For message fields and error codes, see Real-time transcription API (v2). Closing the WebSocket releases the session. To stop the deployment’s replicas when you’re finished, follow Deactivate the tutorial deployment.

Next steps