编程工具接入Coding tools

Claude Code、Codex CLI、Gemini CLI、OpenCode 和 VS Code 插件的配置方法。配置里的 sk-你的密钥 换成你自己的密钥,模型名换成你的分组里有的模型。How to set up Claude Code, Codex CLI, Gemini CLI, OpenCode and VS Code extensions. Replace sk-your-key with your own key and use a model your key’s group offers.

登录后打开控制台的接入教程,选好工具和密钥,配置会自动填好地址、模型和完整密钥,一键复制。

先选对分组

每把密钥属于一个分组,分组决定能用哪些模型、走哪种协议。建密钥时按要用的工具选:

  • Claude Code:Claude 开头的分组(Anthropic 协议)。
  • Codex CLI:ChatGPT 开头的分组(Responses 协议)。ChatGPT 分组的密钥不能用在 Claude Code。
  • Gemini CLI:Gemini 分组。
  • OpenCode、VS Code 插件、Cherry Studio:任意分组都行,国产模型(DeepSeek、Kimi、GLM、Qwen)推荐用这几个。

Claude Code

安装(需要 Node.js 18+):npm install -g @anthropic-ai/claude-code。地址不带 /v1,Claude Code 会自己拼。

长期有效:写进 ~/.claude/settings.json(Windows 为 %USERPROFILE%\.claude\settings.json),文件已存在就只合并 env 这几行:

settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tokenflow365.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-你的密钥",
    "ANTHROPIC_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}

只在当前终端试一下:

export ANTHROPIC_BASE_URL="https://api.tokenflow365.com"
export ANTHROPIC_AUTH_TOKEN="sk-你的密钥"
claude

ANTHROPIC_DEFAULT_HAIKU_MODEL 是后台小任务用的模型,分组里没有 Haiku 就填和 ANTHROPIC_MODEL 一样的模型。启动后仍要求登录 Anthropic 账号的话,在用户目录的 .claude.json 里加 "hasCompletedOnboarding": true 后重开终端。

Codex CLI

安装:npm install -g @openai/codex。配置写进 ~/.codex/config.toml,model_provider 和 model 两行放在文件最上面:

config.toml
model_provider = "tokenflow"
model = "gpt-6.2-sol"

[model_providers.tokenflow]
name = "TokenFlow"
base_url = "https://api.tokenflow365.com/v1"
env_key = "TOKENFLOW_API_KEY"
wire_api = "responses"
# 加到 ~/.zshrc 或 ~/.bashrc 末尾,重开终端
export TOKENFLOW_API_KEY="sk-你的密钥"

在项目目录里运行 codex。

Gemini CLI

安装:npm install -g @google/gemini-cli。新建 ~/.gemini/.env,地址不带版本号:

.env
GOOGLE_GEMINI_BASE_URL=https://api.tokenflow365.com
GEMINI_API_KEY=sk-你的密钥
GEMINI_MODEL=gemini-4-argon

运行 gemini,第一次启动选「Use Gemini API Key」。

OpenCode

安装:npm install -g opencode-ai。配置写进 ~/.config/opencode/opencode.json,models 里可以列多个模型,启动后用 /models 切换:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tokenflow": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "TokenFlow",
      "options": {
        "baseURL": "https://api.tokenflow365.com/v1",
        "apiKey": "sk-你的密钥"
      },
      "models": {
        "deepseek-v4.1-flash": { "name": "deepseek-v4.1-flash" }
      }
    }
  },
  "model": "tokenflow/deepseek-v4.1-flash"
}

Cline / Roo Code / Kilo Code

在 VS Code 扩展市场安装任意一个,设置页里填:

API ProviderOpenAI Compatible
Base URLhttps://api.tokenflow365.com/v1
API Key控制台创建的密钥
Model ID平台模型 ID,例如 claude-opus-5-5、kimi-k3.1-pro

CC Switch 与 Cherry Studio 一键导入

