Local Claude Code and OpenAI SDK backend on Apple Silicon via vllm-mlx
From README links · today
Ran a local inference server exposing OpenAI and Anthropic APIs for coding CLIs.
What they did
They wanted a single local inference process on an Apple Silicon Mac that could serve both OpenAI-style and Anthropic-style clients, so they installed vllm-mlx from PyPI (pinned to 0.4.1) and launched the server with `vllm-mlx serve mlx-community/Llama-3.2-3B-Instruct-4bit --host 127.0.0.1 --port 8000`. They confirmed a first response through the OpenAI Python SDK by pointing `base_url` at `http://localhost:8000/v1` with a placeholder API key, then restarted the server with `--continuous-batching` to exercise the batching and cache options. For the Anthropic side they exported `ANTHROPIC_BASE_URL=http://localhost:8000` and `ANTHROPIC_API_KEY=not-needed` and launched `claude` against the local `/v1/messages` endpoint. The goal was to validate that coding CLIs and standard SDK clients could talk to a local model without any model conversion step, using Metal and unified memory.
How it went
The server came up and answered both OpenAI SDK and Anthropic-style requests from one process, and the coding CLI connected against the local base URL. The README reports seven coding CLIs (OpenCode, pi, Codex, Claude Code, GitHub Copilot CLI, Cline CLI, OpenClaw) completing a streamed tool interaction and an exact file edit in one local run with a larger Qwen model, though those results are tied to specific client versions and settings. The 3B model used in the quickstart is fine for smoke tests but weak for real agentic coding work.
Worth knowing
The quickstart's minimal command runs the default engine without continuous batching; you must restart with the flag to get it. The `openai` client package is not installed by the server package, so client environments need it separately. First-run model download and load time varies by machine and connection. The pinned 0.4.1 is a reference release, not necessarily latest. The CLI validation results apply only to the tested client versions and settings, and the quickstart model is much smaller than the one used in those tests.
Wiring
Install vllm-mlx in an isolated Python 3.10+ environment, then run `vllm-mlx serve <mlx-model-id> --host 127.0.0.1 --port 8000`. The single process exposes OpenAI routes (`/v1/chat/completions`, `/v1/completions`, `/v1/embeddings`, `/v1/rerank`, `/v1/responses`) and Anthropic `/v1/messages`. OpenAI clients set `base_url` to `http://localhost:8000/v1` with any placeholder key; Anthropic clients and Claude Code use `ANTHROPIC_BASE_URL=http://localhost:8000` plus `ANTHROPIC_API_KEY=not-needed`. Restart with `--continuous-batching` to enable batching, paged KV cache, prefix caching, and SSD-tiered cache. Structured output uses `response_format` with JSON Schema; tool calling supports multiple parser families.
Try it yourself
Set up a local vllm-mlx server on this Apple Silicon Mac and wire it to both client styles. Steps: (1) create an isolated venv and `pip install 'vllm-mlx==0.4.1'`; (2) start `vllm-mlx serve mlx-community/Llama-3.2-3B-Instruct-4bit --host 127.0.0.1 --port 8000`; (3) write a small Python script using the `openai` package with `base_url='http://localhost:8000/v1'` and `api_key='not-needed'` that sends one chat completion and prints the reply; (4) restart the server with `--continuous-batching` and re-run the script; (5) export `ANTHROPIC_BASE_URL=http://localhost:8000` and `ANTHROPIC_API_KEY=not-needed` and verify an Anthropic-style `/v1/messages` call with curl. Report timings, any errors, and which flags changed behavior.
Tools in this stack
Run this stack
Install the stack into this project. It writes AGENTS.md and the manifest, merges the MCP servers into .mcp.json, and — with --yes — runs the tool installs.
npx runchr install runchr/stack-rapid-mlx-and-vllm-and-vllm-mlxcurl -s https://api.runchr.com/api/recipes/runchr/stack-rapid-mlx-and-vllm-and-vllm-mlx/manifestThis stack has no prompt yet. You get the tools and the wiring, not the prompt.
The manifest is also at api.runchr.com/api/recipes/runchr/stack-rapid-mlx-and-vllm-and-vllm-mlx/manifest.