面向 AI 助手:本页的 Markdown 版本位于 https://ark.volcengine.com/region:cn-beijing/docs/coding-plan-personal-ai-opencode.md,全部文档索引见 https://ark.volcengine.com/llms.txt。

OpenCode

OpenCode 是一款开源的 AI 编程代理工具,提供终端界面、桌面应用和 IDE 扩展等多种使用方式。
方舟 Coding Plan 支持在 OpenCode 中使用,可参考本文进行配置及使用。

核心配置#

接入工具的核心参数如下:

模型配置#

支持以下两种方式配置模型:

在工具配置文件中指定 Model Name,可实时切换模型。支持配置的 Model Name:

  • doubao-seed-evolving
  • doubao-seed-2.1-pro
  • doubao-seed-2.1-lite
  • doubao-seed-2.0-mini
  • minimax-m3
  • glm-5.3 (glm-latest)
  • glm-5.3-flash
  • deepseek-v4.1-flash
  • deepseek-v4-flash
  • deepseek-v4-pro
  • kimi-k2.8-preview
  • kimi-k3
  1. 在配置文件中指定模型为ark-code-latest。
  2. 通过 开通管理页面 选择或切换目标模型,切换模型后 3-5 分钟即可生效。
    支持 Auto 模式,通过「效果 + 速度」双维度智能算法自动选择模型。

Base URL#

不同的工具配置的 Base URL 根据兼容的协议会有不同:

  • 兼容 Anthropic 接口协议工具:https://ark.cn-beijing.volces.com/api/coding
  • 兼容 OpenAI 接口协议工具:https://ark.cn-beijing.volces.com/api/coding/v3

API Key#

获取 API Key

一、安装 OpenCode#

前提条件:安装 Node.js 18 或更新版本。
在命令行界面,执行以下命令安装 OpenCode。

Bash
npm install -g opencode-ai

安装结束后,执行以下命令查看安装结果,若显示版本号则安装成功。

Bash
opencode --version

二、配置 OpenCode#

方式 1:自动化助手(推荐)#

ArkCLI Helper 是一个编码工具助手,支持快速配置选择的工具接入 Coding Plan。安装并运行该助手,根据界面提示操作可自动完成工具配置,降低手动配置的时间成本和出错风险。

  1. 安装 Ark CLI。

    Bash
    # 1. 通过 NPM 安装
    npm install -g @volcengine/ark-cli@latest
    
    # 2. 验证安装
    arkcli --version
    
  2. 登录 Ark CLI。

    Bash
    arkcli auth login
    

    image-20260624-144256-509.png

    根据界面提示选择登录方式。若之前已登录过 arkcli,会沿用上次选择的配置;如需重新选择,请先执行 arkcli config reset 后再运行 arkcli auth login。首次登录时,按提示完成以下配置:

    1. 选择项目(Project):可按需选择,或默认选择账号全部资源。

    2. 选择消费模式(Type):选择 coding-plan。

      image-20260624-163746-727.png

  3. 运行 ArkCLI Helper,根据界面提示完成 OpenCode 的配置。

    1. 在命令行界面输入 arkcli helper 命令,启动 ArkCLI Helper。

    2. 选择要配置的 Plan profile:选择 coding-plan_cn-beijing_personal (Coding Plan)。
      image-20260624-163451-813.png

    3. 选择默认 model:按需选择。

    4. 选择要配置的 AI Agent:OpenCode。

      image-20260624-164505-484.png

完成上述操作后,将自动完成 OpenCode 的基础配置,无需手动安装。

方式 2:手动配置#

  1. 创建并打开 OpenCode 的配置文件。文件路径因系统而异,具体操作如下:

macOS/Linux 系统 OpenCode 配置文件路径:~/.config/opencode/opencode.json。

  1. 如果在主目录下没有.config/opencode目录,执行以下命令创建目录。

    Bash
    mkdir -p ~/.config/opencode
    
  2. 创建并打开配置文件。

    Bash
    nano ~/.config/opencode/opencode.json
    

