Prerequisites
Before getting started, make sure you have:-
Claude Code installed
Install the Claude Code CLI via npm or pnpm:
Or visit the Claude Code official docs for the latest installation instructions.
-
A ToAPIs API key
Sign in to the ToAPIs Console to obtain your API key (starts with
sk-).
Configuration
Claude Code supports multiple ways to configure a custom API endpoint. You can point it to ToAPIs as a drop-in replacement for the Anthropic API. Claude Code uses two separate JSON files: onboarding state and environment variables must go in the correct file to take effect.Ensure onboarding is complete
In your home directory, set~/.claude.json (create the file if it does not exist):
settings.json below.
Option 1: settings.json (Recommended)
Configure environment variables in ~/.claude/settings.json (global) or .claude/settings.json (project-level). No shell config changes required:
~/.claude/settings.json.
Project-level config (applies only to the current project):
Create .claude/settings.json in your project root. Do not put your API key in project-level config; keep ANTHROPIC_AUTH_TOKEN in the global config and only set ANTHROPIC_BASE_URL at the project level:
Note: PuthasCompletedOnboardingin~/.claude.jsonandenvin~/.claude/settings.jsonor.claude/settings.json. Do not mix them in the same file.
Option 2: Environment Variables
Best for temporary use or CI/CD pipelines.macOS / Linux
Set temporarily for the current session:~/.bashrc or ~/.zshrc:
Windows
Set temporarily in PowerShell:Option 3: .env File
Create a .env file in your project root:
.env to your .gitignore to avoid leaking your API key.
Configuration Reference
Verify the Setup
Run the following to check your installation:Recommended Models
The following Claude models are available through ToAPIs:
To switch models, use the
/model command inside Claude Code, or pass --model at startup:
Troubleshooting
Authentication error or 401 Unauthorized?
- Check that
ANTHROPIC_AUTH_TOKENis set correctly and starts withsk- - Verify the key is active in the ToAPIs Console
- Ensure your account has sufficient balance
Connection refused or unable to connect?
- Confirm
ANTHROPIC_BASE_URLis set tohttps://toapis.com - Check your network connection and ensure
https://toapis.comis reachable
Check current environment variables
Common error codes
Tips
1. Launch in a project directory
Navigate to your project folder and runclaude — it will automatically pick up the project context:
2. Useful commands
3. Working with code
Claude Code can read and modify project files. Common use cases:- Code review — Ask Claude Code to review your code and suggest improvements
- Code generation — Describe what you need; Claude Code writes it directly to files
- Debugging — Paste error messages and get targeted fixes
- Refactoring — Let Claude Code restructure and clean up your code
Support
If you encounter any issues:[## Get Started with ToAPIs Sign up for ToAPIs, get your API key, and supercharge your coding with Claude Code!](https://toapis.com)