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.
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 |
Two configuration methods are provided below — pick one.Option A: Use a .env file (recommended for long-term use)#
Option B: 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-08 04:15:12