Skip to main content
A server started with mstar serve takes requests three ways: the Python SDK, the native /generate routes that every model serves, and OpenAI-compatible /v1 routes for the models that have an OpenAI adapter. HTTP API lists every route and the models behind each one. Poll GET /health until it returns 200 {"status": "healthy"}; it answers 503 when the backend does not respond or is shutting down (Health).

Python SDK

MStarClient wraps POST /generate. It imports only requests, and numpy for the audio helpers, not torch.
  • Keyword arguments other than the named ones are sent as the model’s model_kwargs (voice="tara", temperature=0.7, max_output_tokens=256). None values are dropped.
  • tts(text, *, voice=None, reference_audio=None, **kw) clones a voice from reference_audio (a path, bytes or a (filename, bytes) tuple) on models that take a reference clip. examples/sdk_tts_qwen3.py shows it for qwen3_tts_base.
  • api_key="...", or MSTAR_API_KEY in the client’s environment, sends the server’s key as a bearer token (API key).
  • session= takes your own requests.Session. enable_nvtx=True adds NVTX ranges around the client’s reads and decodes for a CUDA profile (it imports torch).
  • A non-streaming call returns a GenerateResult with .request_id, .text, .images, .audio and .raw. Video (mp4) and action (float32) outputs land only in .raw, a list of {"modality", "bytes", "metadata"} entries. Request them with stream=False: streamed, they arrive as TextChunks decoded with errors="replace", which corrupts the bytes.
Python SDK lists every method, argument and result type.

OpenAI-compatible API

Point an OpenAI client (pip install openai, not installed with M*) at http://<host>:<port>/v1.
  • api_key can be any string unless the server sets a key (API key); the client sends it as Authorization: Bearer <key>.
  • The model field is read only when the deployment serves LoRA adapters, where it names one (LoRA adapters).
  • The routes a model serves are in the OpenAI coverage table. A route the model does not serve answers 404; use /generate or the SDK for it.
  • A field that is not an OpenAI field (top_k, repetition_penalty, a model’s own knob) goes in extra_body and reaches the model as model_kwargs (Generation parameters).
  • Media references (image_url parts, a video route’s image or video) are data URLs. An http(s) URL is fetched only when the server sets MSTAR_ALLOW_REMOTE=1.
  • Image and video results come back inline as b64_json; response_format: "url" is refused.

Chat

POST /v1/chat/completions, streamed (server-sent events) or not.
  • Refused with a 400 when set (0, false or empty counts as unset): n or best_of above 1, stop, stop_token_ids, logprobs, top_logprobs, logit_bias, presence_penalty, frequency_penalty, and a response_format other than {"type": "text"}.
  • Tool calling is refused: a non-empty tools (or functions) unless tool_choice (or function_call) is "none", a tool_choice of "required", or a named function. An empty tools and tool_choice: "auto" are accepted.
  • parallel_tool_calls, user, store, metadata and service_tier are accepted and change nothing.
  • stream_options: {"include_usage": true} ends a stream with one chunk whose choices is empty and which carries usage.
  • On the Qwen3.5-family adapters (qwen3_5_*, qwen3_8_27b, muse_glimmer, phi4mm) and on cosmos3_edge and cosmos3_edge_droid, each chat_template_kwargs key is read as a flat model_kwargs key, and a flat key sent beside it wins. extra_body={"chat_template_kwargs": {"enable_thinking": False}} turns off Qwen’s <think> block.
  • qwen3_omni also speaks when modalities includes "audio". audio.format is wav (the default) or pcm16, or mp3, flac and opus with mstar-ai[audio] installed; a stream sends pcm16.

Speech

POST /v1/audio/speech takes input, voice, response_format, speed and stream.
  • response_format is wav (the default) or pcm, and with mstar-ai[audio] also mp3, flac and opus (opus only at 8, 12, 16, 24 or 48 kHz output). A stream is wav or pcm.
  • A request streams with stream: true or with OpenAI’s stream_format: "audio" sends the bytes as they are made, "sse" sends speech.audio.delta events and then speech.audio.done.
  • Orpheus, Qwen3-TTS, Fish S2 Pro and CosyVoice3 split a long input into sentences, synthesized as ordered requests that run ahead of playback (at most 32 pieces). sentence_chunking: true or false in extra_body turns this on or off for one request.
  • On qwen3_omni the route returns the audio of the model’s reply to input, not a reading of input.
GET /v1/audio/voices returns {"voices": [{"id", "name"}], "default_voice"}. kokoro, orpheus and cosyvoice3 (when its voices directory exists) publish a list; other speech models answer 404.

Transcription

