Skip to content

Latest commit

 

History

History
115 lines (86 loc) · 3.87 KB

File metadata and controls

115 lines (86 loc) · 3.87 KB

Claude Code with GPT-5

This repository lets you use Anthropic's Claude Code with OpenAI's GPT-5 as the "smart" model via a local LiteLLM proxy.

Quick Start ⚡

Prerequisites

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:

Setup 🛠️

  1. Clone this repository:

    git clone https://github.com/teremterem/claude-code-gpt-5.git
    cd claude-code-gpt-5
  2. Install uv (if you haven't already):

    macOS/Linux:

    curl -LsSf https://astral.sh/uv/install.sh | sh

    macOS (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
  3. Configure Environment Variables: Copy the template file to create your .env:

    cp .env.template .env

    Edit .env and add your API keys:

    OPENAI_API_KEY=your-openai-api-key-here
    ANTHROPIC_API_KEY=your-anthropic-api-key-here
  4. Run the server:

    uv run litellm --config config.yaml

Using with Claude Code 🎮

  1. Install Claude Code (if you haven't already):

    npm install -g @anthropic-ai/claude-code
  2. 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 --model parameter:

    • GPT-5:
      • gpt-5-reason-minimal
      • gpt-5-reason-low
      • gpt-5-reason-medium
      • gpt-5-reason-high
    • GPT-5-mini:
      • gpt-5-mini-reason-minimal
      • gpt-5-mini-reason-low
      • gpt-5-mini-reason-medium
      • gpt-5-mini-reason-high
    • GPT-5-nano:
      • gpt-5-nano-reason-minimal
      • gpt-5-nano-reason-low
      • gpt-5-nano-reason-medium
      • gpt-5-nano-reason-high
  3. That's it! Your Claude Code client will now use the selected GPT-5 variant with your chosen reasoning effort level. 🎯

KNOWN PROBLEM

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).

P. S. You are very welcome to join our MiniAgents Discord Server 👥