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).
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 \ --tool-call-parser qwen3_coder_xml --enable-auto-tool-choice # in another shell: $ ANTHROPIC_BASE_URL=http://localhost:8000 ANTHROPIC_API_KEY=not-needed claude
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.