> This page is for version 2.0.13.
> 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

> Point Claude Code at a NIM LLM and VLM deployment through the Anthropic-compatible /v1/messages endpoint, including environment variables and troubleshooting.

[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.13/reference/api-reference#messages-anthropic-compatible).

## Prerequisites

Before you start, complete the following prerequisites:

1. Start a NIM deployment that serves a chat-capable model. For deployment
   instructions, refer to the [Quickstart](/nim/large-language-models/2.0.13/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.13/advanced-use-cases/tool-calling-and-mcp).

2. Find the active model name and export it as `MODEL_NAME`. For more information,
   refer to [Examples](/nim/large-language-models/2.0.13/reference/api-reference#find-model-name). The examples on this page use this variable.

## Configure Claude Code with NIM

To configure Claude Code with NIM, complete the following steps:

1. Set the Claude Code environment variables to point to your NIM deployment, then start Claude Code.

   ```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
   ```

2. 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).

3. Optional: Map Claude Code built-in aliases to the model that NIM serves.

   The custom model option 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

Use this topic when Claude Code connects but requests a model name that NIM does not serve.

**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.13/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}"
```

## Next Steps

After Claude Code can reach NIM, continue with the following topics:

* [Tool Calling and MCP Integration](/nim/large-language-models/2.0.13/advanced-use-cases/tool-calling-and-mcp) if tool use fails.
* [Messages (Anthropic-compatible)](/nim/large-language-models/2.0.13/reference/api-reference#messages-anthropic-compatible) for `/v1/messages` request and response details.