Skip to main content
These examples use the website API host, which currently lists their recommended models. The direct API host can have a different catalog during rollouts. For larger requests or longer runtimes, use https://api.nano-gpt.com/api/v1 with a model from that host’s catalog. See API Hosts for limits and availability checks.

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:
The script will prompt for your API key and automatically configure ~/.claude/settings.json:
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:
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?

Claude Code sends its selected model ID to NanoGPT. To choose our current Claude recommendations explicitly, add these variables to the env section of ~/.claude/settings.json:
These settings select the public NanoGPT model IDs shown above. Existing Claude Code configurations can continue to use older releases.

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:
Recommended models: List available models with GET https://nano-gpt.com/api/v1/models.

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:
NanoGPT is compatible with Claude Code 1.0.0 and newer.

How Is This Different From Using Anthropic Directly?

Need Help?