Skip to content
Skip to Content
Batchwell Docs

Claude Code setup

Use Batchwell in Claude Code by setting ANTHROPIC_BASE_URL to the Batchwell address and ANTHROPIC_AUTH_TOKEN to your API key.

To use Batchwell in Claude Code, set ANTHROPIC_BASE_URL to the base URL https://api.batchwell.ai/v1 without its /v1, set ANTHROPIC_AUTH_TOKEN to your Batchwell API key, and set ANTHROPIC_MODEL to a Batchwell model id. This is Claude Code's documented setup for an LLM gateway.

Tested end to end

This setup was tested end to end with the real Claude Code CLI against the Batchwell API translation layer, which serves Claude Code's Messages API requests.

Not supported by Anthropic

Anthropic does not support Claude Code with models other than Claude. Claude Code runs on a Batchwell model, but features that need a Claude model, such as images and some tools, may not work.

Create a key as described in the Quickstart and Authentication, then run:

Shell
curl -fsSL https://batchwell.ai/connect.sh | sh -s -- claude --model batchwell/kimi-k3.1-pro-uncensored

It writes ~/.config/batchwell/claude-settings.json with the key in its env block (readable only by you), and leaves ~/.claude/settings.json as it is. It reads your key from BATCHWELL_API_KEY, or asks for it on the terminal with the input hidden, and checks it with GET /v1/models before it writes anything. Then start the agent with env -u ANTHROPIC_API_KEY claude --settings ~/.config/batchwell/claude-settings.json. Every file it changes is first copied to <file>.batchwell-backup-<time>; to undo it, copy that backup back over the file, or delete a file the command created. The command runs on macOS, Linux and WSL; see Connect an agent for every option.

Paste this prompt into the agent, or into any coding agent, and it sets itself up the same way. It names the variable that holds the key, never the key itself, and tells the agent to back up each file before it changes it.

Prompt
Set up Claude Code to use Batchwell. Change ~/.config/batchwell/claude-settings.json.

Base URL: https://api.batchwell.ai/v1
Model id: batchwell/kimi-k3.1-pro-uncensored
API format: Anthropic Messages
API key: in the environment variable BATCHWELL_API_KEY

Rules:
- Read the key from BATCHWELL_API_KEY. If it is unset, stop and ask me to export it. Never ask me to paste a key into this chat, never print it, and never write it into a file inside a git repository.
- Back up every file before you change it, as <file>.batchwell-backup-<UTC time>.
- Change only the Batchwell entries. Keep every other setting.

Steps:
- Write that file (mode 0600) with an "env" block: ANTHROPIC_BASE_URL "https://api.batchwell.ai" (no /v1), ANTHROPIC_AUTH_TOKEN set to the key, ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL set to the model id.
- Write the key from $BATCHWELL_API_KEY so it never shows. Leave ~/.claude/settings.json as it is.
- Check: GET https://api.batchwell.ai/v1/models with the header Authorization: Bearer $BATCHWELL_API_KEY. A 200 that lists the model id means it works.
- Tell me to restart with: env -u ANTHROPIC_API_KEY claude --settings ~/.config/batchwell/claude-settings.json. env -u drops a clashing ANTHROPIC_API_KEY. /status shows the Batchwell base URL.

curl -fsSL https://batchwell.ai/connect.sh | sh -s -- claude --model batchwell/kimi-k3.1-pro-uncensored does the same in one step. Guide: https://batchwell.ai/docs/clients/claude-code
Shell
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://api.batchwell.ai"
export ANTHROPIC_AUTH_TOKEN="$BATCHWELL_API_KEY"
export ANTHROPIC_MODEL="batchwell/kimi-k3.1-pro-uncensored"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="batchwell/kimi-k3.1-pro-uncensored"
claude

The snippet is made for batchwell/kimi-k3.1-pro-uncensored, a model Batchwell serves today. It reads the key from BATCHWELL_API_KEY, so no key is written into the snippet. Create a key as described in the Quickstart and Authentication, then run the lines in the shell you start Claude Code from. The last line starts Claude Code.

The first line clears ANTHROPIC_API_KEY. If it is set, Claude Code sends it in an x-api-key header, and it conflicts with a Claude login. Leave it unset whenever you use Batchwell.

  • ANTHROPIC_BASE_URL is the address Claude Code sends its requests to. Set it to https://api.batchwell.ai, the Batchwell base URL without /v1: Claude Code adds /v1/messages itself.
  • ANTHROPIC_AUTH_TOKEN is the key Claude Code sends as a bearer token. The snippet copies it from BATCHWELL_API_KEY. The key starts with bw_live_ or bw_test_.
  • ANTHROPIC_MODEL is the model Claude Code uses. Set it to the model id from GET /v1/models; see models.
  • ANTHROPIC_DEFAULT_HAIKU_MODEL is the model Claude Code uses for its background requests. The snippet sets it to the same model so every request reaches a model Batchwell serves. A cheaper Batchwell model id works here too.

Batchwell serves Claude Code's requests at /v1/messages and runs each one as a chat completion on the same key, so credits, limits and usage work as they do for any other request.

That model lists these supported parameters: temperature, top_p, max_tokens, max_completion_tokens, stop, stream_options, tools, tool_choice, reasoning_effort. These are the model's tunable parameters, not the whole request. Batchwell turns each Claude Code request into a chat completion, which accepts the fields listed under accepted fields, including stream and tools.

Batchwell accepts text content only. A request with an image, such as a screenshot pasted into Claude Code, gets 400 unsupported_content. The full list is on chat completions.

  • Connect an agent compares the five agents and every option of the connect command.
  • Errors lists every error code and what to do about it.
  • Codex setup shows the same model in Codex's config.toml.
  • Hermes Agent setup shows the same model in Hermes Agent's config.yaml.