Why Claude Code isn't a drop-in swap for OpenCode

Every other local-model guide on this blog, OpenCode and Continue among them, points the agent at an OpenAI-compatible endpoint. Claude Code doesn't work that way. It's Anthropic's CLI and speaks the Anthropic Messages API: the request body, the streaming format and the tool-call shape are all Anthropic's. Pointing it at a local server means setting ANTHROPIC_BASE_URL, and whatever answers has to accept requests in that exact shape; being "OpenAI-compatible", as mlx_lm.server is, isn't enough.

That one constraint decides the rest: which host provider you can use, and what you set differently from the other agents.

The host provider that works: Ollama, not MLX directly

Since version 0.14, Ollama supports the Anthropic Messages API: it accepts requests at /v1/messages in Anthropic's format, translates them for the underlying model, and answers in the same shape. That makes it the host provider Claude Code can talk to directly. Ollama's documentation is clear that it's a subset: messages, streaming and function calling work; tool-choice controls, deferred tools and hosted web search don't. Worth knowing before you hit one of those and suspect Velo Workspaces.

MLX's own server (mlx_lm.server) is OpenAI-compatible only. That's fine for OpenCode and Continue, but Claude Code would need a translation layer in front of it, which this guide doesn't cover. For Claude Code, set AI Bridge's Host Provider to Ollama.

Since Ollama 0.19 (March 2026), Ollama runs on Apple's MLX internally on Macs with 32 GB or more. That's about the engine inside Ollama, not the API it offers, so both are true at once: Ollama speaks Anthropic's protocol on the outside and runs MLX on the inside.

Setup

1. Install and run Ollama on the Mac

Install Ollama if you haven't, make sure it's version 0.14 or later, and pull a model that handles agentic tool calls reasonably well:

ollama pull qwen2.5-coder:7b

Ollama listens on 127.0.0.1:11434 and serves the Anthropic-compatible API on the same port; there's nothing extra to enable.

2. Create the workspace with AI Bridge on

In Velo Workspaces, create a Linux workspace (the Cloud image of Ubuntu 26.04 is the quickest), choose the AI Sandbox profile or turn AI Bridge on under Advanced Settings, and set Host Provider to Ollama. It's the same vsock bridge described in the AI Bridge architecture post: the model stays on the Mac's GPU, and only Claude Code's command execution happens in the VM. Then start the guest's forwarder from the workspace's AI Bridge tab, as in the complete guide.

3. Install Claude Code in the VM

Inside the guest, install the Claude Code CLI the usual way for the distribution, for example npm install -g @anthropic-ai/claude-code. Nothing about the install changes because it's in a VM.

4. Point it at AI Bridge instead of Anthropic's API

Set three environment variables before launching, instead of the OPENAI_API_BASE the other guides use:

export ANTHROPIC_BASE_URL=http://127.0.0.1:<port>
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
claude --model qwen2.5-coder:7b

Two details that differ from the OpenCode setup and are easy to get wrong:

  • No /v1 on the base URL. OpenCode's base URL needs /v1; Claude Code adds /v1/messages itself, so adding /v1 breaks the path.
  • The variable is read once, at start-up. Changing ANTHROPIC_BASE_URL in one terminal doesn't affect a claude process already running in another. Restart it after any change, or you'll be debugging an endpoint that's just stale.

ANTHROPIC_AUTH_TOKEN=ollama is a placeholder, not a credential. Ollama doesn't check it, but Claude Code won't send a request without something in the Authorization header.

Why isolate it at all

The reason to run a coding agent in a disposable VM doesn't depend on which agent it is. Claude Code runs shell commands and edits files with whatever permissions its process has, and 2026 incidents, including one involving Claude Code's own project-loading flow, show that "the agent behaves correctly" isn't a boundary to rely on. In a disposable workspace, a compromised or simply mistaken session ends when you close it, and AI Bridge means you keep the Mac's GPU while you get that isolation.

Related reading: the architecture behind AI Bridge, the same setup for OpenCode and for Continue in VS Code, what it costs in inference speed, and what goes wrong when a coding agent runs unsandboxed. Or download Velo Workspaces and try it yourself.