Windows 系统 OpenCode 配置文件路径:%USERPROFILE%\.config\opencode\opencode.json。以 CMD 命令行方式为例,操作如下。

  1. 如果当前用户目录下没有.config\opencode目录,执行以下命令创建目录。

    Bash
    if not exist "%USERPROFILE%\.config\opencode" mkdir "%USERPROFILE%\.config\opencode"
    
  2. 创建并打开配置文件。

    Bash
    notepad "%USERPROFILE%\.config\opencode\opencode.json"
    
  1. 编辑 opencode.json,需关注的配置信息如下:

    • <ARK_API_KEY>:替换为您自己的 API Key。
    • model:更新为需要使用的模型信息。支持的模型信息参见 模型配置。

    Coding Plan 兼容 OpenAI 接口协议,支持 Responses API、Chat API。推荐使用 Responses API 的配置,推理效果更好。

    支持的两类 API 仅在 npm 配置上不同:

    • Responses API 配置:"npm": "@ai-sdk/openai"
    • Chat API 配置:"npm": "@ai-sdk/openai-compatible"

    以配置ark-code-latest为例,具体信息如下。

JSON
{
  "$schema": "https://opencode.ai/config.json",
  "model": "volcengine-plan/ark-code-latest",
  "provider": {
    "volcengine-plan": {
      "npm": "@ai-sdk/openai",
      "name": "Volcano Engine(Responses API)",
      "options": {
        "baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
        "apiKey": "<ARK_API_KEY>"
      },
      "models": {
        "ark-code-latest": {
          "name": "ark-code-latest",
          "limit": {
            "context": 256000,
            "output": 32000
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.1-pro": {
          "name": "doubao-seed-2.1-pro",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-evolving": {
          "name": "doubao-seed-evolving",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-5.3": {
          "name": "glm-5.3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-5.3-flash": {
          "name": "glm-5.3-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-latest": {
          "name": "glm-latest",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          }
        },
        "deepseek-v4-flash": {
          "name": "deepseek-v4-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          }
        },
        "deepseek-v4-pro": {
          "name": "deepseek-v4-pro",
          "limit": {
            "context": 1024000,
            "output": 65536
          }
        },
        "deepseek-v4.1-flash": {
          "name": "deepseek-v4.1-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.1-lite": {
          "name": "doubao-seed-2.1-lite",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.0-mini": {
          "name": "doubao-seed-2.0-mini",
          "limit": {
            "context": 256000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "minimax-m3": {
          "name": "minimax-m3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "kimi-k2.8-preview": {
          "name": "kimi-k2.8-preview",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "kimi-k3": {
          "name": "kimi-k3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        }
      }
    }
  }
}
JSON
{
  "$schema": "https://opencode.ai/config.json",
  "model": "volcengine-plan/ark-code-latest",
  "provider": {
    "volcengine-plan": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Volcano Engine(Chat API)",
      "options": {
        "baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
        "apiKey": "<ARK_API_KEY>"
      },
      "models": {
        "ark-code-latest": {
          "name": "ark-code-latest",
          "limit": {
            "context": 256000,
            "output": 32000
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.1-pro": {
          "name": "doubao-seed-2.1-pro",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-evolving": {
          "name": "doubao-seed-evolving",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-5.3": {
          "name": "glm-5.3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-5.3-flash": {
          "name": "glm-5.3-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "glm-latest": {
          "name": "glm-latest",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          }
        },
        "deepseek-v4-flash": {
          "name": "deepseek-v4-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          }
        },
        "deepseek-v4-pro": {
          "name": "deepseek-v4-pro",
          "limit": {
            "context": 1024000,
            "output": 65536
          }
        },
        "deepseek-v4.1-flash": {
          "name": "deepseek-v4.1-flash",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.1-lite": {
          "name": "doubao-seed-2.1-lite",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "doubao-seed-2.0-mini": {
          "name": "doubao-seed-2.0-mini",
          "limit": {
            "context": 256000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "minimax-m3": {
          "name": "minimax-m3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "kimi-k3": {
          "name": "kimi-k3",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        },
        "kimi-k2.8-preview": {
          "name": "kimi-k2.8-preview",
          "limit": {
            "context": 1024000,
            "output": 65536
          },
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          }
        }
      }
    }
  }
}

三、使用 OpenCode#

  1. 启动OpenCode:

    Bash
    opencode
    
  2. 输入/models,选择配置的模型并在 OpenCode 中使用。

常见问题#

错误码#

在编程工具中使用 Coding Plan 套餐时可能会遇到报错,您可以根据错误信息查看对应的报错场景并定位问题,具体可参考错误码。