Claude Code
Run Claude Code on PromptsForLess with three environment variables, a Claude model ID and your PromptsForLess API key.
Claude Code talks to the PromptsForLess Anthropic-compatible Messages API, including streaming and tool use. Set three environment variables and pick a Claude model.
Claude Code is built for Claude models, so use a Claude ID such as claude-sonnet-5-5 or claude-opus-5-5. Anthropic's gateway documentation explains how Claude Code works with gateways.
Before you start
Install Claude Code through its official instructions. Create an API key in the dashboard and store it as PFL_API_KEY.
Set the gateway for one terminal
export ANTHROPIC_BASE_URL="https://api.promptsforless.com"
export ANTHROPIC_AUTH_TOKEN="$PFL_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-5-5"
claudeUse the origin URL, without /v1: Claude Code appends /v1/messages itself. ANTHROPIC_AUTH_TOKEN sends your key as a bearer token. Unset any ANTHROPIC_API_KEY in this terminal so it does not override your PromptsForLess key.
These variables are Claude Code's official gateway settings. An app opened from your dock does not inherit terminal exports.
Check the connection
Send a direct request to confirm your key and model:
curl --fail-with-body https://api.promptsforless.com/v1/messages \
-H "Authorization: Bearer $PFL_API_KEY" \
-H 'anthropic-version: 2023-06-01' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 32,
"messages": [{"role": "user", "content": "Reply with hello."}]
}'Then start Claude Code from the same terminal and run /status to see the base URL and credential source. Send a short prompt, then ask it to read a file in a small test project.
Make it permanent
Keep your key in a secret manager. Save the base URL and model in your Claude Code user settings so every session uses them. Never commit a key in a project settings file. The official connection guide covers the VS Code extension and desktop app, which have their own settings.
Troubleshooting
| Symptom | Fix |
|---|---|
404 on /v1/v1/messages | Remove /v1 from ANTHROPIC_BASE_URL. |
| Authentication fails | Check that ANTHROPIC_AUTH_TOKEN holds your PromptsForLess key and that no ANTHROPIC_API_KEY is set. |
| Model is rejected | Use a Claude model ID from the catalog. |
/status shows the wrong endpoint | Check your user settings and the environment of the process that started Claude Code. |
Browse Claude models for prices and the integration directory for other tools.