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).Nonevalues are dropped. tts(text, *, voice=None, reference_audio=None, **kw)clones a voice fromreference_audio(a path, bytes or a(filename, bytes)tuple) on models that take a reference clip.examples/sdk_tts_qwen3.pyshows it forqwen3_tts_base.api_key="...", orMSTAR_API_KEYin the client’s environment, sends the server’s key as a bearer token (API key).session=takes your ownrequests.Session.enable_nvtx=Trueadds NVTX ranges around the client’s reads and decodes for a CUDA profile (it imports torch).- A non-streaming call returns a
GenerateResultwith.request_id,.text,.images,.audioand.raw. Video (mp4) and action (float32) outputs land only in.raw, a list of{"modality", "bytes", "metadata"}entries. Request them withstream=False: streamed, they arrive asTextChunks decoded witherrors="replace", which corrupts the bytes.
OpenAI-compatible API
Point an OpenAI client (pip install openai, not installed with M*) at http://<host>:<port>/v1.
api_keycan be any string unless the server sets a key (API key); the client sends it asAuthorization: Bearer <key>.- The
modelfield 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
/generateor the SDK for it. - A field that is not an OpenAI field (
top_k,repetition_penalty, a model’s own knob) goes inextra_bodyand reaches the model asmodel_kwargs(Generation parameters). - Media references (
image_urlparts, a video route’simageorvideo) are data URLs. Anhttp(s)URL is fetched only when the server setsMSTAR_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,falseor empty counts as unset):norbest_ofabove 1,stop,stop_token_ids,logprobs,top_logprobs,logit_bias,presence_penalty,frequency_penalty, and aresponse_formatother than{"type": "text"}. - Tool calling is refused: a non-empty
tools(orfunctions) unlesstool_choice(orfunction_call) is"none", atool_choiceof"required", or a named function. An emptytoolsandtool_choice: "auto"are accepted. parallel_tool_calls,user,store,metadataandservice_tierare accepted and change nothing.stream_options: {"include_usage": true}ends a stream with one chunk whosechoicesis empty and which carriesusage.- On the Qwen3.5-family adapters (
qwen3_5_*,qwen3_8_27b,muse_glimmer,phi4mm) and oncosmos3_edgeandcosmos3_edge_droid, eachchat_template_kwargskey is read as a flatmodel_kwargskey, and a flat key sent beside it wins.extra_body={"chat_template_kwargs": {"enable_thinking": False}}turns off Qwen’s<think>block. qwen3_omnialso speaks whenmodalitiesincludes"audio".audio.formatiswav(the default) orpcm16, ormp3,flacandopuswithmstar-ai[audio]installed; a stream sendspcm16.
Speech
POST /v1/audio/speech takes input, voice, response_format, speed and stream.
response_formatiswav(the default) orpcm, and withmstar-ai[audio]alsomp3,flacandopus(opusonly at 8, 12, 16, 24 or 48 kHz output). A stream iswavorpcm.- A request streams with
stream: trueor with OpenAI’sstream_format:"audio"sends the bytes as they are made,"sse"sendsspeech.audio.deltaevents and thenspeech.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: trueorfalseinextra_bodyturns this on or off for one request. - On
qwen3_omnithe route returns the audio of the model’s reply toinput, not a reading ofinput.
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 nointent, 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, orconversation.item.createwithinput_audioparts), with the session’sinstructionsas its prompt. Instructions, formats and voice are fixed from then on. audio.input.formatandaudio.output.formatare{"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_detectionserver_vadandsemantic_vadare accepted and their knobs unused; null, orcreate_responseorinterrupt_responsefalse, 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.createdtoresponse.done, withresponse.output_audio.deltaandresponse.output_audio_transcript.deltabetween. One response is in progress at a time. response.create,response.cancel,output_audio_buffer.clearand the item-editing events get anunsupportederror, and the call goes on. Input transcription and tools are not supported.voiceis the model’s own (Aria).- When the call ends, the server sends
error, closes an open reply withresponse.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) andinput_audio_buffer.clear. Out:conversation.item.input_audio_transcription.delta(append-only text),mstar.transcription.partial(the whole current hypothesis, unstable tail included) andconversation.item.input_audio_transcription.completed. input_audio_formatis"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 lastunfixed_tokens. Setchunk_seconds,unfixed_chunksandunfixed_tokensundersession.mstar. - An item holds at most 300 s of audio; commit before then.
turn_detectionnull (the default) leaves the commit to the client.{"type": "server_vad"}lets the server end turns with Silero VAD (threshold0.5,prefix_padding_ms300,silence_duration_ms500).{"type": "semantic_vad", "eagerness": "auto"}asks Pipecat’s Smart Turn v3 at each pause (low,medium,highorauto). Both sendinput_audio_buffer.speech_started,speech_stoppedandcommitted.server_vadneedsmstar-ai[vad], oronnxruntimeandMSTAR_SILERO_VAD_PATHset to asilero_vad.onnx.semantic_vadneedsmstar-ai[vad]and weights atMSTAR_SMART_TURN_PATHor 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 anerrorand the session keeps its settings.
Images
POST /v1/images/generationstakesprompt,size(WxH),nandseed.nruns asnrequests batched together, up toMSTAR_MAX_IMAGES_PER_REQUEST(default 10). With a seed, imageiusesseed + i.POST /v1/images/editsis multipart: oneimage(orimage[]),prompt, optionalsize, and other fields passed to the model. The route edits one whole image. An inpaintingmask, a second image ornabove 1 receives a 400.bagel,flux2_kleinandflux2_klein_9bedit; other image models refuse it.- BAGEL, FLUX.2 klein and Z-Image read
output_format(pngdefault,jpeg,webp),output_compression(0 to 100) andpng_compress_level(0 to 9, default 1) fromextra_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_5andminimax_h3mux their generated audio into the mp4;audio: falseinextra_bodyreturns video alone.wan22takesimagebut notvideo.ltx2_5takes neither.minimax_h3takesimageas the first frame andlast_imageinextra_bodyas the last, at 24 fps only.- A Cosmos3 deployment with windowed video (
configs/cosmos3_nano_ar.yaml,configs/cosmos3_edge.yaml) takesstream_video: trueinextra_bodyand answers NDJSON: one{"modality", "data", "metadata"}line per window with a runningmetadata.index, then adoneline.
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:
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.
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:
"append": [files] is short for "append": {"files": [files]}.
- Every field of the record is optional, but an append needs text, files,
model_kwargsorend_input. streamnames 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_kwargsreach only the model’sprocess_stream_chunk, so they mean what that model reads from them. The opening message’smodel_kwargs, such as its sampling settings, still hold for the request. An append’smodel_kwargscount toward the call’smax_call_input_mb, as JSON. - Text, files and
model_kwargsgo inside the record. Beside it they are rejected. - A message is an append if it carries
appendat its top level, orend_input(true or a list) and notextorfiles.
{"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_numpyencodes 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"}}. Forpi05_droidthat is(15, 8), as openpi’s ownpi05_droidserver returns. The DROID example’sassert 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, asseedin/generate’smodel_kwargsdoes. Without it each call gets a fresh seed.
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 acceptstop_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.