Advertisement independent setup guide

NanoGPT with Claude Code: model provider or MCP tools?

These integrations solve different jobs. Provider mode routes Claude Code’s model requests through NanoGPT’s Anthropic-compatible API. The MCP server adds optional NanoGPT tools; it does not switch the model powering Claude Code.

Referral disclosure: the NanoGPT invitation links on this page give you 5% off queries on NanoGPT’s website; they do not claim an API discount. This site may receive platform credit after a qualifying purchase. Terms can change.

Choose before you configure.

Use provider mode when…

You want NanoGPT to handle the model calls that power Claude Code. This sets ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.

Use MCP when…

You want callable tools such as NanoGPT balance, model listing, image generation, web search or URL scraping. MCP can be added without changing the model provider.

You can use both, but configure and verify them separately. Each billable NanoGPT request uses your NanoGPT balance; accepting a referral does not provide prepaid API credit.

Before either path

Back up user settings and check the runtime.

mkdir -p ~/.claude
if [ -f ~/.claude/settings.json ]; then
  cp ~/.claude/settings.json ~/.claude/settings.json.before-nanogpt
fi
node --version
npm install -g @anthropic-ai/claude-code
claude --version

NanoGPT’s current Claude Code guide requires Node.js 18 or newer. Its separate MCP package requires Node.js 22 or newer. Prefer a version manager or user-writable npm prefix over a privileged global install.

Path A · model provider

Try the provider in one shell first.

This reversible test keeps the key out of project files and out of the command itself. Enter the key silently when prompted:

read -rsp "NanoGPT API key: " ANTHROPIC_AUTH_TOKEN; echo
export ANTHROPIC_AUTH_TOKEN
export ANTHROPIC_BASE_URL="https://nano-gpt.com/api/v1"
claude

Do not put a reusable key in a repository, screenshot, URL or copied diagnostic output. A real Claude Code prompt is billable.

Optional persistent user configuration

NanoGPT documents the following user-level ~/.claude/settings.json shape. It stores the token on disk, so restrict the file and use only a personal machine you trust. Merge the env object into existing settings rather than erasing permissions or other configuration.

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "paste-your-key-locally",
    "ANTHROPIC_BASE_URL": "https://nano-gpt.com/api/v1"
  }
}
chmod 600 ~/.claude/settings.json
python3 -c 'import json,pathlib; json.loads(pathlib.Path.home().joinpath(".claude/settings.json").read_text()); print("JSON is valid")'

NanoGPT also provides an installer with browser-based login. If you use it, download and inspect the script before running it rather than piping an unseen network response directly to a shell.

Provider check

Verify routing without printing the token.

python3 -c 'import os; print("NanoGPT base URL set" if os.getenv("ANTHROPIC_BASE_URL") == "https://nano-gpt.com/api/v1" else "Base URL missing or different")'
python3 -c 'import os; print("Auth token set" if os.getenv("ANTHROPIC_AUTH_TOKEN") else "Auth token missing")'

Start Claude Code, approve the API-key prompt if shown, then run /status. NanoGPT and Anthropic both document /status as the place to inspect the active model configuration. Use GET /api/v1/models for current callable IDs rather than copying a static model list.

Path B · optional tools

Add MCP only when you need its tools.

NanoGPT’s MCP server is a local stdio process that calls NanoGPT’s remote API. It is not local inference, and its tools can incur API costs.

read -rsp "NanoGPT API key: " NANOGPT_API_KEY; echo
claude mcp add nanogpt --scope user \
  --env NANOGPT_API_KEY="$NANOGPT_API_KEY" \
  -- npx -y @nanogpt/mcp
unset NANOGPT_API_KEY
claude mcp list

The command stores the MCP environment configuration at user scope. Review that scope before using a shared machine. On native Windows, follow NanoGPT’s current MCP guide: it uses cmd /c with npx.cmd rather than the Unix command above.

Diagnostic path

Identify which integration failed.

Claude Code uses the wrong provider

Check /status, close every Claude Code process and start it from a fresh terminal. Validate JSON before changing anything else.

401 or authentication error

Confirm the relevant variable exists without printing it. Provider mode uses ANTHROPIC_AUTH_TOKEN; the MCP launcher uses NANOGPT_API_KEY.

Unknown model

Refresh https://nano-gpt.com/api/v1/models and use an exact current ID. Availability and compatibility change.

MCP says the key is invalid

If provider calls work, inspect the MCP launch command. On Windows, NanoGPT says a missing cmd /c wrapper can surface as an apparent key error.

MCP is absent

Run claude mcp list, confirm Node 22 or newer, and restart Claude Code. Do not alter provider settings to fix an MCP registration problem.

Insufficient balance

Stop retries and inspect NanoGPT usage and balance. Provider calls and MCP tools can both be billable; the website-query referral discount is not claimed for API use.

Reversible by design

Remove only the path you added.

For the shell-only provider test, close Claude Code and clear the variables:

unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL

If you changed user settings and made the backup above, restore it. Remove the MCP server separately:

if [ -f ~/.claude/settings.json.before-nanogpt ]; then
  mv ~/.claude/settings.json.before-nanogpt ~/.claude/settings.json
fi
claude mcp remove nanogpt --scope user

Removing local configuration does not revoke a key. Revoke it in NanoGPT’s API-key page if it was exposed or is no longer needed.

Optional account step

The technical guide is not gated.

Create or manage an API key on NanoGPT’s clean official API page. If the separate website-query discount is useful, the disclosed invitation is below.

Accept the 5% web-query invitation

Method and limits

Primary sources, with a clear test boundary.

This page was checked against NanoGPT’s current Claude Code guide, MCP guide and Messages API reference, plus Anthropic’s settings and model configuration documentation on 9 August 2026.

The published JSON fixture was parsed successfully. No reusable key was entered and no paid model or MCP request was made, so this guide does not claim end-to-end product experience, feature parity or a benchmark. The linked first-party pages remain authoritative.