POST /v1/audio/transcriptions takes a multipart file plus optional fields. Use language to specify the language, temperature to set the sampling temperature, and stream for transcript.text.delta events. Whisper uses prompt as decoder context and Qwen3-ASR uses it as system-turn context. Both receive it as initial_prompt. Higgs Audio receives the prompt as its text instruction. The Canary, Canary-Qwen, Parakeet and Nemotron ASR adapters drop the prompt. Omnilingual ASR ignores it. response_format defaults to json. Other formats are text, verbose_json, srt and vtt. Leave timestamp_granularities[] unset by default. On Whisper, a timed format requests segment timestamps and word requests word timestamps. Canary, Canary-Qwen, Parakeet and Nemotron ASR reject an explicit granularity with HTTP 400. An upload longer than the model’s clip is cut into windows at quiet points, and the windows run as parallel requests. Upload audio that decodes past 30 minutes is refused. In extra_body, window_seconds (5 up to the clip) sets the window length for one request, and long_form: "sequential" runs the windows in order, passing each one the transcript so far as initial_prompt on a model that reads it. Per-model language and timestamp support is in Speech recognition. For Whisper, set task=translate for English output. For Canary, set language to the source language, target_language to the translation target and punctuation to control punctuation.

Realtime

WS /v1/realtime speaks OpenAI’s Realtime events; a model without the requested intent closes the socket with code 1008.

Conversation

With no intent, a full-duplex model (nemotron_duplex, see Nemotron VoiceChat) holds a conversation in OpenAI’s GA events.
  • The call is one engine request, opened by the first append (input_audio_buffer.append, or conversation.item.create with input_audio parts), with the session’s instructions as its prompt. Instructions, formats and voice are fixed from then on.
  • audio.input.format and audio.output.format are {"type": "audio/pcm", "rate": N} (24 kHz when left out; 8, 11.025, 16, 22.05, 32, 44.1 and 48 kHz too), {"type": "audio/pcmu"} or {"type": "audio/pcma"}. One append holds at most 300 s.
  • The model decides when to speak. turn_detection server_vad and semantic_vad are accepted and their knobs unused; null, or create_response or interrupt_response false, are refused.
  • When the client’s audio falls behind real time (a muted mic), the server appends silence for it, at most 30 s per pause, counted against the call’s length.
  • Each reply is one response, response.created to response.done, with response.output_audio.delta and response.output_audio_transcript.delta between. One response is in progress at a time.
  • response.create, response.cancel, output_audio_buffer.clear and the item-editing events get an unsupported error, and the call goes on. Input transcription and tools are not supported. voice is the model’s own (Aria).
  • When the call ends, the server sends error, closes an open reply with response.done, and closes the socket.

Transcription

?intent=transcription streams speech-to-text with partial results on qwen3_asr and qwen3_asr_realtime, in OpenAI’s transcription-session events.
  • In: transcription_session.update, input_audio_buffer.append (base64 audio), input_audio_buffer.commit (end of utterance) and input_audio_buffer.clear. Out: conversation.item.input_audio_transcription.delta (append-only text), mstar.transcription.partial (the whole current hypothesis, unstable tail included) and conversation.item.input_audio_transcription.completed.
  • input_audio_format is "pcm16" (PCM16 at 16 kHz, the default; OpenAI reads it as 24 kHz, so a 24 kHz client declares {"type": "audio/pcm", "rate": 24000}), "g711_ulaw", "g711_alaw", or a GA format object at the rates above.
  • Every chunk_seconds (default 2, at least 0.5) of new audio, the session transcribes everything heard so far, continuing from the previous hypothesis minus its last unfixed_tokens. Set chunk_seconds, unfixed_chunks and unfixed_tokens under session.mstar.
  • An item holds at most 300 s of audio; commit before then.
  • turn_detection null (the default) leaves the commit to the client. {"type": "server_vad"} lets the server end turns with Silero VAD (threshold 0.5, prefix_padding_ms 300, silence_duration_ms 500). {"type": "semantic_vad", "eagerness": "auto"} asks Pipecat’s Smart Turn v3 at each pause (low, medium, high or auto). Both send input_audio_buffer.speech_started, speech_stopped and committed.
  • server_vad needs mstar-ai[vad], or onnxruntime and MSTAR_SILERO_VAD_PATH set to a silero_vad.onnx. semantic_vad needs mstar-ai[vad] and weights at MSTAR_SMART_TURN_PATH or in the Hugging Face cache (hf download pipecat-ai/smart-turn-v3 smart-turn-v3.2-cpu.onnx). Weights are never downloaded; without them the update gets an error and the session keeps its settings.