装了 CC Switch 或 Cherry Studio 的话,在控制台「API 密钥」列表点「导入客户端」,或在「接入教程」里点一键导入,地址、密钥和模型会自动写进客户端。其他客户端的填法见第三方工具接入。

怎么确认接通了

在工具里随便问一句,然后到控制台消费记录看:有这次调用和扣费,就说明接好了。报错的话对照错误码排查,最常见的是密钥分组和工具不匹配、模型名写成了展示名、地址多写或少写了 /v1。

Signed in? Open the setup guide in the console, pick a tool and a key, and copy settings with the address, model and full key already filled in.

Pick the right group first

Every key belongs to a group, which decides the models and the protocol it can use. When creating a key, pick by tool:

  • Claude Code: a group whose name starts with Claude (Anthropic protocol).
  • Codex CLI: a group whose name starts with ChatGPT (Responses protocol). Keys in ChatGPT groups do not work in Claude Code.
  • Gemini CLI: the Gemini group.
  • OpenCode, VS Code extensions, Cherry Studio: any group; these are the best fit for DeepSeek, Kimi, GLM and Qwen.

Claude Code

Install (Node.js 18+): npm install -g @anthropic-ai/claude-code. The address has no /v1; Claude Code adds it.

To keep it: put this in ~/.claude/settings.json (on Windows %USERPROFILE%\.claude\settings.json). If the file exists, merge only the env entries:

settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tokenflow365.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key",
    "ANTHROPIC_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}

For the current terminal only:

export ANTHROPIC_BASE_URL="https://api.tokenflow365.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"
claude

ANTHROPIC_DEFAULT_HAIKU_MODEL is used for small background tasks; if your group has no Haiku model, use the same model as ANTHROPIC_MODEL. If Claude Code still asks you to sign in to Anthropic, add "hasCompletedOnboarding": true to .claude.json in your home folder and reopen the terminal.

Codex CLI

Install: npm install -g @openai/codex. Put this in ~/.codex/config.toml, keeping model_provider and model at the top of the file:

config.toml
model_provider = "tokenflow"
model = "gpt-6.2-sol"

[model_providers.tokenflow]
name = "TokenFlow"
base_url = "https://api.tokenflow365.com/v1"
env_key = "TOKENFLOW_API_KEY"
wire_api = "responses"
# Add to the end of ~/.zshrc or ~/.bashrc, then reopen the terminal
export TOKENFLOW_API_KEY="sk-your-key"

Run codex in your project folder.

Gemini CLI

Install: npm install -g @google/gemini-cli. Create ~/.gemini/.env; the address has no version:

.env
GOOGLE_GEMINI_BASE_URL=https://api.tokenflow365.com
GEMINI_API_KEY=sk-your-key
GEMINI_MODEL=gemini-4-argon

Run gemini and choose “Use Gemini API Key” on first start.

OpenCode

Install: npm install -g opencode-ai. Put this in ~/.config/opencode/opencode.json; list several models and switch with /models:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tokenflow": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "TokenFlow",
      "options": {
        "baseURL": "https://api.tokenflow365.com/v1",
        "apiKey": "sk-your-key"
      },
      "models": {
        "deepseek-v4.1-flash": { "name": "deepseek-v4.1-flash" }
      }
    }
  },
  "model": "tokenflow/deepseek-v4.1-flash"
}

Cline / Roo Code / Kilo Code

Install any of them from the VS Code marketplace and fill in:

API ProviderOpenAI Compatible
Base URLhttps://api.tokenflow365.com/v1
API KeyA key created in the console
Model IDA platform model ID, such as claude-opus-5-5 or kimi-k3.1-pro

One-click import: CC Switch and Cherry Studio

With CC Switch or Cherry Studio installed, click Import on the console’s API keys list, or use one-click import in the setup guide; the address, key and model are written into the app for you. For other clients see Tool integrations.

Check it works

Ask the tool anything, then open Billing in the console: if the request and its charge are there, you are set. For errors see Errors; the usual causes are a key group that does not fit the tool, a display name used instead of a model ID, or /v1 added or missing.