Agent guide · rapid-mlx 0.10.3 · ← Back to README

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.

Wire: /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

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.

See also