Images

  • POST /v1/images/generations takes prompt, size (WxH), n and seed. n runs as n requests batched together, up to MSTAR_MAX_IMAGES_PER_REQUEST (default 10). With a seed, image i uses seed + i.
  • POST /v1/images/edits is multipart: one image (or image[]), prompt, optional size, and other fields passed to the model. The route edits one whole image. An inpainting mask, a second image or n above 1 receives a 400. bagel, flux2_klein and flux2_klein_9b edit; other image models refuse it.
  • BAGEL, FLUX.2 klein and Z-Image read output_format (png default, jpeg, webp), output_compression (0 to 100) and png_compress_level (0 to 9, default 1) from extra_body.

Videos

POST /v1/videos/generations takes JSON: prompt, size (WxH), seed, num_frames, fps, image (image-to-video), video (video-to-video), n (1 only) and response_format (b64_json only); model knobs such as guidance_scale go in extra_body. The reply is {"created", "data": [{"b64_json"}]} holding an mp4.
  • ltx2_5 and minimax_h3 mux their generated audio into the mp4; audio: false in extra_body returns video alone.
  • wan22 takes image but not video. ltx2_5 takes neither. minimax_h3 takes image as the first frame and last_image in extra_body as the last, at 24 fps only.
  • A Cosmos3 deployment with windowed video (configs/cosmos3_nano_ar.yaml, configs/cosmos3_edge.yaml) takes stream_video: true in extra_body and answers NDJSON: one {"modality", "data", "metadata"} line per window with a running metadata.index, then a done line.

LoRA adapters

POST /v1/load_lora_adapter ({"lora_name", "lora_path"}) and POST /v1/unload_lora_adapter ({"lora_name"}) change the served adapters while the server runs. They work only on a deployment whose resources: lora: block sets runtime_updates: true, and answer 404 otherwise. GET /v1/models lists the served model and each adapter, with parent naming the base model. See LoRA adapters.

Native /generate

POST /generate takes form fields, as multipart/form-data (needed for file uploads) or application/x-www-form-urlencoded; any other content type is a 400. It returns one JSON document or an NDJSON stream. A client request_id is at most 128 characters from [A-Za-z0-9._:-]; any other is refused with 400 (on /generate/ws, with the in-band error below). An empty request_id counts as none: the server mints a fresh one. A non-streaming response groups outputs by modality, each payload base64-encoded:
A streaming response is application/x-ndjson: one {"modality", "data", "metadata"} object per line as chunks arrive, data base64-encoded. A request that fails after its stream has started ends it with one chunk of modality error (the HTTP status in metadata.status); nothing follows it. A client that sends Accept: application/vnd.mstar.frames receives length-framed binary chunks instead, which skips the base64 pass on multi-megabyte video_frame payloads. A server without the framing keeps answering NDJSON, so a client parses by the response Content-Type. Streamed text chunks (/generate and /generate/ws) are the raw UTF-8 bytes of each token, so one character can be split across two chunks. Decode the stream incrementally (codecs.getincrementaldecoder("utf-8"), as the Python SDK does) or join the chunks before decoding.

WebSocket /generate/ws

/generate/ws streams replies over a persistent WebSocket, for control loops that cannot afford an HTTP round trip per step (robot policies, streaming world models). The start fields are text, files as [{"name": ..., "data": ...}], input_modalities, output_modalities, model_kwargs, and request_id. Send modality lists and the model_kwargs object as native values. It always streams and has no streaming field. Send a JSON text frame (data base64) or a msgpack binary frame (data raw bytes); a field sent as null counts as absent. Replies use the same encoding as the message: one frame per result chunk, {"request_id", "modality", "data", "metadata"}, then {"request_id", "finish": true}. A rejected message answers {"request_id", "error": ..., "status": ...} with the HTTP status /generate would have returned (409 for a request_id still in flight), and the socket stays open; a request that fails after it was accepted ends the same way, and no finish follows. Messages may be pipelined: send the next observation before the current action chunk has returned, and the request_id tells the replies apart. Pipelined messages are submitted in order, so of two under one request_id the later one gets the 409; replies may interleave. Closing the socket aborts whatever is still in flight. A message larger than ws_max_message_mb (by default MSTAR_MAX_BODY_MB) closes the socket with 1009. mstar-server does not compress WebSocket frames. The deprecated Python frontend (--python-frontend) negotiates per-message deflate unless the config sets ws_per_message_deflate: false, as the Nemotron VoiceChat configs do. It parses a message on its event loop, or in a helper process past 1 MiB of JSON or 32 MiB of msgpack, and a large message holds up its other requests, so keep bulk data in files there.
The chunk (32 rows), the fps and the domain come from the checkpoint, and the reply holds the predicted rows after the state, in the robot’s values. examples/cosmos3_action_ws_client.py is a complete openpi-style client for mstar serve cosmos3_droid: it builds the observation the way NVIDIA’s RoboLab server does for the DROID policies and reports the loop rate and latency.

Live input

