Yomi APIYomi APIDocs Open console

中文

Yomi API / Documentation / Claude Code CLI

Connect an agent

Claude Code CLI

Claude Code is an AI coding assistant that runs in your terminal. Set a few environment variables to call claude-sonnet-5 and claude-opus-4-8 through Yomi API.

Prerequisites

  • Node.js: 18 or later.
  • Windows users: Install Git for Windows as well.
  • API key: Create a key in the console's API Keys page, copy it and store it safely. It is visible only at creation.

Installation

Install globally with npm. The command is the same on macOS, Linux and Windows:

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

Run the following command. A version number confirms successful installation:

claude --version

Configure Yomi API

Claude Code reads connection settings from environment variables:

  • ANTHROPIC_BASE_URL: The platform address, fixed at https://api.yomiapi.com. Do not append /v1.
  • ANTHROPIC_AUTH_TOKEN: Your API key.
  • ANTHROPIC_MODEL: The default main model. This example uses claude-sonnet-5; you can change it to claude-opus-4-8.
  • The other three settings: Pin the Opus, Sonnet and subagent use cases to models in the platform catalog.
ANTHROPIC_BASE_URL is required. Without it, Claude Code sends requests to Anthropic's official servers instead of Yomi API.

macOS / Linux

Append the following to ~/.zshrc (for bash, use ~/.bashrc):

export ANTHROPIC_BASE_URL=https://api.yomiapi.com
export ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY
export ANTHROPIC_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-8
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
export CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-5

After saving, run source ~/.zshrc or reopen the terminal to apply the settings.

Windows

Run these commands in order. setx writes the variables to your user environment:

setx ANTHROPIC_BASE_URL "https://api.yomiapi.com"
setx ANTHROPIC_AUTH_TOKEN "YOUR_API_KEY"
setx ANTHROPIC_MODEL "claude-sonnet-5"
setx ANTHROPIC_DEFAULT_OPUS_MODEL "claude-opus-4-8"
setx ANTHROPIC_DEFAULT_SONNET_MODEL "claude-sonnet-5"
setx CLAUDE_CODE_SUBAGENT_MODEL "claude-sonnet-5"

setx only applies to new terminals. Close and reopen your terminal after running these commands.

Start and verify

Open your project directory and start Claude Code:

claude
  1. Enter a simple task, such as "Explain this project's directory structure." A normal response confirms that the connection works.
  2. Sign in to the console and check "Usage" in the User Center. The corresponding record confirms that the request went through Yomi API.

Common questions

What if startup returns a 401 authentication error?

Check that ANTHROPIC_AUTH_TOKEN is a valid key from API Keys and was copied in full (starting with sk-). If the key was deleted or disabled, create a new one and update the environment variable.

Why are requests still sent to Anthropic?

Usually ANTHROPIC_BASE_URL has not taken effect. On macOS or Linux, run echo $ANTHROPIC_BASE_URL; on Windows, reopen the terminal and run echo %ANTHROPIC_BASE_URL%. The output should be https://api.yomiapi.com. Empty output means the setting was not saved or the terminal was not reopened.

What if the model is unavailable?

Use a model ID from the platform catalog (such as claude-sonnet-5, claude-opus-4-8) and make sure your key's group includes that model. Select the group when creating a key in API Keys; available models are listed under Models in the console.