Skip to main content
Enables real-time voice conversation. It accepts audio and text input and produces streaming audio (with a matching text transcript) as output, over a single WebSocket connection.
For model capabilities, supported voices, audio format, and a runnable quick-start, see StepAudio 2.5 Realtime. An open-source reference client is available at Step-Realtime-Console.

Protocol

WebSocket.

Endpoint

The model is passed as a query parameter, e.g. wss://api.stepfun.ai/v1/realtime?model=stepaudio-2.5-realtime.

Authentication

  • Authorization string required
    Authentication token in the format Bearer $STEPFUN_API_KEY.

Request Parameters

  • model string required
    The model to use. Currently supports stepaudio-2.5-realtime.

Voices

Set the voice with session.update before the model produces audio. The following system voices are available: You can also use a cloned voice: clone it via the Voice cloning API with the stepaudio-2.5-tts model, then pass the returned voice ID as voice.
Only the voice IDs above (or a valid cloned voice ID) are accepted; other values are rejected with a 400 error. A session’s voice cannot be changed once the model has produced audio.

How it works

After the WebSocket connection is established, the client sends Client Events and receives Server Events to drive the interaction.

Common fields

The following fields are common to Client and Server Events:

Client Events

Create / update session (session.update)

Send this event to create or update the session’s default configuration. The client may send it at any time to update the session; any field may be updated at any time except voice. The server responds with a session.updated event.
  • modalities array<string>
    The set of modalities the model may use. Fixed to ["text", "audio"].
  • instructions string
    Default system instructions (i.e. the system message) prepended before the model call. Use this to guide the model’s content and format (e.g. “be very concise”, “be friendly”) and its audio behavior (e.g. “speak quickly”, “inject emotion into your voice”). The model is not guaranteed to follow the instructions, but they provide guidance on the desired behavior.
  • voice string
    The voice used for generation. See Voices for the available system voices and how to use a cloned voice. The voice cannot be changed once the model has produced audio.
  • turn_detection object optional
    Server VAD configuration. Disabled by default.
  • input_audio_format string
    Input audio format. Currently supports pcm16.
  • output_audio_format string
    Output audio format. Currently supports pcm16.
  • tools object array optional
    The list of functions available for tool calling.
Sample

Append audio (input_audio_buffer.append)

Append audio bytes to the input audio buffer. The server does not acknowledge this event. In Server VAD mode it triggers model inference.
  • audio string
    Base64-encoded audio bytes, in the format specified by input_audio_format in the session configuration.
Sample

Commit audio (input_audio_buffer.commit)

Commit the user’s input audio buffer for inference, creating a new user message item in the conversation. The server responds with an input_audio_buffer.committed event. If the input audio buffer is empty, this event produces an error. Sample

Clear audio (input_audio_buffer.clear)

Clear the user’s input audio buffer. The server responds with an input_audio_buffer.cleared event. Sample

Create conversation item (conversation.item.create)

Add a new item to the conversation context, including messages, function calls, and function-call responses. Use it to populate conversation history or to add new items mid-session, but it cannot populate Assistant audio messages. On success the server responds with conversation.item.created; otherwise it sends an error event.
  • previous_item_id string
    The ID of the previous item.
  • item object
    The message item; see the message parameters.
Sample

Delete conversation item (conversation.item.delete)

Send this event to remove an item from the conversation history. The server responds with conversation.item.deleted. If the item does not exist, the server responds with an error.
  • item_id string
    The ID of the item to delete.
Sample

Create response (response.create)

Instructs the server to create a Response, i.e. trigger model inference. Sample

Cancel response (response.cancel)

Cancel an in-progress response. The server returns a response.cancelled event, or an error if there is no response to cancel.

Server Events

Error (error)

Returned when an error occurs during server processing. This may be a client or server problem; the session continues.
  • type string
    Error type (e.g. invalid_request_error, server_error).
  • code string
    Error code, if any.
  • message string
    Human-readable error message.
  • event_id string
    The event_id of the client event that caused the error, if applicable.
Sample

Session created (session.created)

Returned when the session is created, automatically emitted as the first server event when a new connection is established. Contains the default session configuration.
  • modalities array<string>
    The set of modalities the model may use. Fixed to ["text", "audio"].
  • instructions string
    Default system instructions prepended before the model call.
  • voice string
    The voice used for generation.
  • input_audio_format string
    Input audio format. Currently supports pcm16.
  • output_audio_format string
    Output audio format. Currently supports pcm16.
  • volume_ratio number
    Output volume ratio. Default 1.
Sample

Session updated (session.updated)

Returned when the session is updated. Sample

Speech started (input_audio_buffer.speech_started)

Notifies that valid speech input has started; typically used for interruption scenarios. Emitted only when Server VAD is enabled.
  • audio_start_ms integer
    The start time of the speech within the audio.
  • item_id string
    The item ID.
Sample

Speech stopped (input_audio_buffer.speech_stopped)

Notifies that valid speech input has ended. Emitted only when Server VAD is enabled.
  • audio_end_ms integer
    The end time of the speech within the audio.
  • item_id string
    The item ID.
Sample

Response audio delta (response.audio.delta)

