> This page is for version 2.0.8.
> For other versions, use one of these documentation indexes:
> - 2.1.6 (Latest) (default): https://docs.nvidia.com/nim/large-language-models/2.1.6/llms.txt
> - 2.1.5: https://docs.nvidia.com/nim/large-language-models/2.1.5/llms.txt
> - 2.1.4: https://docs.nvidia.com/nim/large-language-models/2.1.4/llms.txt
> - 2.0.13: https://docs.nvidia.com/nim/large-language-models/2.0.13/llms.txt
> - 2.0.12: https://docs.nvidia.com/nim/large-language-models/2.0.12/llms.txt
> - 2.0.11: https://docs.nvidia.com/nim/large-language-models/2.0.11/llms.txt
> - 2.0.10: https://docs.nvidia.com/nim/large-language-models/2.0.10/llms.txt
> - 2.0.9: https://docs.nvidia.com/nim/large-language-models/2.0.9/llms.txt
> - 2.0.8: https://docs.nvidia.com/nim/large-language-models/2.0.8/llms.txt
> - 2.0.4-pb6: https://docs.nvidia.com/nim/large-language-models/2.0.4-pb6/llms.txt
> - Archive: https://docs.nvidia.com/nim/large-language-models/archive/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/large-language-models/llms.txt.

# Use Claude Code with NIM

[Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) can use
NIM as its backend through the Anthropic-compatible `/v1/messages` endpoint.
For request and response details, refer to [Messages (Anthropic-compatible)](/nim/large-language-models/2.0.8/reference/api-reference#messages-anthropic-compatible).

## Before You Begin

Start a NIM deployment that serves a chat-capable model. For deployment
instructions, refer to the [Quickstart](/nim/large-language-models/2.0.8/get-started/quickstart).

> **Note**
>
> Claude Code requires tool calling. Verify that your model supports tool use
> before you rely on it with Claude Code. For instructions and troubleshooting,
> refer to [Tool Calling and MCP Integration](/nim/large-language-models/2.0.8/advanced-use-cases/tool-calling-and-mcp).

To find the active model name and export it as `MODEL_NAME`, refer to
[Examples](/nim/large-language-models/2.0.8/reference/api-reference#find-model-name). The examples below use this variable.

## Configure Claude Code

Set the Claude Code environment variables to point to your NIM deployment:

```bash
export ANTHROPIC_BASE_URL="http://${NIM_ENDPOINT}:${NIM_SERVER_PORT}"
export ANTHROPIC_API_KEY="not-used"
export ANTHROPIC_CUSTOM_MODEL_OPTION="${MODEL_NAME}"
claude
```

Replace `NIM_ENDPOINT` with the hostname or IP address of your NIM deployment.
Replace `NIM_SERVER_PORT` with the port, which is `8000` by default.

NIM does not validate `ANTHROPIC_API_KEY`. Set it to any non-empty string that
satisfies Claude Code or the Anthropic SDK client.

`ANTHROPIC_CUSTOM_MODEL_OPTION` adds the model to the Claude Code `/model`
picker. For additional options such as
`ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` and
`ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION`, refer to the
[Claude Code model configuration documentation](https://code.claude.com/docs/en/model-config#add-a-custom-model-option).

This setting adds a custom entry, but it does not replace Claude Code built-in
aliases such as `haiku`, `sonnet`, and `opus`. To map those aliases to the same
model that NIM serves, set the alias variables explicitly:

```bash
export ANTHROPIC_API_KEY="not-used"
export ANTHROPIC_BASE_URL="http://${NIM_ENDPOINT}:${NIM_SERVER_PORT}"
export ANTHROPIC_CUSTOM_MODEL_OPTION="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_OPUS_MODEL="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_SONNET_MODEL="${MODEL_NAME}"
export CLAUDE_CODE_SUBAGENT_MODEL="${MODEL_NAME}"
```

## Troubleshooting

This section covers common issues when Claude Code or other Anthropic-compatible
clients connect to NIM through `/v1/messages`.

### Claude Code Returns a Model `404` Error

**Symptoms**

Claude Code appears to connect, but NIM logs contain errors such as the
following:

```text
The model 'claude-haiku-4-5-20251001' does not exist
```

**Cause**

Claude Code can continue to use built-in aliases such as `haiku`, `sonnet`, or
`opus` for background functionality even after you add a custom model option.
If those aliases still resolve to Anthropic model IDs, NIM returns `404 Not
Found` because it does not serve those model names.

**Resolution**

Map the Claude Code aliases to the same model name that NIM serves. To find the
active model name and export it as `MODEL_NAME`, refer to
[Examples](/nim/large-language-models/2.0.8/reference/api-reference#find-model-name).

```bash
export ANTHROPIC_API_KEY="not-used"
export ANTHROPIC_BASE_URL="http://${NIM_ENDPOINT}:${NIM_SERVER_PORT}"
export ANTHROPIC_CUSTOM_MODEL_OPTION="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_OPUS_MODEL="${MODEL_NAME}"
export ANTHROPIC_DEFAULT_SONNET_MODEL="${MODEL_NAME}"
export CLAUDE_CODE_SUBAGENT_MODEL="${MODEL_NAME}"
```