Getting StartedClaude CodeInstallationConnect GPT Models

How to Connect Claude Code to GPT Models

Why Would You Do This?

The supply of Claude models is currently quite unstable, and Anthropic’s account ban policy is fairly strict. If you want:

  • A stable user experience
  • An excellent large language model
  • To keep Claude Code’s best-in-class Agent ecosystem

Then you can use Claude Code as the front-end Agent paired with OpenAI’s GPT models as the back-end LLM. This gives you a top-tier Coding Agent backed by a very capable GPT model — the experience is quite good.

Prerequisites

  1. Claude Code is already installed and configured
  2. Connected to the CC Club back-end API (see Configure Base URL and Auth Token)

Configure Environment Variables

You need to configure the following environment variables to point Claude Code’s models at the GPT series:

Environment VariableRecommended ValueDescription
ANTHROPIC_DEFAULT_HAIKU_MODELgpt-5.4-miniLightweight model, used for simple tasks
ANTHROPIC_DEFAULT_OPUS_MODELgpt-5.4-maxAdvanced model, used for complex tasks
ANTHROPIC_DEFAULT_SONNET_MODELgpt-5.4Default model, balanced choice
ANTHROPIC_MODELgpt-5.4Primary model
ANTHROPIC_REASONING_MODELgpt-5.4Reasoning model

Only the GPT models listed above are currently supported. If you need additional models in the future, please contact us via the customer service agent in the bottom-right corner.

Choose the configuration method for your operating system:

Method 1: Temporary (current terminal session only)

Execute directly in the terminal:

export ANTHROPIC_DEFAULT_HAIKU_MODEL="gpt-5.4-mini"
export ANTHROPIC_DEFAULT_OPUS_MODEL="gpt-5.4-max"
export ANTHROPIC_DEFAULT_SONNET_MODEL="gpt-5.4"
export ANTHROPIC_MODEL="gpt-5.4"
export ANTHROPIC_REASONING_MODEL="gpt-5.4"

This method only takes effect in the current terminal session. It will expire when you exit the terminal. This is ideal for temporarily switching models.

Quick Alternative: Simpler Temporary Switch

If you only want to temporarily switch the primary model, there is an even simpler way — specify the model directly when launching Claude Code:

claude --model gpt-5.4

You can copy the command above and run it directly — very convenient.

⚠️

The --model flag only affects the primary model; it does not override the higher-tier (Opus) or lower-tier (Haiku) models. If you need to override all models, use the environment variable approach above.

Method 2: Permanent (Recommended)

Write the environment variables into your shell configuration file. Choose the file that matches your shell:

  • zsh (macOS default): edit ~/.zshrc
  • bash: edit ~/.bashrc or ~/.bash_profile

Add the following lines at the end of the file:

# Claude Code configuration for GPT models
export ANTHROPIC_DEFAULT_HAIKU_MODEL="gpt-5.4-mini"
export ANTHROPIC_DEFAULT_OPUS_MODEL="gpt-5.4-max"
export ANTHROPIC_DEFAULT_SONNET_MODEL="gpt-5.4"
export ANTHROPIC_MODEL="gpt-5.4"
export ANTHROPIC_REASONING_MODEL="gpt-5.4"

After saving, execute the following command to apply the configuration immediately:

# zsh users
source ~/.zshrc
 
# bash users
source ~/.bashrc

Restart the Terminal to Apply the Configuration

⚠️

After configuration, you must fully exit and reopen the terminal for the environment variables to take effect.

  • Terminal users: Close the current terminal window and open a new one
  • Cursor users: Fully quit Cursor (not just close the window — quit the application), then reopen Cursor
  • VS Code users: Fully quit VS Code, then reopen it

Verify the Configuration

After reopening the terminal, run the following commands to verify the environment variables are set correctly:

echo "ANTHROPIC_MODEL=$ANTHROPIC_MODEL"
echo "ANTHROPIC_REASONING_MODEL=$ANTHROPIC_REASONING_MODEL"
echo "ANTHROPIC_DEFAULT_SONNET_MODEL=$ANTHROPIC_DEFAULT_SONNET_MODEL"
echo "ANTHROPIC_DEFAULT_OPUS_MODEL=$ANTHROPIC_DEFAULT_OPUS_MODEL"
echo "ANTHROPIC_DEFAULT_HAIKU_MODEL=$ANTHROPIC_DEFAULT_HAIKU_MODEL"

If the configuration is correct, you should see output similar to:

ANTHROPIC_MODEL=gpt-5.4
ANTHROPIC_REASONING_MODEL=gpt-5.4
ANTHROPIC_DEFAULT_SONNET_MODEL=gpt-5.4
ANTHROPIC_DEFAULT_OPUS_MODEL=gpt-5.4-max
ANTHROPIC_DEFAULT_HAIKU_MODEL=gpt-5.4-mini

If the output is empty or still shows the old value, please confirm:

  1. The environment variables were correctly written to the configuration file
  2. The terminal was fully restarted (not just opening a new tab)
  3. Cursor / VS Code users need to fully quit the application and reopen it

Once verification passes, launch Claude Code to start developing with GPT models.


MIT 2026 © Nextra.
加入社群CC Club返回官网