Returned as the model generates audio.
  • response_id string
    The response ID.
  • item_id string
    The item ID.
  • output_index int
    The index of the output item in the response.
  • delta string
    A Base64-encoded audio delta, in the output_audio_format set when the session was created.
Sample

Response audio done (response.audio.done)

Returned when the model’s audio is complete. Also emitted when a response is interrupted, incomplete, or cancelled.
  • response_id string
    The response ID.
  • item_id string
    The item ID.

Audio transcript delta (response.audio_transcript.delta)

Streams the text transcript of the model’s audio output.
  • response_id string
    The response ID.
  • item_id string
    The item ID.
  • output_index int
    The index of the output item in the response.
  • delta string
    The transcript delta.

Audio transcript done (response.audio_transcript.done)

Returned when the transcript of the model’s audio output finishes streaming. Also emitted when a response is interrupted, incomplete, or cancelled.
  • response_id string
    The response ID.
  • item_id string
    The item ID.
  • output_index int
    The index of the output item in the response.
  • transcript string
    The complete transcript of the audio.

Thinking delta (response.thinking.delta)

Streams the model’s reasoning process as it is generated.
  • response_id string
    The response ID.
  • item_id string
    The item ID.
  • output_index int
    The index of the output item in the response.
  • content_index int
    The index of the content part in the item’s content array.
  • delta string
    The reasoning delta.

Thinking done (response.thinking.done)

Returned when the model’s reasoning process finishes.
  • response_id string
    The response ID.
  • item_id string
    The item ID.
  • output_index int
    The index of the output item in the response.
  • content_index int
    The index of the content part in the item’s content array.
  • thinking string
    The complete reasoning text.

Response text delta (response.text.delta)

Returned as the model generates text output.
  • response_id string
    The response ID.
  • item_id string
    The response item ID.
  • output_index int
    The index of the output item in the response.
  • content_index int
    The index of the content part containing the text.
  • delta string
    The generated text delta.

Response text done (response.text.done)

Returned when the model’s text output is complete. Also emitted when a response is interrupted, incomplete, or cancelled.
  • response_id string
    The response ID.
  • item_id string
    The response item ID.
  • output_index int
    The index of the output item in the response.
  • content_index int
    The index of the content part containing the text.
  • text string
    The complete generated text.

Conversation item created (conversation.item.created)

Returned when a conversation item is created.
  • id string
    The unique ID of the message. Optional; the server generates one if the client does not provide it.
  • type string
    The item type, usually message.
  • role string
    The role of the sender (user, assistant, system); applies to message items only.
  • status string
    The item status (completed, incomplete).
  • content array
    The message content; applies to message items.

Conversation item deleted (conversation.item.deleted)

Returned when the client deletes a conversation item with conversation.item.delete. Used to keep the server’s conversation history in sync with the client.
  • item_id string
    The conversation item ID.

Input audio transcription completed (conversation.item.input_audio_transcription.completed)

The output of the automatic speech recognition (ASR) of the user’s input audio. Transcription starts when the client commits the buffer, or when the buffer is committed in Server VAD mode. It runs asynchronously with response creation, so this event may arrive before or after the response events.
  • item_id string
    The conversation item ID.
  • content_index int
    The index of the audio content part.
  • transcript string
    The complete transcript of the audio.

Audio buffer committed (input_audio_buffer.committed)

Returned when the client commits the input audio buffer.
  • previous_item_id string
    The previous item ID in the conversation.
  • item_id string
    The conversation item ID.

Audio buffer cleared (input_audio_buffer.cleared)

Returned when the client clears the input audio buffer with input_audio_buffer.clear.

Response output item added (response.output_item.added)

Returned when a new item is created during response generation.
  • output_index int
    The index of the output item in the response.
  • item object
    The output item.

Response output item done (response.output_item.done)

Returned when an item is completed. Also emitted when the response is interrupted, incomplete, or cancelled.
  • output_index int
    The index of the output item in the response.
  • item object
    The output item (same structure as in response.output_item.added).

Response content part added (response.content_part.added)

Returned when a new content part is added to an assistant message item during response generation.
  • response_id string
    The response ID.
  • item_id string
    The corresponding item ID.
  • content_index int
    The index of the content part in the item’s content array.
  • output_index int
    The index of the output item in the response.
  • part object

Response content part done (response.content_part.done)

Returned when a content part is completed. Also emitted when the corresponding response is interrupted, incomplete, or cancelled.
  • response_id string
    The response ID.
  • item_id string
    The corresponding item ID.
  • content_index int
    The index of the content part in the item’s content array.
  • output_index int
    The index of the output item in the response.
  • part object
    Same structure as in response.content_part.added.

Response created (response.created)

Returned when a new Response is created. This is the first event of response creation, with an initial status of in_progress.
  • id string
    The unique ID of the response.
  • object string
    The object type, realtime.response.
  • status string
    The response status (in_progress, completed, cancelled, failed, incomplete).
  • output list
    The list of output items generated by the response.

Response done (response.done)

Returned when the Response finishes streaming. Always emitted, regardless of the final status. The Response object includes all output items but omits the raw audio data.
  • id string
    The unique ID of the response.
  • object string
    The object type, realtime.response.
  • status string
    The final status (completed, cancelled, failed, incomplete).
  • output list
    The list of output items generated by the response.