Use Claude Code with NIM
Claude Code can use
NIM as its backend through the Anthropic-compatible /v1/messages endpoint.
For request and response details, refer to Messages (Anthropic-compatible).
Before You Begin
Start a NIM deployment that serves a chat-capable model. For deployment instructions, refer to the Quickstart.
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.
To find the active model name and export it as MODEL_NAME, refer to
Examples. The examples below use this variable.
Configure Claude Code
Set the Claude Code environment variables to point to your NIM deployment:
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.
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:
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:
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.