Skip to main content
Claude Code speaks only the Anthropic Messages API. The Fortytwo API serves Chat Completions, so Claude Code connects through a local LiteLLM proxy that translates between the two. This setup needs Python, Node.js and a terminal. Anthropic does not support Claude Code with models other than Claude.
Before you start: create a Fortytwo API key and buy credits — see Quickstart, step 1. Give each agent its own key with a Spend limit.
1

Install LiteLLM and Claude Code

The LiteLLM version is pinned. Upgrade it on purpose: a new release can change how LiteLLM translates Messages requests.
2

Configure LiteLLM

Create litellm.yaml:
litellm.yaml
Use the custom_openai/ prefix: with openai/, LiteLLM sends Messages requests to the Responses API, which the Fortytwo API does not serve. The same file works for the Codex guide.The master key is a password for your local LiteLLM proxy; LiteLLM does not start without it. You do not get it anywhere: make up any string that starts with sk-, or let the command in the next step create a random one. Claude Code sends it to LiteLLM; LiteLLM sends your Fortytwo key to Fortytwo.
3

Start LiteLLM

The echo line prints the master key: copy it for the next step. Keep this terminal open while you use Claude Code.
4

Start Claude Code

In a second terminal, in your project folder:
  • ANTHROPIC_AUTH_TOKEN replaces the sign-in: Claude Code does not ask for an Anthropic account.
  • The ANTHROPIC_DEFAULT_* and CLAUDE_CODE_SUBAGENT_MODEL lines send Claude Code’s background tasks and subagents to the same model. Without them, Claude Code asks LiteLLM for Claude models that it does not have.
  • CLAUDE_CODE_MAX_CONTEXT_TOKENS sets the model’s context window. Without it, Claude Code does not recognise the model and assumes 200,000 tokens.
Another model works the same way: take its ID, context window and max output from Models.On the first start, Claude Code asks for a text style and whether you trust the folder.
LiteLLM passes the model’s reasoning to Claude Code as thinking. More options: Claude Code LLM gateways , LiteLLM: Claude Code with non-Anthropic models .
Something not working with your agent, or using one we have not listed? Tell us in the platform: Feedback for ideas and small bugs, Contact support if it blocks your work, or Report a security issue.
Last modified on November 13, 2026