Claude Code
Claude Code is
Anthropic's official CLI. It speaks the Anthropic SDK wire
(/v1/messages), not OpenAI's. rapid-mlx exposes
/v1/messages as a first-class route so a one-liner
env var flip is all you need.
/v1/messages (Anthropic SDK) ·
Setup: ANTHROPIC_BASE_URL=http://localhost:8000 ·
Matrix cell:
✅ ✅ ✅ ✅
(Qwen 3.6 / Gemma 4 / DeepSeek / gpt-oss on 2026-07-07 pilot).
Re-verified 2026-08-01 — a real end-to-end bug fix: Claude Code pointed at the local server via
ANTHROPIC_BASE_URL and asked to find and fix a failing factorial, which it did (agent_smoke, claude 2.1.218). Plus the Anthropic SDK deep flow — plain, system prompt, multi-turn, streaming, tool use — 5/5. On rapid-mlx 0.11.5: the fix against gpt-oss-20b-mxfp4-q8, the SDK flow against qwen3.5-9b-4bit, both on an M2 Pro Mac mini (32 GB).
New to this? The 5-minute walkthrough on the blog is the fastest path from zero to a working local agent — this page is the complete reference behind it.
Install
Claude Code is upstream Anthropic — install their vendor CLI:
$ npm install -g @anthropic-ai/claude-code # or download the binary from anthropic.com/claude-code
Config
Anthropic's SDK honors the ANTHROPIC_BASE_URL env var.
Set it to the root of your rapid-mlx server (no /v1
suffix — the SDK appends the path itself):
$ export ANTHROPIC_BASE_URL=http://localhost:8000 $ export ANTHROPIC_API_KEY=not-needed $ claude # or inline: $ ANTHROPIC_BASE_URL=http://localhost:8000 ANTHROPIC_API_KEY=not-needed claude
Anthropic SDK (Python)
If you're driving the same wire from a script, the Python SDK
snippet is (verified by
tests/integrations/test_anthropic_sdk.py):
$ pip install anthropic
# Note the base_url is the ROOT, not /v1 — the SDK appends /v1/messages itself. # The test file strips /v1 with ``_BASE.rstrip('/').removesuffix('/v1')``. from anthropic import Anthropic client = Anthropic( base_url="http://localhost:8000", api_key="not-needed", ) message = client.messages.create( model="default", max_tokens=256, messages=[{"role": "user", "content": "Say hello"}], ) # Reasoning models emit a ThinkingBlock first — walk content and find the # first block with type == "text" (see _first_text in the test file). for block in message.content: if getattr(block, "type", None) == "text": print(block.text) break
Run
$ rapid-mlx serve qwen3.6-35b-4bit # in another shell: $ ANTHROPIC_BASE_URL=http://localhost:8000 ANTHROPIC_API_KEY=not-needed claude
serve auto-configures the
tool-call parser from the model's alias profile and turns on
grammar-constrained tool calling by default, so tool calls come back
guaranteed-parseable. Verified end-to-end: a bare serve +
an Anthropic /v1/messages request with a tool returns a
tool_use block. (On builds older than 0.10.14, add
--tool-call-parser qwen3_coder_xml --enable-auto-tool-choice.)
Gotchas
-
Base URL is root, not
/v1. The Anthropic SDK appends/v1/messagesitself.ANTHROPIC_BASE_URL=http://localhost:8000/v1would make it POST to/v1/v1/messagesand 404. -
Reasoning models emit a
ThinkingBlockfirst. The legacyresponse.content[0].textlookup raisesAttributeError. Walkresponse.contentand pick the first block whosetype == "text". -
Tool calls use Anthropic's
input_schema, not OpenAI'sparameters. Thetest_anthropic_sdk.pysmoke posts aninput_schemawith aget_weather(city: str)function and asserts atool_useblock comes back. -
No
--setuptemplate. Unlike other agents, Claude Code is a two-env-var flip —rapid-mlx agents claude-codedoes not have a config-file profile because there's nothing to write to.
Empirical
The claude-code row of the integration matrix
is ✅ across all four Tier-1 families (Qwen 3.6, Gemma 4,
DeepSeek R1-Distill, gpt-oss) on the 2026-07-07 pilot. The dedicated
Anthropic SDK deep flow at
test_anthropic_sdk.py
covers plain, system prompt, multi-turn, streaming, and tool use.