A model that listens while it runs (a full-duplex speech model, or a TTS model fed text as it is written) can keep a request’s input open after the opening message. An opening with "end_input": false opens a live call, and may then carry no media at all. An append feeds the running request more input, in order, while its output keeps streaming back:
An append carries a record. "append": [files] is short for "append": {"files": [files]}.
  • Every field of the record is optional, but an append needs text, files, model_kwargs or end_input.
  • stream names the client stream a file is for. Without it the model decides, and a name the model doesn’t have is rejected.
  • An append’s model_kwargs reach only the model’s process_stream_chunk, so they mean what that model reads from them. The opening message’s model_kwargs, such as its sampling settings, still hold for the request. An append’s model_kwargs count toward the call’s max_call_input_mb, as JSON.
  • Text, files and model_kwargs go inside the record. Beside it they are rejected.
  • A message is an append if it carries append at its top level, or end_input (true or a list) and no text or files.
{"request_id", "end_input": true} ends the input, alone or on an append, and the request then finishes as usual. An opening without end_input is one-shot, as a request over /generate is. A model may take several client streams, such as audio and video. end_input may then name the ones it ends as a list ("end_input": ["video_in"], on the opening too), and the call’s input has ended once every stream has. The opening message’s files may name a stream too (an unknown name gets a 400), but the model routes them itself. A live call needs a request_id. Only the socket that opened it can append to it, and closing the socket aborts it. Input resets the request timeout. Models without live input ignore end_input and reject an append. A model that declares its audio frame (Nemotron VoiceChat: 80 ms, 1280 samples at 16 kHz) takes a live call’s audio in whole frames: each whole frame of an append is a step of its own, and the rest waits for the next append or the stream’s end, so appends of whole frames add no wait.

openpi WebSocket /

A deployment whose config has an openpi: block (configs/pi05_droid.yaml, served with mstar serve pi05 --config configs/pi05_droid.yaml) also serves openpi’s policy protocol at the server’s root, so robot clients written against openpi’s openpi_client.WebsocketClientPolicy connect unchanged. Those include openpi’s DROID example and its examples/simple_client --env DROID. The protocol:
  • On connect the server sends one msgpack frame, the block’s metadata ({} by default).
  • The client then sends one observation and waits for one reply, and repeats. Arrays travel as openpi_client.msgpack_numpy encodes them, so camera frames arrive as raw pixels and reach the model with no PNG and no file in between.
  • The reply is {"actions": float32 [H, action_dims], "server_timing": {"infer_ms", "prev_total_ms"}}. For pi05_droid that is (15, 8), as openpi’s own pi05_droid server returns. The DROID example’s assert shape == (10, 8) was written for pi0-FAST.
  • A call that fails is answered with a text frame holding the error, which the client raises, and the socket closes with 1011.
  • An observation may carry seed (an int), which openpi does not have. It pins the call’s noise, as seed in /generate’s model_kwargs does. Without it each call gets a fresh seed.
On a server with the block, GET /healthz answers OK without a key, as openpi’s server does, and with --api-key the handshake takes Authorization: Api-Key <key> (what the client sends for api_key) as well as Bearer. Every other route still takes only Bearer. A server without the block has none of this: it refuses the handshake and answers 404 on /healthz. Both frontends serve this route; the Dynamo worker serves without it. The server caps a message at ws_max_message_mb (by default MSTAR_MAX_BODY_MB), which openpi_client does not. A larger observation closes the socket with 1009 and no error frame, so raise the cap for robots that send several raw high-resolution cameras.

Generation parameters

The shared sampling parameters have the meanings below on models that use them. The server checks their ranges at intake and returns HTTP 400 for an invalid value, including on streaming requests. Models can narrow those ranges. CosyVoice3 accepts top_k from 1 to 128 and nonnegative seeds. Chatterbox caps temperature at 5 and repetition_penalty at 2. Model guides A string that spells a number is read as that number: "0.7" or " 0.7 " for a real-valued knob, "5" or "5.0" for an integer one ("5e0", "5.5" and "0x1" are not integers and are a 400). Booleans stay strict: "false" is not a boolean, and true is not a number. null is the same as leaving the knob out: the model’s default applies, which is the checkpoint’s own generation_config.json value where it ships one. BAGEL and Orpheus are the exception: their files are the backbone’s chat presets, so only their do_sample: false is read and the models’ own defaults stay. MiniCPM-o keeps upstream chat’s defaults over its file. Multi-stage models take a stage prefix (talker_temperature, code_predictor_top_k) with the same rules; an unprefixed knob sets the primary stage (the thinker of Qwen3-Omni, the talker of Qwen3-TTS), and a prefixed one wins over it for its stage. Each model defines its other request fields. A request can succeed with an unknown key such as temprature. Models that declare the keys they read log ignored names the first time they see that set of names. LTX-2.5 also accepts num_inference_steps and guidance_scale and warns that its fixed schedule ignores them.