CCHPCCHPDocs
↑↓↵pagefind

Chapter 4013 min read

Connect Claude Code

Install Claude Code, connect it to CCHP with a configuration manager or by editing its config file manually, and verify the connection.

Claude Code is Anthropic’s command-line coding assistant. After installation, use a configuration manager or configure it manually to use the CCHP gateway, an LLM key, and models your organization provides.

What you need#

  • LLM key: A full key whose status is Active (not the masked key in the list). If you don’t have one yet, see Create an LLM key.
  • Gateway URL: In the console sidebar, click API Keys, then copy the URL in the Claude row of the API base URLs card at the top of the page, for example https://api.cchp.example.com. This URL has no /v1 at the end, because Claude Code adds the request path itself. If the page doesn’t show this card, ask your admin for the gateway URL.

Already installed Claude Code? Skip to configuration.

Step 1: Install Claude Code#

Select your operating system and use any one of the installation methods. The first method in each tab is the officially recommended one. Don’t run claude right after you install it: until the gateway is configured, Claude Code asks you to sign in to a claude.ai account on first launch. Start it after you finish configuring CCHP.

System requirements: macOS 13.0 or later, Apple silicon or Intel, and at least 4 GB of RAM.

Official install script (recommended)

Open Terminal and run:

bash
curl -fsSL https://claude.ai/install.sh | bash

The install script shows no progress while it downloads. It installs the program to ~/.local/bin/claude, and the program then updates automatically in the background. You can also run claude update at any time to update right away.

If running claude prints command not found: claude, the install directory isn’t on your PATH. macOS uses Zsh by default. Run the two lines below to add the directory to your PATH:

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

If you use Bash, replace ~/.zshrc in both lines with ~/.bash_profile.

Homebrew

If you have Homebrew installed, run:

bash
brew install --cask claude-code

claude-code follows the stable channel and is usually about a week behind the latest version. To use the latest version, install claude-code@latest instead:

bash
brew install --cask claude-code@latest

Homebrew installations don’t update automatically, so run brew upgrade claude-code regularly. If you installed claude-code@latest, run brew upgrade claude-code@latest. If the installation prints No Cask with this name exists, run brew update first and try again.

npm

Requires Node.js 22 or later. Run:

bash
npm install -g @anthropic-ai/claude-code

Don’t use sudo npm install -g, to avoid permission issues. npm installs the same program as the official install script. To upgrade right away, run npm install -g @anthropic-ai/claude-code@latest, not npm update -g.

After the installation finishes, open a new terminal window and run:

bash
claude --version

Result: The terminal prints a version number followed by (Claude Code). If claude can’t be found, add the install directory to your PATH as described in the tab for your system above. To check the installation and the settings files further, run claude doctor. This command only runs checks and doesn’t start a session.

After installation: Configure CCHP#

Recommended: Use Magpie or CC Switch to configure CCHP through a graphical interface. Once you verify the connection in that guide, you can start using the client without following the manual steps on this page.

Edit the config file manually: Start at step 2 to check the key and models, then edit the config file in step 3. You can also set environment variables for the current terminal only. The status check in step 4 is for the manual configuration.

Step 2: Check that your key works and list available models#

Run the command below in a terminal. Replace the URL with your gateway URL, and replace cch_llm_live_xxxxxxxx with your full key. This request doesn’t call a model and doesn’t incur any cost.

bash
curl "https://api.cchp.example.com/v1/models?limit=1000" \
  -H "Authorization: Bearer cch_llm_live_xxxxxxxx" \
  -H "anthropic-version: 2023-06-01"

In the returned data, the id of each item is a model ID.

Result: The response lists the models that this key can call in Claude Code. Note the models you want to use, because you enter their model IDs in step 3. If you get 401, check that you copied the whole key and that the key is still valid. If the connection fails, check the gateway URL.

The list may also include models from other vendors. Claude Code is designed for Claude models, so enter Claude model IDs in step 3. For the price of each model, see View available models.

Step 3: Write the Claude Code settings#

Write the settings to Claude Code’s user settings file so that they apply to all your projects and terminals. Open the settings file, or create it if it doesn’t exist:

  • macOS, Linux, and WSL: ~/.claude/settings.json
  • Windows: %USERPROFILE%\.claude\settings.json

Add the following content, and replace the URL, key, and models with your own values. If the file already has other settings, merge only these keys into the existing env.

settings.jsonjson
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.cchp.example.com",
    "ANTHROPIC_AUTH_TOKEN": "cch_llm_live_xxxxxxxx",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}
  • ANTHROPIC_BASE_URL: The gateway URL. Don’t add /v1 at the end. Otherwise, the gateway returns 404 with a message that starts with no API endpoint matches.
  • ANTHROPIC_AUTH_TOKEN: Your LLM key. Claude Code sends it in the Authorization: Bearer header. You can use ANTHROPIC_API_KEY instead (sent in the x-api-key header), which the gateway also accepts, but Claude Code asks you to confirm the key the first time you use it.
  • ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL: The models that Claude Code’s Opus, Sonnet, and Haiku tiers call. Enter model IDs from the list in step 2. By default, Claude Code requests its built-in model names, which your organization may not provide, so requests may return 404 if you don’t set these variables. If only a few models are available, you can set all three variables to the same model. When ANTHROPIC_DEFAULT_HAIKU_MODEL is set, background tasks such as generating session titles also use that model.

