Skip to content

Use Claude Code with a local model

You’ll get: Claude Code (or OpenAI’s Codex CLI) working on a model that runs on your own Mac. Your code and prompts stay on your machine.

You need:

  • A local MLX model that’s good at coding and can call tools, such as a Qwen coding model.
  • A Nexus API key. Make one in Connections.
  • A short alias for the model, such as nexus-coder. Add it in Model Aliases.
  1. Save this as ~/.claude/settings.nexus.json, with your key:

    {
    "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:3939",
    "ANTHROPIC_AUTH_TOKEN": "msty_nexus_key_here",
    "ANTHROPIC_MODEL": "nexus-coder",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "nexus-coder",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "nexus-coder",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "nexus-coder",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144",
    "API_TIMEOUT_MS": "600000"
    }
    }
  2. Start Claude Code with it:

    claude --settings ~/.claude/settings.nexus.json

Set all four model names. Claude Code makes small background calls, such as naming the chat. Without them, those calls ask for a Claude model Nexus doesn’t have.

Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to your model’s real context size. Otherwise Claude Code assumes 200K and shortens the chat too early.

Codex speaks the Responses API, which Nexus also serves. Add a provider to ~/.codex/config.toml:

model_provider = "nexus"
model = "nexus-coder"
[model_providers.nexus]
name = "Msty Nexus"
base_url = "http://127.0.0.1:3939/v1"
env_key = "NEXUS_API_KEY"
wire_api = "responses"

Then run NEXUS_API_KEY=msty_nexus_key_here codex.

Ask the agent to read a file in your project. In Activity → Live stream, you see the request go to your local model.

If the agent answers but never reads or edits files, the model’s tool calls aren’t coming through. Try another model; see Gateway.