跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.aihubmix.com/llms.txt

Use this file to discover all available pages before exploring further.

当前已支持 GPT、Claude、DeepSeek、Gemini、Qwen 等主流模型系列。在 OpenCode 使用场景中,推荐以下模型:
  • coding-minimax-m2.1-free
  • coding-glm-4.7-free
  • claude-sonnet-4-5
  • gpt-5
  • gpt-5-codex
本文档将介绍如何在不同操作系统中安装、配置并启动 OpenCode,并完成对 AIHubMix API的接入。
在开始安装前,请确保系统已满足以下要求:
  • Node.js ≥ 18.0.0
  • 对应系统的包管理工具(可选):
    • macOS / Linux:brew
    • Arch Linux:paru
    • Windows:chocowingetscoop

一、安装 OpenCode

可根据所使用的系统与工具选择任意一种安装方式。
  1. 使用 Node.js 安装
# 使用 CURL 脚本快速安装
curl -fsSL https://opencode.ai/install | bash

# 使用 NPM
npm install -g opencode-ai

# 使用 Bun
bun install -g opencode-ai

# 使用 PNPM
pnpm install -g opencode-ai

# 使用 Yarn
yarn global add opencode-ai

  1. 使用 Homebrew(macOS / Linux)
brew install sst/tap/opencode

  1. 使用 Paru(Arch Linux)
paru -S opencode-bin

  1. Windows 安装
Windows 用户可通过以下方式安装 OpenCode:
# Chocolatey
choco install opencode

# WinGet
winget install opencode

# Scoop
scoop bucket add extras
scoop install extras/opencode

# 或使用 NPM(需 Node.js 环境)- 注意:需要管理员权限
npm install -g opencode-ai

二、启动与登录 OpenCode

安装完成后,执行以下步骤完成登录与配置。
  1. 登录OpenCode
在终端输入以下命令:
opencode auth login

  1. 选择 AI 供应商
在登录界面中选择 **AIHubMix **作为模型供应商。 Opencode 1
  1. API Key授权
输入 AiHubMix API Key 并在 OpenCode 登录页面中输入该密钥以完成授权。 Opencode 2

三、模型使用

  1. 安装验证
可通过以下命令验证 OpenCode 是否安装并配置成功:
opencode
Opencode 3
  1. 选择模型
/models ,搜aihubmix,选择需要的模型。 Opencode 4

四、在 OpenCode 客户端使用

  1. 下载 OpenCode 桌面端:https://opencode.ai/download
  2. 打开 OpenCode,输入/model -> Connet provider -> 搜索aihubmix -> 输入 API Key -> SubmitOpencode 5
  3. 在模型选择栏搜aihubmix ,选择需要使用的模型即可使用。 Opencode 6

五、手动配置更新模型

以添加 DeepSeek V4 Pro 为例。

第一步:确认模型 ID

AIHubMix 模型界面找到目标模型,复制 ID。 也可以通过 API 直接查询:
curl https://aihubmix.com/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY" \
  | python3 -m json.tool | grep "id"

第二步:打开配置文件

根据你的系统,在终端运行对应命令: Mac
mkdir -p ~/.config/opencode && open -a TextEdit ~/.config/opencode/opencode.json
Linux
mkdir -p ~/.config/opencode && nano ~/.config/opencode/opencode.json
Windows(在 PowerShell 中运行)
New-Item -ItemType Directory -Force "$env:USERPROFILE\.config\opencode"
notepad "$env:USERPROFILE\.config\opencode\opencode.json"
文件打开后,你会看到一个空文件或已有的 JSON 内容。

第三步:写入配置

如果是空文件,直接粘贴以下内容:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aihubmix": {
      "models": {
        "deepseek-v4-pro": {
          "name": "DeepSeek-V4-Pro",
          "contextLength": 131072,
          "type": "language"
        }
      }
    }
  }
}
如果文件已有内容,只需在 "models" 里追加新模型,每个模型之间用逗号隔开:
"models": {
  "deepseek-v4-pro": {
    "name": "DeepSeek-V4-Pro",
    "contextLength": 131072,
    "type": "language"
  },
  "deepseek-v4-flash-think": {
    "name": "DeepSeek-V4-Flash-Think",
    "contextLength": 131072,
    "type": "language"
  }
}
注意:最后一个模型后面不加逗号,否则文件格式会出错。
保存文件:Mac 按 Command + S,Windows 按 Ctrl + S 字段说明:
字段说明
name模型ID
contextLength上下文长度(token数)
type模型类型,文本对话填 "language"

第四步:重启 OpenCode

保存配置文件后,完全退出 OpenCode 并重新启动,新模型才会加载。

第五步:验证

打开模型选择(默认快捷键 ;),搜索 V4DeepSeek,确认 DeepSeek-V4-Pro 已出现在列表中。

六、常见问题与提示

  • 若API Key无法通过验证,请重新登录AIHubMix并检查密钥有效性。
  • 查看帮助文档:opencode ->/help
  • opencode官方文档:https://opencode.ai/docs/
最新更新日期: 2026年4月27日