Claude Code integration · Pay-as-you-go API
Claude Code third-party API setup
Claude Code reads its API endpoint and key from environment variables. Point ANTHROPIC_BASE_URL at aicodewith, add your API key, and use Claude Opus 5.5, Sonnet 5.5 and more in your terminal, billed per token.
For developers who outgrow their Claude Code plan allowance, teams that need per-key accounting, and anyone who prefers paying per token from a balance.
- ANTHROPIC_BASE_URL
- https://api.aicodewith.ai
- ANTHROPIC_AUTH_TOKEN
- Your AI Code With API key
- ANTHROPIC_API_KEY
- ""
- Model
- claude-sonnet-5-5 (example, switch with /model)
Set up in 1 minute
This is exactly the config the dashboard onboarding gives you.
- 1
Create an API key
Sign in to the dashboard and create a key on the API Keys page. You can set daily, monthly or total spend caps on it.
- 2
Write settings.json
macOS / Linux: ~/.claude/settings.json. Windows: %USERPROFILE%\.claude\settings.json. Create the file if it doesn't exist.
~/.claude/settings.json{ "env": { "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_API_KEY": "", "ANTHROPIC_BASE_URL": "https://api.aicodewith.ai" } } - 3
Skip the first-run login
Add hasCompletedOnboarding to ~/.claude.json so Claude Code doesn't ask you to sign in to an Anthropic account.
~/.claude.json{ "hasCompletedOnboarding": true }If ~/.claude.json already exists, add this one field to the existing JSON instead of overwriting it.
- 4
Restart Claude Code
Close every Claude Code session, run claude again and send a test message.
What each variable does
On startup Claude Code reads the env block in settings.json and uses it as environment variables.
- ANTHROPIC_BASE_URL
- The API endpoint. Use https://api.aicodewith.ai as the bare domain, with no /v1; Claude Code appends the path itself.
- ANTHROPIC_AUTH_TOKEN
- Your aicodewith API key, sent as Authorization: Bearer.
- ANTHROPIC_API_KEY
- Leave empty so it doesn't clash with an Anthropic key already set on your system.
Once an API key is set, Claude Code uses API billing instead of your Claude plan allowance. Usage is deducted per token from your aicodewith balance.
Choose a model
Type /model in Claude Code to switch. A common setup:
Claude Sonnet 5.5
The default for everyday coding; balanced speed and price.
Claude Opus 5.5
Large refactors, architecture work and hard-to-find bugs.
Claude Haiku 5.5
Subagents and batches of small tasks; the cheapest option.
See the models page for available models and live prices. /models
Check that it worked
- Run /status in Claude Code and confirm the API endpoint is api.aicodewith.ai.
- After a message, the request and its charge show up in your dashboard usage records.
- Run /cost to see the session's per-token cost.
Switching back to your Claude plan
Remove these env entries from settings.json, then run /login in Claude Code to sign in to your Anthropic account.
Don't have Claude Code yet?
Claude Code needs Node.js 18 or later. Install it globally with npm:
npm install -g @anthropic-ai/claude-codeFollow Anthropic's docs for the current install method. Run claude in your project folder to start.
Claude Code on npmFAQ
Should the base URL include /v1?
No. Set ANTHROPIC_BASE_URL to https://api.aicodewith.ai only; adding /v1 causes 404 errors.
Will my Claude plan's 5-hour or weekly limits still apply?
Requests don't use your plan allowance. They are billed per token from your aicodewith balance; our own rate and concurrency limits still apply as described in our docs.
How do I control spend?
Set daily, monthly or total spend caps on each API key in the dashboard, and run /cost in Claude Code to check a session's cost at any time.
Does it work with the Claude Code extension for VS Code or JetBrains?
Yes. The extensions read the same ~/.claude/settings.json as the CLI, so you only configure it once.
Is aicodewith affiliated with Anthropic?
No. aicodewith is an independent third-party API service. Claude and Claude Code are trademarks of Anthropic.
Common errors
Most problems come from the base URL, the key, or a leftover environment variable.
401 / Invalid API key
Symptom: Authentication fails as soon as you send a message.
Cause: Wrong or deleted key, or a system ANTHROPIC_API_KEY overrides the config.
- Copy the key again and check for extra spaces
- Make sure ANTHROPIC_API_KEY is empty
- Run echo $ANTHROPIC_API_KEY to look for a leftover value
404 Not Found
Symptom: Requests return 404.
Cause: The base URL includes /v1 or has a typo.
- Change it to https://api.aicodewith.ai
- Save and fully restart Claude Code
Still seeing "You've hit your session limit"
Symptom: You still get your Claude plan's limit message.
Cause: The config isn't active and Claude Code is still using your subscription login.
- Check the settings.json path and that the JSON is valid
- Close every session and restart
- Run /status to see the current endpoint
429 / rate limited
Symptom: Occasional 429 responses.
Cause: Request rate or concurrency exceeded the rate limit.
- Run fewer parallel subagents
- Wait a moment and retry
- Check your balance and the key's spend cap
Ran out of Claude Code usage?
See how the Pro and Max 5-hour and weekly limits work, and how a subscription, usage credits and pay-as-you-go API compare on cost.
Read the Claude Code usage limits guideSources
Related links
Claude and Claude Code are trademarks of Anthropic PBC. This page is not affiliated with or endorsed by Anthropic.