> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syon.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code 命令行

> 将 Claude Code CLI 接入 Syon

This guide is for using Claude Code in a terminal. If you are not comfortable with command-line tools, download the Claude desktop app from the [Claude website](https://claude.ai/downloads) and follow the [CC Switch guide](https://docs.syon.ai/install-cc-switch).

## 1. Install Claude Code from scratch

Claude Code is an AI coding assistant that runs inside your terminal. If Claude Code is already installed, skip to the next section.

### Download and install

Install Node.js before installing Claude Code, so the package can download and run correctly.

* Download and install [Node.js](https://nodejs.org/en/download/) (version 18 or newer).

![Image 1: Node.js download page](https://docs.syon.ai-images/en/install-claude-code-terminal-1.png)

After installation, you do not need to open Node.js separately.

* Windows users should also install [Git for Windows](https://git-scm.com/download/win).

![Image 2: Git for Windows download page](https://docs.syon.ai-images/en/install-claude-code-terminal-2.png)

After installation, you do not need to open Git separately.

After the prerequisites are installed, open your terminal.

On macOS, search for Terminal in Applications and open it.

On Windows 11, press `Win + S`, search for Terminal, and open it.

On Windows 10, press `Win + S`, search for Terminal, then open Command Prompt.

Copy and run the command below:

bash

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

After installation, run:

bash

```
claude --version
```

If a version such as `x.x.xxx (Claude Code)` appears, Claude Code is installed successfully.

### Configure environment variables

For Linux and macOS, write the following variables into your shell config file. The script detects zsh or bash automatically. Create your API key in the [Syon dashboard](https://syon.com/dashboard?tab=api-keys).

bash

```
SHELL_RC="$HOME/.zshrc"; case "$SHELL" in *bash*) SHELL_RC="$HOME/.bashrc";; esac
cat >> "$SHELL_RC" <<'EOF'
export ANTHROPIC_BASE_URL=https://api.syon.com
export ANTHROPIC_AUTH_TOKEN="your Syon API Key"
export ANTHROPIC_MODEL=claude-opus-4-8
export ANTHROPIC_DEFAULT_FABLE_MODEL=claude-fable-5-1
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-8
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
export CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-5
export CLAUDE_CODE_EFFORT_LEVEL=xhigh
EOF
source "$SHELL_RC"
```

For Windows, run the following commands in PowerShell. They use `setx` to write user-level environment variables permanently. Reopen the terminal after running them.

powershell

```
setx ANTHROPIC_BASE_URL "https://api.syon.com"
setx ANTHROPIC_AUTH_TOKEN "your Syon API Key"
setx ANTHROPIC_MODEL "claude-opus-4-8"
setx ANTHROPIC_DEFAULT_FABLE_MODEL "claude-fable-5-1"
setx ANTHROPIC_DEFAULT_OPUS_MODEL "claude-opus-4-8"
setx ANTHROPIC_DEFAULT_SONNET_MODEL "claude-sonnet-5"
setx ANTHROPIC_DEFAULT_HAIKU_MODEL "claude-haiku-4-5"
setx CLAUDE_CODE_SUBAGENT_MODEL "claude-sonnet-5"
setx CLAUDE_CODE_EFFORT_LEVEL "xhigh"
```

### Launch Claude Code

In PowerShell or your terminal, run:

bash

```
claude
```

![Image 3: Claude Code launch example](https://docs.syon.ai-images/en/install-claude-code-terminal-6.png)

## 2. Connect to Syon

If Claude Code is already installed, update the environment variables below. Create your API key in the [Syon dashboard](https://syon.com/dashboard?tab=api-keys).

For Linux and macOS:

bash

```
SHELL_RC="$HOME/.zshrc"; case "$SHELL" in *bash*) SHELL_RC="$HOME/.bashrc";; esac
cat >> "$SHELL_RC" <<'EOF'
export ANTHROPIC_BASE_URL=https://api.syon.com
export ANTHROPIC_AUTH_TOKEN="your Syon API Key"
export ANTHROPIC_MODEL=claude-opus-4-8
export ANTHROPIC_DEFAULT_FABLE_MODEL=claude-fable-5-1
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-8
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
export CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-5
export CLAUDE_CODE_EFFORT_LEVEL=xhigh
EOF
source "$SHELL_RC"
```

For Windows PowerShell:

powershell

```
setx ANTHROPIC_BASE_URL "https://api.syon.com"
setx ANTHROPIC_AUTH_TOKEN "your Syon API Key"
setx ANTHROPIC_MODEL "claude-opus-4-8"
setx ANTHROPIC_DEFAULT_FABLE_MODEL "claude-fable-5-1"
setx ANTHROPIC_DEFAULT_OPUS_MODEL "claude-opus-4-8"
setx ANTHROPIC_DEFAULT_SONNET_MODEL "claude-sonnet-5"
setx ANTHROPIC_DEFAULT_HAIKU_MODEL "claude-haiku-4-5"
setx CLAUDE_CODE_SUBAGENT_MODEL "claude-sonnet-5"
setx CLAUDE_CODE_EFFORT_LEVEL "xhigh"
```

After configuration, reopen your terminal and run:

bash

```
claude
```
