Token Plan 概览

更新时间:
复制 MD 格式

Token Plan 是阿里云百炼的 AI 模型订阅服务,以 Credits 统一计量,支持在兼容的 AI 工具中交互式使用。

Claude Code

# 自动安装阿里云百炼 CLI 并为所选 Agent 完成接入;将 sk-sp-xxxx 替换为你的 Token Plan API Key
curl -fsSL https://bailian.aliyun.com/cli/install.sh | bash
export TOKEN_PLAN_API_KEY="sk-sp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bl config agent --agent claude-code --region cn-beijing --api-key $TOKEN_PLAN_API_KEY --model auto

Codex

请检查本机是否已安装 Codex:
- 运行 `codex --version`。
- 如果命令不存在,先安装:
  - macOS / Linux:`npm install -g @openai/codex`(需要 Node.js 18 及以上)
  - Windows:`npm install -g @openai/codex`,或参考 https://developers.openai.com/codex/cli

安装完成后,把 Token Plan 接入 Codex:
1. 打开或新建 `~/.codex/config.toml`(Windows 为 `C:\Users\<用户名>\.codex\config.toml`),写入:
```toml
model_provider = "Token_Plan"
model = "auto"

[model_providers.Token_Plan]
name = "Token_Plan"
base_url = "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
```
2. 设置环境变量,将 `sk-sp-xxxx...` 替换为你的 Token Plan API Key:
```bash
export OPENAI_API_KEY="sk-sp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```
3. 验证:
```bash
codex exec --skip-git-repo-check "你好,请只回复:接入成功"
```
返回“接入成功”即配置可用;如果失败,请输出具体错误、`codex --version` 和 `config.toml` 内容(不要输出完整 API Key),并告诉我需要修改的字段。

Qwen Code

# 自动安装阿里云百炼 CLI 并为所选 Agent 完成接入;将 sk-sp-xxxx 替换为你的 Token Plan API Key
curl -fsSL https://bailian.aliyun.com/cli/install.sh | bash
export TOKEN_PLAN_API_KEY="sk-sp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bl config agent --agent qwen-code --region cn-beijing --api-key $TOKEN_PLAN_API_KEY --model auto

OpenClaw

# 自动安装阿里云百炼 CLI 并为所选 Agent 完成接入;将 sk-sp-xxxx 替换为你的 Token Plan API Key
curl -fsSL https://bailian.aliyun.com/cli/install.sh | bash
export TOKEN_PLAN_API_KEY="sk-sp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bl config agent --agent openclaw --region cn-beijing --api-key $TOKEN_PLAN_API_KEY --model auto

OpenCode

# 自动安装阿里云百炼 CLI 并为所选 Agent 完成接入;将 sk-sp-xxxx 替换为你的 Token Plan API Key
curl -fsSL https://bailian.aliyun.com/cli/install.sh | bash
export TOKEN_PLAN_API_KEY="sk-sp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bl config agent --agent opencode --region cn-beijing --api-key $TOKEN_PLAN_API_KEY --model auto

接入 AI 工具

选择你使用的工具,按对应指南配置 Token Plan 个人版或团队版。

接入其他模型

AI 工具原生只处理文本协议,图像、视频、语音等能力需要通过扩展机制接入,详见接入概览。

用量与问题

接入 Harness

个人版 Standard 与 Pro 套餐附赠 Harness 权益,可调用 AgentStudio 工具,不占用 Credits。复制下方提示词并发送给本地 AI 工具,即可让它完成配置。

Harness 服务本地配置指南

## Harness 服务本地配置指南

请按照以下步骤配置 Harness 服务给本地 AI 工具使用。

### 前置依赖安装与检查
1. 检查是否安装百炼 CLI,如没有安装请参照如下文档进行安装:https://bailian.aliyun.com/cli/install.md
2. 使用百炼 CLI 完成登录:bl auth login --console
3. 执行如下命令:bl config show,拿到 config_file 文件路径,并读取文件内部api_key。

