> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Run Claude Code on Morph models, and add Morph's fast edits and repo search as tools.

Claude Code speaks the Anthropic Messages API. Morph serves that format at `/v1/messages` for every [open-source chat model](/sdk/components/fast-models), so Claude Code runs on Morph with four env vars. You need a [Morph API key](https://morphllm.com/dashboard/api-keys).

## Run Claude Code on a Morph model

`ANTHROPIC_MODEL` remaps sonnet/opus. `ANTHROPIC_SMALL_FAST_MODEL` remaps haiku — the background calls for titles and summaries.

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.morphllm.com"
export ANTHROPIC_AUTH_TOKEN="YOUR_MORPH_API_KEY"
export ANTHROPIC_MODEL="morph-kimik3"
export ANTHROPIC_SMALL_FAST_MODEL="morph-glm53flash"
claude
```

Or persist it in `~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.morphllm.com",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_MORPH_API_KEY",
    "ANTHROPIC_MODEL": "morph-kimik3",
    "ANTHROPIC_SMALL_FAST_MODEL": "morph-glm53flash"
  }
}
```

Read, Edit, Write, Bash, and Grep run through the standard `tool_use` / `tool_result` loop. Streaming, system prompts, and `cache_control` work as Anthropic documents them; model reasoning arrives as `thinking` blocks. Model IDs are on the [Open Source Models](/sdk/components/fast-models) page — `morph-glm53-744b` and `morph-glm53flash` are cheaper alternatives to K3.

Codex and per-task model routing: [Claude Code & Codex](/guides/coding-agents).

## Add Fast Apply and WarpGrep as tools

Independent of which model runs the loop, the [Morph MCP server](/mcpquickstart) gives Claude Code `edit_file` (10,500 tok/s merges) and `codebase_search`:

```bash theme={null}
claude mcp add filesystem-with-morph -e MORPH_API_KEY=YOUR_API_KEY -e ALL_TOOLS=false -- npx @morphllm/morphmcp
```

Then tell Claude when to reach for them:

```bash theme={null}
mkdir -p ~/.claude && echo "Fast Apply: IMPORTANT: Use \`edit_file\` over \`str_replace\` or full file writes. It works with partial code snippets—no need for full file content.
Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. \"Find the XYZ flow\", \"How does XYZ work\", \"Where is XYZ handled?\", \"Where is <error message> coming from?\"" >> ~/.claude/CLAUDE.md
```

## Troubleshooting

**401 on every request.** Claude Code sends `ANTHROPIC_AUTH_TOKEN` as a bearer token; `ANTHROPIC_API_KEY` also works. Both go to the same Morph key — don't leave an Anthropic key in either variable.

**Model not found.** Use a Morph model ID (`morph-kimik3`), not `claude-sonnet-4-6`. Morph serves its own models, not Anthropic's.

**Claude isn't calling `edit_file`.** Confirm the MCP server is connected with `/mcp`, and that the instructions above landed in `~/.claude/CLAUDE.md`.
