This repository lets you use Anthropic's Claude Code with OpenAI's GPT-5 as the "smart" model via a local LiteLLM proxy.
Why the Anthropic API key is still required
Claude Code uses two models: a fast model (for quick actions) and a slow “smart” model. This setup only replaces the slow model with GPT‑5 via the proxy; the fast model still runs on Anthropic, hence the need for the Anthropic API key.
First time using GPT-5 via API?
If you are going to use GPT-5 via API for the first time, OpenAI may require you to verify your identity via Persona. You may encounter an OpenAI error asking you to “verify your organization.” To resolve this, you can go through the verification process here:
-
Clone this repository:
git clone https://github.com/teremterem/claude-code-gpt-5.git cd claude-code-gpt-5 -
Install uv (if you haven't already):
macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | shmacOS (using Homebrew):
brew install uv
Windows (using PowerShell):
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Windows (using Scoop):
scoop install uv
Alternative: pip install
pip install uv
-
Configure Environment Variables: Copy the template file to create your
.env:cp .env.template .env
Edit
.envand add your API keys:OPENAI_API_KEY=your-openai-api-key-here ANTHROPIC_API_KEY=your-anthropic-api-key-here
-
Run the server:
uv run litellm --config config.yaml
-
Install Claude Code (if you haven't already):
npm install -g @anthropic-ai/claude-code
-
Connect to your proxy to use GPT-5 variants:
ANTHROPIC_BASE_URL=http://localhost:4000 claude --model gpt-5-reason-medium
Available models for the
--modelparameter:- GPT-5:
gpt-5-reason-minimalgpt-5-reason-lowgpt-5-reason-mediumgpt-5-reason-high
- GPT-5-mini:
gpt-5-mini-reason-minimalgpt-5-mini-reason-lowgpt-5-mini-reason-mediumgpt-5-mini-reason-high
- GPT-5-nano:
gpt-5-nano-reason-minimalgpt-5-nano-reason-lowgpt-5-nano-reason-mediumgpt-5-nano-reason-high
- GPT-5:
-
That's it! Your Claude Code client will now use the selected GPT-5 variant with your chosen reasoning effort level. 🎯
The Web Search tool currently does not work with this setup. You may see an error like:
API Error (500 {"error":{"message":"Error calling litellm.acompletion for non-Anthropic model: litellm.BadRequestError: OpenAIException - Invalid schema for function 'web_search': 'web_search_20250305' is not valid under any of the given schemas.","type":"None","param":"None","code":"500"}}) · Retrying in 1 seconds… (attempt 1/10)
WORKAROUND: If your request requires searching the web, temporarily switch back to one of the Claude 4 models using the /model command in Claude Code. Claude models remain available alongside gpt-5 and will use the Anthropic API key from your .env.
The Fetch tool DOES work, though (getting web content from specific URLs).
