Blog

Using any LLM with Claude Code

The agent run is half done. Its subagents are searching files, and they do not need the largest model to do it. Claudish lets each one use another.

Date
Filed under
Engineering notes
An engineer in a yellow jacket types on a laptop on a pickup tailgate beside green tanks after rain.

Why route to another model

Claudish is a proxy for the Claude Code command line. With it, Claude Code can send its requests to OpenRouter, OpenAI, Gemini or another LLM provider. The agent workflow stays as it is.

  • CostSend subagents and test runs to a cheaper model.
  • ProvidersSwitch between OpenAI, Google, Anthropic or a local model.
  • New modelsTry a model when it is released.
  • Same sessionThe claudish command starts Claude Code as before.

One proxy between CLI and provider

Claude Code makes a request. Claudish takes it and forwards it to the provider named in the model ID. Claude Code asks for a tier (opus, sonnet or haiku), and each tier can map to a different model.

Isometric diagram of a request passing from the Claude Code command line through the Claudish proxy to one of three models, one for each tier.12345
  1. Claude Code command line
  2. Claudish proxy on your machine
  3. Model set for the opus tier
  4. Model set for the sonnet tier
  5. Model set for the haiku tier

What you need first

  1. Claude Code, installed.
  2. An API key from at least one provider: OpenRouter, Gemini, OpenAI or Ollama Cloud.
  3. Without a Pro or Max subscription only: set placeholder Anthropic keys. Subscribers skip this step.
export ANTHROPIC_API_KEY="sk-ant-api03-placeholder"
export ANTHROPIC_AUTH_TOKEN="placeholder"

Install Claudish

Use one of these, whichever package manager you have.

npm install -g claudish
bun install -g claudish
brew install claudish
curl -fsSL https://raw.githubusercontent.com/MadAppGang/claudish/main/install.sh | sh

Optional: run claudish --init to add Claudish as a skill to the current project.

Set models and keys

Claudish reads its models and API keys from environment variables. Set them in two places: your shell and Claude Code's settings file.

VariablePurpose
OPENROUTER_API_KEYSigns requests to OpenRouter
CLAUDISH_MODELDefault model for interactive and single-shot mode
CLAUDISH_MODEL_OPUSModel for opus tier subagents
CLAUDISH_MODEL_SONNETModel for sonnet tier subagents
CLAUDISH_MODEL_HAIKUModel for haiku tier subagents
ANTHROPIC_API_KEYYour Anthropic key, or a placeholder
ANTHROPIC_AUTH_TOKENYour Anthropic token, or a placeholder

Windows

Open sysdm.cpl, then Advanced, then Environment Variables. Add:

ANTHROPIC_API_KEY=your-anthropic-key
ANTHROPIC_AUTH_TOKEN=your-anthropic-token
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxx
CLAUDISH_MODEL=openrouter@openai/gpt-4.1
CLAUDISH_MODEL_OPUS=openrouter@openai/gpt-4.1
CLAUDISH_MODEL_SONNET=openrouter@openai/gpt-4.1-mini
CLAUDISH_MODEL_HAIKU=openrouter@openai/gpt-4.1-nano

Then edit Claude Code's settings at C:\Users\[username]\.claude\settings.json:

{
  "env": {
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
    "OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx",
    "CLAUDISH_MODEL": "openrouter@openai/gpt-4.1",
    "CLAUDISH_MODEL_OPUS": "openrouter@openai/gpt-4.1",
    "CLAUDISH_MODEL_SONNET": "openrouter@openai/gpt-4.1-mini",
    "CLAUDISH_MODEL_HAIKU": "openrouter@openai/gpt-4.1-nano"
  }
}

Check the values in PowerShell:

$env:CLAUDISH_MODEL
$env:OPENROUTER_API_KEY

WSL, Linux and macOS

Create ~/.env:

