How do you run Claude Code with a different API address and key?
ANTHROPIC_BASE_URL is the API's root address (for Wiozen https://api.wiozen.com, without /v1 at the end), ANTHROPIC_AUTH_TOKEN is your API key (it starts with sk-gw-), ANTHROPIC_MODEL is the model name, and ANTHROPIC_DEFAULT_HAIKU_MODEL is the model Claude Code uses for small background tasks. On Wiozen, Claude Code currently works only with the wiozen-coder model, so both model variables get that name. With the variables set, the claude command sends its requests to that address.Which variables do you need?
Claude Code sends requests in the Anthropic Messages format and reads the address, key and model from environment variables. Switching to another API doesn't involve changing any code or reinstalling Claude Code; you only supply these four values. On macOS and Linux:
export ANTHROPIC_BASE_URL="https://api.wiozen.com" export ANTHROPIC_AUTH_TOKEN="sk-gw-..." export ANTHROPIC_MODEL="wiozen-coder" export ANTHROPIC_DEFAULT_HAIKU_MODEL="wiozen-coder" claude
In Windows PowerShell you use $env: instead of export:
$env:ANTHROPIC_BASE_URL = "https://api.wiozen.com" $env:ANTHROPIC_AUTH_TOKEN = "sk-gw-..." $env:ANTHROPIC_MODEL = "wiozen-coder" $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "wiozen-coder" claude
These variables only apply to that terminal window. Close it and Claude Code goes back to its previous setup. The same steps, in short form, are also on the Claude Code setup page.
Why doesn't the address end with /v1?
Claude Code appends the path to the address you give it: /v1/messages. That's why you give the root address. Tools that use the OpenAI format want the address with /v1; the difference is explained in the OpenAI-compatible connection guide.
If you type https://api.wiozen.com/v1 by mistake, the request goes to /v1/v1/messages. Wiozen accepts that doubled path too, so it keeps working, but the same mistake can give a 404 with another service. Make the root address a habit.
Wiozen serves the two Anthropic-format endpoints: /v1/messages (generating answers) and /v1/messages/count_tokens (counting tokens). Token counting is free.
How do I make the setting permanent?
There are two ways. The first is adding the four export lines to your shell profile (~/.bashrc or ~/.zshrc). Every terminal you open then starts with these values, and every tool sees them.
The second is giving the values to Claude Code only. Claude Code loads the env block in its user settings file as environment variables every time it starts:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.wiozen.com",
"ANTHROPIC_AUTH_TOKEN": "sk-gw-...",
"ANTHROPIC_MODEL": "wiozen-coder",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "wiozen-coder"
}
}If the file already has other settings, add just the env block. The key sits in this file as plain text, so don't put the file in a repository or a shared folder. If the key was shared by mistake, follow the steps in the leaked key guide.
Which model should I set?
wiozen-coder. On Wiozen, Claude Code currently works only with this model. Wiozen accepts only the names published on the Models page; a name that isn't on the list returns 400 Unknown model, and the error message lists the models you can use.
You can use the other models on the list from tools that use the OpenAI format (code editors, your own scripts) with the same key. Which model suits which job is covered in the model choice guide.
How is it billed, and how do I track it?
Each request takes the price of the tokens it used from your dollar balance. Agents like Claude Code resend the whole conversation on every turn, so the input grows as the session gets longer. When the repeated part is read from the cache, it's charged at a tenth of the normal input price; current prices are on the Models page. The full calculation is in the API cost guide.
Create a separate key for Claude Code and label it claude-code. The Keys page shows each key's total spend on its own. If you're worried about a session stuck in a loop burning the whole balance, put a spend limit on that key; when it's reached, only that key stops.
Common errors
| Error | Cause | Fix |
|---|---|---|
401 Invalid API key | The key is wrong, copied incompletely or revoked | Check the key again; details in the 401 guide |
400 Unknown model | ANTHROPIC_MODEL or ANTHROPIC_DEFAULT_HAIKU_MODEL holds a name that isn't on the list | Set both to wiozen-coder |
429 | The balance ran out or the key's spend limit was reached | See the 429 guide |
| Long waits, timeouts | Long answers or a network problem | See the timeout guide |
If both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY are set, remove one. The first is sent in the Authorization: Bearer header, the second in x-api-key. If both arrive, Wiozen reads Authorization first, so an old key left there means the correct key in the other header is never read.
To go back to your previous setup, remove the variables: on macOS and Linux unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_MODEL ANTHROPIC_DEFAULT_HAIKU_MODEL, in PowerShell Remove-Item Env:ANTHROPIC_BASE_URL and the same for the other three. If you added them to the settings file, delete the env block.
Frequently asked questions
What do I put in ANTHROPIC_BASE_URL?
https://api.wiozen.com. Claude Code adds the /v1/messages path itself.ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?
ANTHROPIC_AUTH_TOKEN. Wiozen accepts both headers, but don't set both; if both are sent, the key in the Authorization header is the one read.Which model works in Claude Code?
wiozen-coder. Any other name returns 400 Unknown model.Do I have to set the variables again in every terminal?
env block in ~/.claude/settings.json and they stay.Is token counting charged?
/v1/messages/count_tokens request doesn't touch your balance.Create a key labelled claude-code on the Keys page, set the four variables and run claude. The step-by-step setup is on the Claude Code page.
More guides: How can you use an AI API from Turkey without a credit card? · How do you connect an OpenAI-compatible API to a tool you already use? · How do you calculate the cost of an AI API? · What should I do if my AI API key has leaked? · How do you generate images with an AI API, and what does one image cost? · How much does a speech-to-text API cost, and how is it billed per minute? · Why does my AI API return a 429 error, and how do I fix it? · Why do long AI API requests time out: streaming or non-streaming? · Anthropic Messages API or OpenAI Chat Completions: which one should I use? · What is a context window, and what is a 1 million token context good for? · Which AI model should I choose: deciding by price, context and quality · Why does a reasoning model return an empty answer, and why are thinking tokens charged? · Why is my API balance running out faster than expected? Tracking spend request by request · How do you convert a web page to Markdown to feed it to an AI model? · How do you get AI to write and publish articles in WordPress automatically? · How do you find blog topics from RSS feeds and Google Trends? · Does AI-written content show up on Google and in AI answers? · How do you get internal links into AI-written WordPress articles? · How do you get AI to generate a different featured image for every WordPress post? · How do you write a content brief when an AI writes your blog posts? · What should you watch for when an AI writes recipes for your food blog? · How do you fix errors when connecting a WordPress plugin to your AI API account? · Why does my AI article bot stop halfway in WordPress? "Run is stuck" and LiteSpeed · Why are my scheduled WordPress posts late? WP-Cron and a real server cron · How do I get an AI article bot to write blog posts in English or another language? · What does "Content Bot cannot generate articles" mean? Reading the bot's log · If I delete the WordPress AI article plugin, are the articles it wrote deleted? · How do you do function calling (tool use) with an AI API? · How do I check my AI API balance from code and get a low-balance alert? · Can I use the same AI article plugin on several WordPress sites with one account and one balance? · Do AI-written WordPress posts get an FAQ section and FAQ structured data (schema)? · My AI API returns "401 Invalid API key": why isn't my key accepted? · Is there a free trial for an AI API? How much credit Wiozen API gives and what it covers · Claude Haiku vs Claude Sonnet via API: price per million tokens and when to use each · How much does a Claude Code session cost with an API key? · Can you use Claude Code without a subscription and pay only for what you use? · How much does prompt caching cut API costs? Cache read and cache write prices · When is the DeepSeek API cheaper? Peak and off-peak hour pricing · Which model should you use in Cline, Cursor, OpenCode and Aider? · How much does an AI-written WordPress post cost? Text, image and research · Why didn't the AI bot publish its post, and why is it stuck in drafts? · How many AI-written posts a day should you publish, and how do you set the frequency? · Who should be the author of AI-written WordPress posts? · What to watch for when AI writes posts for a loan, crypto or energy website · An AI API returns "Unknown model": where do I find the right model name? · How do I add web search to my AI app, and what does a search cost?