Warning: Don’t put your key in the .claude/settings.json file in your project directory. That file is usually committed to the code repository, so everyone with access to the repository can see your key.

Use in the current terminal only#

If you don’t want to edit the settings file, set the same environment variables in a terminal, then run claude in that terminal:

bash
export ANTHROPIC_BASE_URL="https://api.cchp.example.com"
export ANTHROPIC_AUTH_TOKEN="cch_llm_live_xxxxxxxx"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"

These variables apply only to the current terminal and the programs started from it. To make them apply in new terminals too, add these lines to ~/.zshrc, ~/.bashrc, or your PowerShell profile $PROFILE. If the same variable is set in both the settings file and the terminal, the settings file takes precedence.

Step 4: Start Claude Code and check the connection#

Check the connection status#

Open a new terminal, go to your project directory, and run claude. The first time Claude Code starts in a folder, it asks whether you trust the folder. Confirm to enter the session. Then enter /status.

Result: On the Status tab, the Anthropic base URL line shows your gateway URL, and the Auth token line shows ANTHROPIC_AUTH_TOKEN. If there is no Anthropic base URL line, Claude Code didn’t read your settings. Check the location of the settings file and its JSON syntax.

Send a message#

Press Esc to close the status screen, then send any message, for example Hello.

Result: Claude replies normally.

View the request in Call Records#

In the console sidebar, click Call Records (a platform super admin’s sidebar shows Usage Records instead) to open the Request Logs page.

Result: In the latest record, the Model column shows the model you used, the Key column shows the name of this key, and the Status column shows 200. To see only the requests of this key, in API Keys, click the View request logs icon in the Actions column of the key’s row (when the table is narrow, the actions are collapsed into the menu at the end of the row).

Switch models#

  • In Claude Code, enter /model and select Opus, Sonnet, or Haiku. The model that is actually called is the one you set for that tier in step 3.
  • To use a model outside the three tiers, enter /model followed by the model ID, for example /model claude-fable-5-1, or start Claude Code with claude --model claude-fable-5-1.
  • To see the models that the gateway provides directly in the /model list, add "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" to env in the settings file. When Claude Code starts, it reads the gateway’s model list and adds only the models whose IDs contain claude or anthropic.

Frequently asked questions#

How do I troubleshoot Claude Code errors?#

Look up the status code and message from the error in the table below:

ErrorCauseFix
Unable to connect to API, or the message contains ConnectionRefused or ENOTFOUNDThe gateway URL is wrong, or the network is unreachableCheck the URL with the command from step 2
404, no API endpoint matches ...The gateway URL has an extra /v1 at the endRemove the /v1 from the end of ANTHROPIC_BASE_URL
401, invalid LLM tokenThe key was entered incorrectly, or it is disabled, expired, or revokedCheck the key’s status in API Keys, then copy the key again or create a new one
404, no provider serves the requested modelYour organization doesn’t provide the model that Claude Code requestedSet the three tier models to models from the step 2 list as in step 3, or switch to another model with /model
403, requested model is not allowed by this API key, or another message about the modelThe key can’t call this modelUse a model from the step 2 list. For other fixes, see the frequently asked questions in View available models
403, this client is not allowed for the organization or teamYour organization or team has turned on Client restriction and doesn’t allow Claude CodeAsk your organization admin to allow Claude Code in the organization’s or team’s Client restriction
402Your wallet balance is too low, or the postpaid organization’s postpaid credit for this month is used upSee Provider groups and your final price
429, for example user_key rpm exceededYou reached one of your limitsSee the limits in Create an LLM key
400, and the message contains Extra inputs are not permitted or context_managementThe upstream that handles the request doesn’t accept some of the new feature fields that Claude Code sendsAdd "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1" to env in the settings file. If the error persists, contact your admin

Why does Claude Code still ask me to sign in after it starts?#

Claude Code didn’t read your key. Make sure that ANTHROPIC_AUTH_TOKEN is in env in the user settings file ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows), that the variable name is spelled correctly, and that the file is valid JSON. You can also set it in the terminal as described in “Use in the current terminal only” in step 3. If the key is only in a settings file in your project directory, Claude Code can’t read it during the sign-in step on first launch.

What do I do if Claude Code says there are two credential sources at startup?#

You signed in to Claude Code with a claude.ai account before. When ANTHROPIC_AUTH_TOKEN is set, requests go to the gateway with your LLM key, and the saved sign-in is no longer used. To remove this message, run /logout in Claude Code to clear the saved sign-in.

How do I configure the VS Code extension?#

The Claude Code extension for VS Code checks for sign-in credentials before it starts, and this check doesn’t read ~/.claude/settings.json. In the VS Code Command Palette, run Preferences: Open User Settings (JSON) and add the following content. Replace the URL and the key with your own values:

settings.jsonjson
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://api.cchp.example.com" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "cch_llm_live_xxxxxxxx" }
  ]
}

The extension also uses the model settings from the settings file in step 3.