This guide explains how to point the Claude Code CLI at our reverse proxy endpoint.Pricing: The Claude Code endpoint is billed at 20% of the official Anthropic API pricing.
Pricing Details (per Million Tokens)#
| Model | Input | Cache Write | Cache Read | Output |
|---|
| claude-opus-4-6 | $1.00 | $1.25 | $0.10 | $5.00 |
| claude-sonnet-4-6 | $0.60 | $0.75 | $0.06 | $3.00 |
| claude-haiku-4-5 | $0.20 | $0.25 | $0.02 | $1.00 |
Prices shown are after the 80% discount. Cache Write = 5-minute TTL cache write. Cache Read = cache hit/refresh.Access: This endpoint is available to subscribed users only. Free-tier users cannot access the Claude Code reverse proxy. Please upgrade your plan to use this feature.
1. Install Claude Code#
First, install the Claude Code CLI by following the official documentation:Quick install (macOS / Linux): Claude Code uses two environment variables to determine the API destination:| Variable | Value |
|---|
ANTHROPIC_BASE_URL | https://api.piapi.ai/v1/claude-code |
ANTHROPIC_API_KEY | Your user API key |
Three configuration methods are provided below — pick one.Option A: Use settings.json (recommended for project-level config)#
Create a .claude/settings.json file in your project directory:Replace your-api-key with your actual API key.Why apiKeyHelper instead of ANTHROPIC_API_KEY?
Claude Code's authentication priority (highest → lowest):1.
apiKeyHelper (shell command output) ← highest
2.
ANTHROPIC_API_KEY environment variable
3.
Stored OAuth token (from claude login) ← lowest
If you have ever run claude login, an OAuth token is stored in ~/.claude/.credentials.json. This token silently overrides ANTHROPIC_API_KEY, causing requests to be sent with the wrong credentials. Using apiKeyHelper avoids this problem entirely.This method takes effect automatically whenever you run claude inside the project directory — no shell rc changes needed.Option B: Use a .env file (recommended for long-term use)#
Option C: Direct export (temporary / per-session)#
Run this in the terminal where you want to use Claude Code:The variables are lost when the terminal closes — useful for quick testing or switching providers.3. Verify the Configuration#
Confirm the environment variables are set:Both should print the values you configured.Then start Claude Code to test:If you get a normal model response, the configuration is working.4. Switching Models#
Inside a Claude Code session, type the /model command to switch between Claude models:Follow the prompts to choose a model.5. FAQ#
Q: I get 403 "This endpoint is reserved for Claude Code CLI only"#
Requests must be made through the official claude CLI. Custom curl scripts or third-party SDKs are not allowed to call this endpoint directly.
Q: How do I switch back to the official API?#
Unset the environment variables: Or comment out the two lines in ~/.claude/.env and re-source your shell rc file.
6. Support#
If you run into any issues, please contact technical support. Modified at 2026-04-20 06:06:58