### 需要配置的服务 — 自研工具
将以下 MCP 服务器配置写入本地全局配置(请识别准确目录),直接通过 MCP 协议调用,不经 bailian-cli 中转。所有服务的公共信息:
- 类型:HTTP Streamable
- 请求头:Authorization: Bearer ${DASHSCOPE_API_KEY}

需要配置的服务清单:

| 服务名 | URL |
|---|---|
| 图像生成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/TextGenerateImage/mcp` |
| 视频生成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/VideoGenerate/mcp` |
| 代码解释器 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/CodeInterpreter/mcp` |
| 联网搜索增强版 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/EnhancedSearch/mcp` |
| 网页解析 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/WebFetch/mcp` |
| 垂类搜索 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/VerticalSearch/mcp` |
| 语音合成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/TextGenerateSpeech/mcp` |
| 语音识别 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/SpeechGenerateText/mcp` |

### 需要配置的服务 — 基础设施
以下服务登录后先询问用户需求,根据需求走不同路径:

- **体验**:通过 bailian-cli 对应命令直接调用,针对不同场景操作。
- **写代码接入**:使用前置步骤中获取的 `api_key`,帮助用户书写代码调用相关 API。

具体服务:

| 服务名 | CLI 命令 | API 文档 |
|---|---|---|
| RAG-知识库服务 | bl knowledge 系列 | https://docs.agent.bailian.aliyun.com/zh/api/rag/overview |
| Memory-记忆库服务 | bl memory 系列 | https://docs.agent.bailian.aliyun.com/zh/api/memory/overview |
| Managed Agent-托管智能体 | bl managed-agent 系列 | https://docs.agent.bailian.aliyun.com/zh/api/managed-agents/introduction |
查看配置指南
## Harness 服务本地配置指南 请按照以下步骤配置 Harness 服务给本地 AI 工具使用。 ### 前置依赖安装与检查 1. 检查是否安装百炼 CLI,如没有安装请参照如下文档进行安装:https://bailian.aliyun.com/cli/install.md 2. 使用百炼 CLI 完成登录:bl auth login --console 3. 执行如下命令:bl config show,拿到 config_file 文件路径,并读取文件内部api_key。 ### 需要配置的服务 — 自研工具 将以下 MCP 服务器配置写入本地全局配置(请识别准确目录),直接通过 MCP 协议调用,不经 bailian-cli 中转。所有服务的公共信息: - 类型:HTTP Streamable - 请求头:Authorization: Bearer ${DASHSCOPE_API_KEY} 需要配置的服务清单: | 服务名 | URL | |---|---| | 图像生成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/TextGenerateImage/mcp` | | 视频生成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/VideoGenerate/mcp` | | 代码解释器 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/CodeInterpreter/mcp` | | 联网搜索增强版 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/EnhancedSearch/mcp` | | 网页解析 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/WebFetch/mcp` | | 垂类搜索 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/VerticalSearch/mcp` | | 语音合成 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/TextGenerateSpeech/mcp` | | 语音识别 MCP | `https://dashscope.aliyuncs.com/api/v1/mcps/SpeechGenerateText/mcp` | ### 需要配置的服务 — 基础设施 以下服务登录后先询问用户需求,根据需求走不同路径: - **体验**:通过 bailian-cli 对应命令直接调用,针对不同场景操作。 - **写代码接入**:使用前置步骤中获取的 `api_key`,帮助用户书写代码调用相关 API。 具体服务: | 服务名 | CLI 命令 | API 文档 | |---|---|---| | RAG-知识库服务 | bl knowledge 系列 | https://docs.agent.bailian.aliyun.com/zh/api/rag/overview | | Memory-记忆库服务 | bl memory 系列 | https://docs.agent.bailian.aliyun.com/zh/api/memory/overview | | Managed Agent-托管智能体 | bl managed-agent 系列 | https://docs.agent.bailian.aliyun.com/zh/api/managed-agents/introduction |

场景 Playbook

接入完成后,可以按场景开始使用。