Skip to main content

Claude Code

What is Claude Code?

Claude Code is Anthropic's official AI coding CLI. It reads your codebase, writes code, runs tests, and iterates — all from your terminal via a conversational interface.

By default Claude Code sends requests directly to Anthropic's API. You can redirect it to BluesMinds by setting two environment variables, keeping the exact same UX while gaining BluesMinds' routing and reliability features.


Why route Claude Code through BluesMinds?

BenefitDetail
Provider fallbackIf Anthropic's API is degraded, BluesMinds automatically retries through an alternative provider.
Rate-limit bypassBluesMinds distributes load so long coding sessions don't hit Anthropic's per-minute limits.
Unified billingOne key, one invoice — whether you use Claude, GPT-4, or any other model.
Privacy controlsDisable prompt logging entirely with a single header.

Prerequisites

Install Claude Code globally via npm:

npm install -g @anthropic-ai/claude-code

Confirm the installation:

claude --version

Obtain your BluesMinds API key from the BluesMinds Console.


Environment Variable Configuration

Set the following two environment variables before running claude:

VariableValue
ANTHROPIC_BASE_URLhttps://api.bluesminds.com/
ANTHROPIC_API_KEYYour BluesMinds API key (sk-…)

Note: Claude Code also checks ANTHROPIC_API_URL on some versions. Setting both is safe — the ANTHROPIC_BASE_URL variable takes precedence in current releases.

One-off (inline):

ANTHROPIC_BASE_URL=https://api.bluesminds.com/ \
ANTHROPIC_API_KEY=sk-your-bluesminds-key \
claude

Persistent (shell profile):

Add the following to your ~/.zshrc or ~/.bashrc:

export ANTHROPIC_BASE_URL=https://api.bluesminds.com/
export ANTHROPIC_API_KEY=sk-your-bluesminds-key

Then reload:

source ~/.zshrc  # or source ~/.bashrc

.env File Approach

If you prefer to keep credentials in a project-level file (add it to .gitignore!):

.env
ANTHROPIC_BASE_URL=https://api.bluesminds.com/
ANTHROPIC_API_KEY=sk-your-bluesminds-key

Load it before invoking Claude Code:

export $(cat .env | xargs) && claude

Or use dotenv-cli:

npx dotenv-cli -- claude

Selecting a Model

Pass the --model flag to override the default:

ANTHROPIC_BASE_URL=https://api.bluesminds.com/ \
ANTHROPIC_API_KEY=sk-your-bluesminds-key \
claude --model claude-sonnet-4-5

BluesMinds supports the full range of Anthropic model IDs. Check the BluesMinds Models page for the complete, up-to-date list. Common examples:

Model IDDescription
claude-opus-4-5Most capable; best for complex, multi-step tasks
claude-sonnet-4-5Balanced performance and speed (recommended)
claude-haiku-3-5Fastest and lowest cost
claude-sonnet-3-7Previous Sonnet generation

CLI Usage Examples

# Start an interactive Claude Code session via BluesMinds
ANTHROPIC_BASE_URL=https://api.bluesminds.com/ \
ANTHROPIC_API_KEY=sk-your-bluesminds-key \
claude

# Non-interactive: one-shot prompt
ANTHROPIC_BASE_URL=https://api.bluesminds.com/ \
ANTHROPIC_API_KEY=sk-your-bluesminds-key \
claude -p "Explain the function in src/utils.ts"

# Use a specific model
ANTHROPIC_BASE_URL=https://api.bluesminds.com/ \
ANTHROPIC_API_KEY=sk-your-bluesminds-key \
claude --model claude-opus-4-5

Quick Reference

# For Claude Code and Anthropic SDK tools
export ANTHROPIC_API_KEY=sk-your-bluesminds-key
export ANTHROPIC_BASE_URL=https://api.bluesminds.com/

# Older Claude Code versions may also need:
export ANTHROPIC_API_URL=https://api.bluesminds.com/

BluesMinds automatically maps the Anthropic message format to and from the appropriate upstream provider.


Troubleshooting

SymptomFix
Authentication errorConfirm ANTHROPIC_API_KEY is set and starts with sk-. Run echo $ANTHROPIC_API_KEY to verify.
Model not foundCheck the model ID on the BluesMinds Models page. BluesMinds uses the same model IDs as Anthropic.
Connection refused / ECONNREFUSEDVerify ANTHROPIC_BASE_URL is exactly https://api.bluesminds.com/ — no trailing slash.
Claude Code ignores env varsEnsure variables are exported in the same shell session. echo $ANTHROPIC_BASE_URL should print the URL.
Still hitting Anthropic directlySome older Claude Code versions use ANTHROPIC_API_URL instead. Try setting that variable as well: export ANTHROPIC_API_URL=https://api.bluesminds.com/
Auth errors (401/403)1. Re-copy your key from the BluesMinds Console. 2. Ensure no extra spaces or line breaks. 3. Confirm the key starts with sk-.
Connection timeoutVerify connectivity: curl https://api.bluesminds.com//models -H "Authorization: Bearer sk-your-key"
Tool uses wrong endpointSome tools cache the base URL. Restart the tool — or open a new terminal — after changing env vars.
Responses seem slowTry a lighter model for faster responses (e.g., claude-haiku-3-5).
Context window errorsSwitch to a model with a larger context window (e.g., claude-opus-4-5 supports 200k).

Next Steps