Skip to main content

Claude Code

Use Claude Code with NanoGPT to access Claude and 400+ AI models through a single API key.
Get started with NanoGPT for pay-as-you-go pricing with no monthly fees.
NanoGPT provides an Anthropic API-compatible endpoint that works seamlessly with Claude Code. This allows you to:
  • Use Claude Code with your NanoGPT credits
  • Access the real Claude models (Sonnet, Opus, Haiku)
  • Optionally route to 400+ other models (GPT-4o, Gemini, DeepSeek, and more)

Step 1: Install Claude Code

Note: If you encounter permission issues during installation, try using sudo (macOS/Linux) or running the command prompt as an administrator (Windows) to re-execute the installation command.

Step 2: Configure NanoGPT

1

Get API Key

  • Go to NanoGPT API
  • Create an account or log in
  • Copy your API key
2

Configure Environment Variables

Set up environment variables using one of the following methods:
Note: Some commands show no output when setting environment variables. This is normal as long as no errors appear.
Run this command in your terminal:
curl -O "https://nano-gpt.com/install/claude_code_nanogpt.sh" && bash ./claude_code_nanogpt.sh
The script will prompt for your API key and automatically configure ~/.claude/settings.json:
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_nanogpt_api_key",
    "ANTHROPIC_BASE_URL": "https://nano-gpt.com/api/v1",
    "API_TIMEOUT_MS": "600000"
  }
}
The installer now supports browser-based login. When the script starts, choose:
  1. Browser login (recommended) - it will open a verification URL, wait for approval, and then save your key in ~/.claude/settings.json.
  2. Paste API key - manual fallback if you prefer.
If a browser does not open automatically, copy the printed URL into your browser and approve the request.For more details on the browser login flow, see CLI login.

Step 3: Start Using Claude Code

Once configured, start Claude Code in your terminal:
cd your-project-directory
claude
If prompted with “Do you want to use this API key,” select “Yes.”
Grant Claude Code permission to access files in your folder and you’re ready to go.

FAQ

What Models Does This Use?

By default, Claude Code uses the real Claude models through NanoGPT:
Claude Code ModelNanoGPT Routes To
OpusClaude Opus 4.5
SonnetClaude Sonnet 4.5
HaikuClaude Haiku 4.5
No model mapping is required. NanoGPT passes the model names directly to Anthropic.

Can I Use Other Models?

Yes. NanoGPT supports 400+ models. You can configure Claude Code to use different models by adding model mappings to your ~/.claude/settings.json:
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_nanogpt_api_key",
    "ANTHROPIC_BASE_URL": "https://nano-gpt.com/api/v1",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "openai/gpt-5.2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-4.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "google/gemini-3-flash-preview"
  }
}
Recommended models:
Use CaseRecommended Model
Best overallopenai/gpt-5.2, anthropic/claude-opus-4.5
Fast/cheapgoogle/gemini-3-flash-preview
View all available models at nano-gpt.com/models/text.

Configuration Not Working?

If your configuration changes don’t take effect:
  1. Restart Claude Code: Close all Claude Code windows, open a new terminal, and run claude again
  2. Check JSON syntax: Ensure your settings.json has valid JSON (no trailing commas, proper quotes)
  3. Reset configuration: Delete ~/.claude/settings.json and reconfigure from scratch

How Do I Check My Configuration?

Run /status inside Claude Code to see your current model configuration. We recommend using the latest version of Claude Code:
# Check current version
claude --version

# Upgrade to latest
claude update
NanoGPT is compatible with Claude Code 1.0.0 and newer.

How Is This Different From Using Anthropic Directly?

FeatureAnthropic DirectNanoGPT
PricingMonthly subscription or API creditsPay-as-you-go, no minimums
ModelsClaude onlyClaude + 400 other models
BillingSeparate Anthropic accountSingle NanoGPT account
Rate limitsAnthropic limitsNanoGPT limits

Need Help?