Connect Claude Code
Use Claude Code with AlpRouter
If I change the address that Claude Code refers to from AlpRouter, then I can use AlpRouter’s credits to operate Claude Code.
Connect to environment variables
export ANTHROPIC_BASE_URL="https://alprouter.com/api"
export ANTHROPIC_AUTH_TOKEN="alp-your-key"
export ANTHROPIC_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"
claude| Variables | It’s worth putting it in there. |
|---|---|
ANTHROPIC_BASE_URL | https://alprouter.com/api |
ANTHROPIC_AUTH_TOKEN | AlpRouter API Key |
ANTHROPIC_MODEL | The models that will be used mainly |
ANTHROPIC_DEFAULT_HAIKU_MODEL | It’s such a trivial task like titling… I don’t think there’s any model that can be used for such things. |
Put it into the configuration file.
If you don’t want to send it every time, then write it down in the env of ~/.claude/settings.json.
{
"env": {
"ANTHROPIC_BASE_URL": "https://alprouter.com/api",
"ANTHROPIC_AUTH_TOKEN": "alp-your-key",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
}
}Things to know:
- The tools in Claude Code, such as file reading, writing, and command execution, remain unchanged.
- The web search tools aren’t yet usable.
- If the conversation exceeds 400KB, an
input_too_longerror will occur. Please reduce the size of the conversation to/compactbefore that. - The Claude Code allows for a long output at once. Each request requires a corresponding amount of credits. If the credits are low, then
insufficient_creditsmay not be able to be executed. - If you create a special key for the Claude Code and set limits on it, you can keep track of the amounts that have been used.
This connection is confirmed in Claude Code 2.1 for both file writing and reading operations. As the version increases, new items are added. It’s important to note that the supplier doesn’t receive those new items; instead, they are sent to the recipient.