mstar.api_server.openai.adapters#
Per-model translation between OpenAI-shaped requests and mstar’s request path.
The OpenAI endpoints are model-agnostic; everything model-specific lives here.
An adapter translates an OpenAI request into SubmitArgs (the arguments
APIServer.submit_request expects) and declares which OpenAI surfaces the
model supports. Output chunks are translated back to OpenAI shapes by the
serving handlers, which are generic across models.
model_kwargs is non-standardized across models, so each adapter maps the
standard OpenAI fields (temperature, top_p, max_tokens, seed,
voice, modalities …) onto the keys its model actually honors (see
_apply_sampling()). Knobs that aren’t OpenAI-standard (top_k,
repetition_penalty, or model-namespaced keys like talker_top_p) are not
first-class fields — pass them via the OpenAI client’s extra_body and they
flow through verbatim as model_kwargs (see _passthrough()).
Models whose outputs have no OpenAI-standard representation (robot actions from
Pi0.5, world-model latents from V-JEPA 2) intentionally have no adapter:
they are served only through the native /generate endpoint and the Python
SDK, and /v1/* returns 404 for them (they do not fall back to chat). New
OpenAI-capable models opt in by adding an adapter and registering it in
ADAPTER_REGISTRY.
Functions
|
Flatten OpenAI chat |
|
Classes
BAGEL: text chat (text out) + text-to-image / image editing. |
|
Base adapter. |
|
Orpheus: text-to-speech (audio out only). |
|
Qwen3-Omni: multimodal chat (text, optionally + speech) and TTS. |
|
|
- class mstar.api_server.openai.adapters.BagelAdapter[source]#
Bases:
OpenAIAdapterBAGEL: text chat (text out) + text-to-image / image editing.
BAGEL’s
get_sampling_configreads the model config, so per-requesttemperature/top_pare not honored;max_output_tokensandseedare.- chat_to_request(req, upload_dir)[source]#
- Parameters:
req (ChatCompletionRequest)
upload_dir (Path)
- Return type:
- image_to_request(req, upload_dir)[source]#
- Parameters:
req (ImageGenerationRequest)
upload_dir (Path)
- Return type:
- class mstar.api_server.openai.adapters.OpenAIAdapter[source]#
Bases:
objectBase adapter. A model subclasses this and implements the surfaces it supports; an unimplemented surface raises and the endpoint returns 404. Models with no OpenAI-standard output have no adapter (see the module docstring) and are reached only via
/generate/ the SDK.- chat_to_request(req, upload_dir)[source]#
- Parameters:
req (ChatCompletionRequest)
upload_dir (Path)
- Return type:
- image_to_request(req, upload_dir)[source]#
- Parameters:
req (ImageGenerationRequest)
upload_dir (Path)
- Return type:
- speech_to_request(req, upload_dir)[source]#
- Parameters:
req (SpeechRequest)
upload_dir (Path)
- Return type:
- class mstar.api_server.openai.adapters.OrpheusAdapter[source]#
Bases:
OpenAIAdapterOrpheus: text-to-speech (audio out only). Honors temperature/top_p/seed (its
get_sampling_configreads model_kwargs).- speech_to_request(req, upload_dir)[source]#
- Parameters:
req (SpeechRequest)
upload_dir (Path)
- Return type:
- class mstar.api_server.openai.adapters.Qwen3OmniAdapter[source]#
Bases:
OpenAIAdapterQwen3-Omni: multimodal chat (text, optionally + speech) and TTS.
Sampling is split across two stages: the Thinker (text) takes
thinker_*keys, the Talker (speech)talker_*. The other Talker knobs (talker_top_k,talker_repetition_penalty) aren’t OpenAI fields — pass them viaextra_body.- chat_to_request(req, upload_dir)[source]#
- Parameters:
req (ChatCompletionRequest)
upload_dir (Path)
- Return type:
- speech_to_request(req, upload_dir)[source]#
- Parameters:
req (SpeechRequest)
upload_dir (Path)
- Return type:
- class mstar.api_server.openai.adapters.SubmitArgs(text: 'str | None' = None, file_paths: 'dict[str, list[str]] | None'=None, input_modalities: 'list[str]' = <factory>, output_modalities: 'list[str]' = <factory>, model_kwargs: 'dict' = <factory>)[source]#
Bases:
object- Parameters:
- mstar.api_server.openai.adapters.flatten_messages(messages, upload_dir, allow_remote=True)[source]#
Flatten OpenAI chat
messagesinto (text, file_paths, input_modalities).Text parts across all messages are concatenated (newline-joined). Image / audio / video content parts are persisted under
upload_dirand grouped by modality. (Multi-turn role structure is flattened — a v1 simplification; the models here apply their own prompt formatting inprocess_prompt.)
- mstar.api_server.openai.adapters.get_adapter(model_name)[source]#
- Parameters:
model_name (str)
- Return type:
OpenAIAdapter | None