Reference · HTTP API

API surface

Rapid-MLX exposes an OpenAI-shaped HTTP API at http://localhost:8000/v1 by default. If a tool speaks OpenAI, it speaks Rapid-MLX. Point the base URL at your local server and pass any non-empty API key.

Live OpenAPI schema. Every running server exposes its own machine-readable schema at GET /openapi.json and an interactive Swagger UI at GET /docs. The list below is the human-readable summary; the JSON schema is the source of truth.

Endpoints

methodpathdescription
GET/v1/modelsList available models — alias, parser bindings, capability flags.
POST/v1/chat/completionsChat completions — tools, vision, streaming, reasoning_content all supported.
POST/v1/responsesOpenAI Responses API — streaming with item-by-item events, reasoning items, tool calls.
POST/v1/messagesAnthropic Messages API — the surface Claude Code targets; tools, streaming, and reasoning content all supported.
POST/v1/messages/count_tokensAnthropic token-count endpoint for the Messages API.
POST/v1/completionsLegacy text completion (no chat template).
POST/v1/embeddingsEmbeddings — requires the [embeddings] install extra and an embedding alias (e.g. embeddinggemma-300m-6bit).
POST/v1/audio/speechText-to-speech (Kokoro, Qwen3-TTS, IndexTTS, Chatterbox, VibeVoice, VoxCPM, F5-TTS, Dia) — requires the [audio] extra. Cloning models take a ref_audio extension field; Qwen3-TTS Base and F5-TTS also need ref_text.
POST/v1/audio/transcriptionsSpeech-to-text (Whisper, Parakeet, SenseVoice) — requires the [audio] extra. Returns word-level timestamps. Passing a text field switches to forced alignment against that transcript instead of recognition.
POST/v1/audio/musicText-to-music / SFX — requires the [audio] extra.
POST/v1/videosCreate a video-generation job (Wan, CogVideoX-Fun, LTX-2.3) — requires the [video] extra, ffmpeg, and Python 3.11+. Asynchronous: returns a job id.
GET/v1/videos/{id}Poll a video job's status.
GET/v1/videos/capabilitiesWhat the loaded video model accepts — modes, native fps, size rule and frame-count rule. Same contract the route validates against.
GET/v1/videos/{id}/contentDownload the finished MP4.
GET/healthHealth probe (also /healthz, /readyz, /livez).
GET/metricsPrometheus-format counters and histograms.
GET/openapi.jsonOpenAPI 3 schema for everything above.
GET/docsSwagger UI (interactive).

What's the same as OpenAI

What is on by default in 0.9

Two features flipped from opt-in to on-by-default in 0.9 because they help every multi-user workload and cost nothing on the single-user path.

Where it diverges

Examples

List models

$ curl http://localhost:8000/v1/models | jq .data[0]
{
  "id": "qwen3.5-4b-4bit",
  "object": "model",
  "tool_call_parser": "hermes",
  "reasoning_parser": "qwen3",
  "is_hybrid": false,
  "is_moe": false,
  "supports_spec_decode": false
}

Streaming chat completion

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="x")
stream = client.chat.completions.create(
    model="qwen3.5-4b-4bit",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Embeddings

# first install: pip install 'rapid-mlx[embeddings]'
$ rapid-mlx serve embeddinggemma-300m-6bit --port 8001 &
$ curl http://localhost:8001/v1/embeddings \
    -H "Content-Type: application/json" \
    -d '{"model": "embeddinggemma-300m-6bit", "input": "ping"}'

Long inputs. Before 0.11.8 the tokenizer was pinned at 512 tokens, so anything longer came back HTTP 200, correctly shaped, and quietly missing its tail — which degrades a vector index with no signal. The limit is now derived from the model (config.max_position_embeddings, else tokenizer.model_max_length), so a 32K-context embedder like Qwen3-Embedding-4B uses its real ceiling. Overflow is never silent: it either logs and increments rapid_mlx_embedding_truncations_total on /metrics, or — with --embedding-overflow-policy error — returns a structured 400:

$ rapid-mlx serve embeddinggemma-300m-6bit --port 8001 \
    --embedding-max-length 2048 --embedding-overflow-policy error

# a 3,000-token input then returns, instead of a silently short vector:
{"error": {"code": "input_too_long", "message": "…observed vs allowed tokens…"}}

Audio (TTS)

# first install: pip install 'rapid-mlx[audio]'
$ rapid-mlx serve kokoro-tts --port 8002 &
$ curl http://localhost:8002/v1/audio/speech \
    -H "Content-Type: application/json" \
    -d '{"model": "kokoro-tts", "voice": "af_heart", "input": "hello"}' \
    -o speech.wav

Where to next

For the full request/response field reference, hit the live Swagger UI at http://localhost:8000/docs on your own server — it stays in sync with the running build, including any flags wired up by recent releases. The engine README covers CLI flags, environment variables, and the rapid-mlx launch <client> bootstrap targets.