ANTHROPIC_API_KEY=your-anthropic-key
ANTHROPIC_AUTH_TOKEN=your-anthropic-token
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxx
CLAUDISH_MODEL=openrouter@openai/gpt-4.1
CLAUDISH_MODEL_OPUS=openrouter@openai/gpt-4.1
CLAUDISH_MODEL_SONNET=openrouter@openai/gpt-4.1-mini
CLAUDISH_MODEL_HAIKU=openrouter@openai/gpt-4.1-nano

Load it from ~/.bashrc, ~/.zshrc or ~/.bash_profile:

if [ -f "$HOME/.env" ]; then
    set -a
    source "$HOME/.env"
    set +a
fi

Then edit Claude Code's settings at ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
    "OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx",
    "CLAUDISH_MODEL": "openrouter@openai/gpt-4.1",
    "CLAUDISH_MODEL_OPUS": "openrouter@openai/gpt-4.1",
    "CLAUDISH_MODEL_SONNET": "openrouter@openai/gpt-4.1-mini",
    "CLAUDISH_MODEL_HAIKU": "openrouter@openai/gpt-4.1-nano"
  }
}

Check the values:

source ~/.bashrc
echo $CLAUDISH_MODEL
echo $OPENROUTER_API_KEY

Run a session

Interactive mode

Start a session with your default model. No model picker appears; it starts at once with CLAUDISH_MODEL.

claudish

Single-shot mode

Run one task with one command. Name a model to override the default.

claudish "task description"
claudish --model "openrouter@openai/gpt-4.1" "task description"

Tier routing for subagents

When Claude Code starts a subagent on a given tier, Claudish routes it:

  • The opus tier goes to CLAUDISH_MODEL_OPUS.
  • The sonnet tier goes to CLAUDISH_MODEL_SONNET.
  • The haiku tier goes to CLAUDISH_MODEL_HAIKU.

Claude Code and Claudish side by side

The first line runs Claude Code on its own. The second runs the same task through Claudish.

claude --model sonnet "task"
claudish "task"

Claudish does not keep conversation history. Claude Code does that.

Choose a model

Find models

List every model, search by name, or show the top models.

claudish --models
claudish --models "sonnet"
claudish --models "gpt"
claudish --top-models

Model IDs

A model ID has the form provider@model:

openrouter@openai/gpt-4.1
openrouter@openai/gpt-4.1-mini
openrouter@openai/gpt-4.1-nano
openrouter@anthropic/claude-opus-4-5
openrouter@google/gemini-3-pro
openrouter@deepseek/deepseek-r1

Which setting wins

Claudish reads the tier settings in this order. The first one found is used.

  1. Command-line flags: --model-opus, --model-sonnet, --model-haiku
  2. The CLAUDISH_MODEL_* environment variables
  3. The ANTHROPIC_DEFAULT_*_MODEL environment variables
  4. Profile defaults

Endpoints and usage

Custom API endpoints

Point Claudish at your own endpoint, such as an Ollama server on the local network.

GEMINI_BASE_URL=https://custom-gemini-endpoint.com
OPENAI_BASE_URL=https://custom-openai-endpoint.com
OPENROUTER_BASE_URL=https://custom-openrouter-endpoint.com
OLLAMA_BASE_URL=http://192.168.1.100:11434
OLLAMA_HOST=http://192.168.1.100:11434

Usage and cost

Track what each model used and what it cost on the OpenRouter activity dashboard.

When something does not work

Environment variables not loaded

On WSL, Linux and macOS:

source ~/.bashrc
env | grep CLAUDISH

In Windows PowerShell:

$env:CLAUDISH_MODEL

Model not found

Check that the key is set, then refresh the model list.

echo $OPENROUTER_API_KEY
claudish --models --force-update

Settings not applied

Check the file is in the right place: C:\Users\[username]\.claude\settings.json on Windows , ~/.claude/settings.json elsewhere. Then print the block Claude Code reads:

cat ~/.claude/settings.json | jq '.env'

Language models in a process plant

Claudish gives Claude Code any provider's model: a cheaper one, a new one or one on your own hardware. We also put such models to work for plant staff, on procedures, logs and reports.