Appearance
OpenCode 配置指南
OpenCode 是基于终端的 AI 编程助手,支持多个 Provider 同时接入。以下配置可以让你通过 1xm 同时使用 Claude、GPT-5 Codex、Gemini 全系列模型。
1. 安装 OpenCode
bash
npm install -g opencode-ai安装完成后运行 opencode 启动,或在项目目录运行 opencode .。
2. 创建配置文件
在项目根目录或 ~/.config/opencode/ 下创建 opencode.json,将以下配置粘贴进去,并将所有 apiKey 字段替换为你的 1xm 密钥(三个 Provider 使用同一密钥):
json
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"oh-my-opencode"
],
"provider": {
"1xm-oai": {
"npm": "@ai-sdk/openai",
"name": "1xm-oai",
"options": {
"baseURL": "https://api.1xm.ai/v1",
"apiKey": "sk-1xm-5fxxxx",
"setCacheKey": true
},
"models": {
"gpt-5.4": {
"name": "gpt-5.4"
},
"gpt-5.3-codex": {
"name": "gpt-5.3-codex",
"thinking": true,
"options": {
"include": ["reasoning.encrypted_content"],
"store": false
},
"variants": {
"xhigh": { "reasoningEffort": "xhigh", "textVerbosity": "medium", "reasoningSummary": "auto" },
"high": { "reasoningEffort": "high", "textVerbosity": "medium", "reasoningSummary": "auto" },
"medium":{ "reasoningEffort": "medium","textVerbosity": "medium", "reasoningSummary": "auto" },
"low": { "reasoningEffort": "low", "textVerbosity": "medium", "reasoningSummary": "auto" }
}
},
"gpt-5.2-codex": {
"name": "gpt-5.2-codex",
"thinking": true,
"options": {
"include": ["reasoning.encrypted_content"],
"store": false
},
"variants": {
"xhigh": { "reasoningEffort": "xhigh", "textVerbosity": "medium", "reasoningSummary": "auto" },
"high": { "reasoningEffort": "high", "textVerbosity": "medium", "reasoningSummary": "auto" },
"medium":{ "reasoningEffort": "medium","textVerbosity": "medium", "reasoningSummary": "auto" },
"low": { "reasoningEffort": "low", "textVerbosity": "medium", "reasoningSummary": "auto" }
}
},
"gpt-5.1-codex-max": {
"name": "gpt-5.1-codex-max",
"thinking": true,
"options": {
"include": ["reasoning.encrypted_content"],
"store": false
},
"variants": {
"xhigh": { "reasoningEffort": "xhigh", "textVerbosity": "medium", "reasoningSummary": "auto" },
"high": { "reasoningEffort": "high", "textVerbosity": "medium", "reasoningSummary": "auto" },
"medium":{ "reasoningEffort": "medium","textVerbosity": "medium", "reasoningSummary": "auto" },
"low": { "reasoningEffort": "low", "textVerbosity": "medium", "reasoningSummary": "auto" }
}
}
}
},
"1xm-claude": {
"npm": "@ai-sdk/anthropic",
"name": "1xm-claude",
"options": {
"baseURL": "https://api.1xm.ai/v1",
"apiKey": "sk-1xm-5fxxxx"
},
"models": {
"claude-opus-4-6": { "name": "claude-opus-4-6", "thinking": true },
"claude-opus-4-6-thinking": { "name": "claude-opus-4-6-thinking", "thinking": true },
"claude-sonnet-4-6": { "name": "claude-sonnet-4-6", "thinking": false },
"claude-sonnet-4-6-thinking": { "name": "claude-sonnet-4-6-thinking", "thinking": true },
"claude-haiku-4-5": { "name": "claude-haiku-4-5", "thinking": false }
}
},
"1xm-gemini": {
"npm": "@ai-sdk/google",
"name": "1xm-gemini",
"options": {
"baseURL": "https://api.1xm.ai/gemini",
"apiKey": "sk-1xm-5fxxxx"
},
"models": {
"gemini-3.1-pro-preview": { "name": "gemini-3.1-pro-preview", "thinking": true },
"gemini-3-pro-preview": { "name": "gemini-3-pro-preview", "thinking": true },
"gemini-3-flash-preview": { "name": "gemini-3-flash-preview", "thinking": false }
}
}
}
}Provider 说明
1xm-oai — OpenAI 兼容
接入 GPT-5.4 / GPT-5.3 Codex / GPT-5.2 Codex / GPT-5.1 Codex 系列,Base URL 为 https://api.1xm.ai/v1。Codex 系列支持 thinking 模式,可通过 variants 按需设置推理强度(xhigh / high / medium / low)。
1xm-claude — Anthropic
接入 Claude Opus 4.6 / Sonnet 4.6 / Haiku 4.5 全系列,Base URL 为 https://api.1xm.ai/v1,支持 extended thinking(带 -thinking 后缀的模型 ID 已内置开启推理)。
1xm-gemini — Google
接入 Gemini 3.1 Pro / Gemini 3 Pro / Gemini 3 Flash 系列,Base URL 为 https://api.1xm.ai/gemini,支持 thinking 模式。
3. 获取 API 密钥
在 1xm.ai 控制台 → 「令牌」 → 「创建令牌」 获取你的 API Key,替换配置中所有的 sk-1xm-5fxxxx。
三个 Provider 使用同一密钥即可。