# Yunshu

Local LLM / VLM inference engine for Apple Silicon.

- [Audio](/console/docs-assets/en/api/audio.md): OpenAI-style speech-to-text, translation and text-to-speech endpoints, plus local custom voices, served by mlx-audio models.
- [Batches](/console/docs-assets/en/api/batches.md): The OpenAI Batch API, backed by a single loopback worker that replays each JSONL line against this same server and resumes after a restart.
- [Chat completions](/console/docs-assets/en/api/chat-completions.md): The OpenAI Chat Completions endpoint, with tools, structured output, logprobs, reasoning, image/audio/video input and streaming, plus the legacy text completions endpoint.
- [Decisions](/console/docs-assets/en/api/decisions.md): Typed questions (yes/no, pick one, ordinal score) answered with probabilities from a decision-head model in a single forward pass, with no generated text.
- [Embeddings](/console/docs-assets/en/api/embeddings.md): The OpenAI embeddings endpoint for text and multimodal embedding models, plus the vLLM-style pooling endpoint that returns raw pooled vectors.
- [Evals](/console/docs-assets/en/api/evals.md): The OpenAI Evals API on a local store - define graders, run them over JSONL or stored completions, and read per-item results.
- [Extensions](/console/docs-assets/en/api/extensions.md): Everything Yunshu adds on top of the OpenAI, Anthropic and Ollama APIs - status, warmup, cancellation, per-response stats, a multiplexed WebSocket, native speech, and System One.
- [Files](/console/docs-assets/en/api/files.md): A local file store that speaks both the OpenAI Files API and the Anthropic Files API on the same /v1/files paths.
- [Images and OCR](/console/docs-assets/en/api/images.md): OpenAI-style image generation, edits and variations from a local diffusion model, plus a Yunshu OCR endpoint for extracting text from images.
- [MCP](/console/docs-assets/en/api/mcp.md): Yunshu as an MCP server (JSON-RPC over HTTP) that exposes generation, speech and image tools, plus routes that report the MCP client pool.
- [Messages](/console/docs-assets/en/api/messages.md): Anthropic Messages API with tools, thinking, images, documents with citations, token counting and message batches.
- [Models](/console/docs-assets/en/api/models.md): List and inspect served models with cards that speak the OpenAI, Anthropic, OpenRouter, vLLM and LM Studio dialects at once, and load or unload models in multi-model mode.
- [OCR](/console/docs-assets/en/api/ocr.md): POST /v1/ocr turns an uploaded image into text with an OCR model or, when none is loaded, any loaded vision-language model.
- [Ollama](/console/docs-assets/en/api/ollama.md): Ollama-compatible /api routes so Ollama clients and SDKs can talk to Yunshu, with a precise list of what is real and what is not.
- [Operations](/console/docs-assets/en/api/operations.md): Health probes, Prometheus metrics, live request inspection and cancellation, server properties, interactive docs, rate limiting and logging.
- [API overview](/console/docs-assets/en/api/overview.md): Base URLs, the dialects Yunshu serves, authentication, how the model field is resolved, error shapes, request ids and the route map for the whole API.
- [Realtime](/console/docs-assets/en/api/realtime.md): The OpenAI Realtime protocol over WebSocket (GA and beta schemas) and WebRTC, with ephemeral client secrets, text and voice turns, and tool calls.
- [Rerank and scoring](/console/docs-assets/en/api/rerank.md): Rerank documents against a query, score text pairs and classify text with embedding models, cross-encoder rerankers and sequence-classifier checkpoints.
- [Responses](/console/docs-assets/en/api/responses.md): OpenAI Responses API with stored responses, background mode, conversations, compaction, client tools and WebSocket mode.
- [Server tools](/console/docs-assets/en/api/server-tools.md): Web search, web fetch and the MCP connector, executed by Yunshu inside the generation loop for Anthropic Messages and OpenAI Responses requests.
- [Stored completions](/console/docs-assets/en/api/stored-completions.md): Keep chat completions on disk with store true, then list, retrieve, label and delete them with the OpenAI stored-completions routes.
- [Tokenization](/console/docs-assets/en/api/tokenization.md): Count and inspect tokens with the vLLM-style tokenize, detokenize and apply-template routes, plus the llama.cpp-style props route.
- [Accuracy alignment](/console/docs-assets/en/developers/accuracy.md): How Yunshu shows that its serving path computes what stock MLX and mlx-vlm compute on the same checkpoint, in three tiers: logit divergence, greedy divergence and paired task evaluation.
- [Agent compatibility](/console/docs-assets/en/developers/agent-compat.md): What Claude Code, Codex CLI and opencode actually call, how Yunshu serves each request, and the scripts that re-earn those claims against the newest CLIs.
- [Agentic coding benchmark](/console/docs-assets/en/developers/agentic-bench.md): How Yunshu is measured under real coding-agent loops (Claude Code, Codex CLI, opencode) with hidden tests, and how to run, repeat and extend the benchmark.
- [API parity matrix](/console/docs-assets/en/developers/api-parity.md): One row per request or response feature of the OpenAI and Anthropic APIs we serve, one column per route and stream mode; executable probes keep every engaged cell honest and every gap counted.
- [Architecture](/console/docs-assets/en/developers/architecture.md): How a request moves through the gateway and the engine, the two serving paths, the prefix cache, speculative decoding, batch-invariant kernels and constrained decoding.
- [Auxiliary scheduling](/console/docs-assets/en/developers/auxiliary-scheduling.md): How captured client side requests (opencode title generation) yield to interactive agent turns, how prefill work is ordered, and what stays identical in the output.
- [Contributing](/console/docs-assets/en/developers/contributing.md): Set up a development checkout, run lint and tests, follow the settings registry rule, and open a pull request.
- [Hardware validation](/console/docs-assets/en/developers/hardware-validation.md): The plan for validating Yunshu across Apple Silicon generations, and the M5 Max hardware map: what each unit measured, what Yunshu uses of it and which ideas survived a roofline check.
- [Retrieval and prior-art formats](/console/docs-assets/en/developers/prior-art-formats.md): Which published embedding, reranker and classifier checkpoint formats Yunshu loads, which loader each one uses, and how the loaders are checked against their upstream implementations.
- [Release gate](/console/docs-assets/en/developers/release-gate.md): The checks a Yunshu version must pass before it ships, how the gate tests an installed build, and the readiness checklist for a new user's first hour.
- [Release readiness](/console/docs-assets/en/developers/release-readiness.md): The outward-facing checklist for a release, what is evidence and what is only a capability inventory, and the maintainer procedure summarized from RELEASING.md.
- [Roadmap and proposals](/console/docs-assets/en/developers/roadmap.md): What Yunshu prioritizes, what is out of scope, and the lightweight RFC process for substantial changes.
- [Round driver](/console/docs-assets/en/developers/round-driver.md): The packed-row engine that serves every mlx-vlm model: one forward per step over every decoding row, row-invariant arithmetic, and cost-aware MTP or DFlash drafting for several rows at once.
- [Serve and develop on one machine](/console/docs-assets/en/developers/serve-and-develop.md): How the GPU queue lets a production Yunshu server and development GPU jobs share one Mac, with idle gating, preemption, memory and CPU admission, and measurement-integrity rules.
- [Upstream tracking](/console/docs-assets/en/developers/upstream-tracking.md): How Yunshu records code it took from other projects in vendor.json, the four kinds of dependency on upstream, and how just vendor-check reports what changed.
- [Verification](/console/docs-assets/en/developers/verification.md): How Yunshu checks that an optimization is lossless and not slower, using the yv verify tool, and how accuracy is compared against stock MLX.
- [Console](/console/docs-assets/en/getting-started/console.md): The web console the Yunshu server hosts for watching the engine, managing models and keys, reading logs, trying the API and reading these docs.
- [Install](/console/docs-assets/en/getting-started/install.md): Install Yunshu from PyPI with uv or pip, or with Homebrew, and check the installation with yunshu doctor.
- [Models](/console/docs-assets/en/getting-started/models.md): Where Yunshu keeps and finds models, how to download, list and remove them, and how to serve several models from one directory.
- [Quickstart](/console/docs-assets/en/getting-started/quickstart.md): Download a model, start the server, check readiness and send a first request with curl, the OpenAI SDK or yunshu chat.
- [Service](/console/docs-assets/en/getting-started/service.md): Run Yunshu in the background at login with a per-user launchd agent managed by yunshu service.
- [Coding agents and SDKs](/console/docs-assets/en/guides/agents.md): Point Claude Code, Codex, opencode, Pi and the official OpenAI and Anthropic SDKs at a local Yunshu server, with the launcher or by hand.
- [Authentication, API keys and CORS](/console/docs-assets/en/guides/auth-and-keys.md): How to protect a Yunshu server with a token or per-key quotas, write settings from the API, edit CORS origins, and what the built-in protections do.
- [Benchmarks](/console/docs-assets/en/guides/benchmarks.md): Full 27B comparison run 2026-11-04 to 2026-11-08 on Apple M5 Max, audited study gaps_full_1109. Same numbers as docs/BENCHMARKS.md.
- [CLI reference](/console/docs-assets/en/guides/cli.md): Every yunshu command, subcommand and option, with the global flags, JSON mode and exit codes.
- [Connecting clients](/console/docs-assets/en/guides/clients.md): Point the OpenAI and Anthropic SDKs, curl, Open WebUI and coding agents at a local Yunshu server, and check that the server is healthy.
- [Code execution](/console/docs-assets/en/guides/code-execution.md): Turn on the Anthropic code_execution tool, which runs model-written commands on your Mac inside the sandbox-runtime, and learn its containers, files and limits.
- [Configuration](/console/docs-assets/en/guides/configuration.md): Every YUNSHU_* setting, its type and default, generated from the settings registry.
- [Debugging and observability](/console/docs-assets/en/guides/debugging.md): One switch turns on the debug routes, host telemetry, serve log, audit log, token ids and generation capture; the console then shows every panel and compares the engine's request state with what it displays.
- [Feature index](/console/docs-assets/en/guides/features.md): Every Yunshu feature in one table per area, with its status and the documentation page that covers it.
- [Model support](/console/docs-assets/en/guides/model-support.md): Which model families and modalities Yunshu serves, and which serving path and optional extra each one uses.
- [Multimodal and retrieval endpoints](/console/docs-assets/en/guides/multimodal.md): Which routes serve images, audio, video, speech, Realtime voice, OCR, image generation, embeddings and rerank, which extras they need, and where the limits are.
- [Options that can change output](/console/docs-assets/en/guides/options.md): The opt-in settings whose output is not guaranteed identical to the default path, and the rule that separates them from lossless defaults.
- [Prompt caching](/console/docs-assets/en/guides/prompt-caching.md): How Yunshu reuses the KV cache of a shared prompt prefix, how cache hits show up in usage, and which options control memory, SSD storage and precision.
- [Sampling defaults](/console/docs-assets/en/guides/sampling.md): What temperature, top_p, top_k and the penalties a request gets when it sends none, and how the thinking mode picks them.
- [Structured output and tool calling](/console/docs-assets/en/guides/structured-output.md): Constrain generation to a JSON schema, regex, choice list or grammar, and call tools with tool_choice and parallel calls, across the chat, Responses, Messages and Ollama routes.
- [Local Tavily API](/console/docs-assets/en/guides/tavily.md): Use the official Tavily Python, JavaScript and LangChain clients against Yunshu's local Tavily-compatible search, extract, crawl, map and research endpoints.
- [Host telemetry and energy](/console/docs-assets/en/guides/telemetry.md): Enable the local Apple Silicon power, GPU and temperature sampler, read it from the API, the CLI and Prometheus, and understand what the per-request energy estimates mean.
- [Transports](/console/docs-assets/en/guides/transports.md): The HTTP, SSE, WebSocket, Realtime, WebRTC and Unix socket transports Yunshu serves, the multiplexed text WebSocket protocol, and what is not offered.
- [Troubleshooting](/console/docs-assets/en/guides/troubleshooting.md): Fixes for common problems with installing, starting and calling Yunshu, and how to collect a diagnostics bundle.
- [Web search and fetch](/console/docs-assets/en/guides/web-search.md): Server-side web_search and web_fetch tools, the search providers behind them, the settings that control them, and what leaves your machine.
- [Introduction](/console/docs-assets/en/index.md): Yunshu is a local LLM and VLM inference engine for Apple Silicon that serves OpenAI- and Anthropic-compatible APIs from one process.
- [Code execution sandbox](/console/docs-assets/en/internals/code-execution-sandbox.md): How the Anthropic code_execution server tool runs model-written commands inside sandbox-runtime (srt) with file, network, time, memory and output limits.
- [The console process](/console/docs-assets/en/internals/console-process.md): Why the web console runs as a separate light process, what it proxies and records, how it finds engines, how restarts and launchd fit in, and how a measurement can pause it.
- [Constrained decoding](/console/docs-assets/en/internals/constrained-decoding.md): How JSON schema, regex, choice, grammar and tool-call constraints are enforced token by token, the two engines behind them, and how they interact with speculative decoding.
- [Memory management](/console/docs-assets/en/internals/memory.md): How Yunshu budgets, accounts for and gives back unified memory - cache budgets, the idle trim and keep-warm heartbeat, admission under pressure, and model eviction in multi-model mode.
- [How Yunshu works](/console/docs-assets/en/internals/overview.md): A map of the engine internals - the serving model, the request path, the prefix cache, speculative decoding, prefill and memory - with a link to a page for each part.
- [Prefill and rehearsal](/console/docs-assets/en/internals/prefill-and-rehearsal.md): How prefill gives the same tokens whatever the piece length (split-invariant prefill, 64-aligned checkpoints) and how next-turn rehearsal prefills a reply while idle without changing outputs.
- [Prefix cache](/console/docs-assets/en/internals/prefix-cache.md): How the automatic prefix cache (APC) stores exact checkpoints, keys them by tokens and media, spills to SSD, and why a hit returns the same tokens as a cold prefill.
- [Request lifecycle](/console/docs-assets/en/internals/request-lifecycle.md): The path of one request through the gateway middleware, the router, ModelManager dispatch, the VLM batch runner, the MLX thread and back out as a stream.
- [Speculative decoding](/console/docs-assets/en/internals/speculative-decoding.md): How Yunshu drafts and verifies several tokens per step with DFlash2 or the MTP head, why greedy output is identical with speculation on or off, and which models and requests take part.
- [Tool-call parsing](/console/docs-assets/en/internals/tool-call-parsing.md): How Yunshu detects a model's tool-call wire format from its chat template, parses calls from complete and streamed output, types the arguments, and decides finish_reason.

## Generated API reference

- [OpenAPI schema](/console/docs-assets/openapi.json)
