Codex 中转介绍
🔗 OpenCode 配置
在 OpenCode 中接入 Nexoraivision Codex 中转的完整模型清单与变体配置。
OpenCode 是开源 CLI 与 IDE 集成的 AI Agent,原生支持任意 OpenAI 兼容后端,配置一次可同时挂载多个模型与推理变体。
配置文件位置
| 平台 | 路径 |
|---|---|
| macOS / Linux | ~/.config/opencode/opencode.json 或 opencode.jsonc |
| Windows | %APPDATA%\opencode\opencode.json |
目录或文件不存在需手动创建。也可用 OpenCode 客户端的
/connect 命令交互式配置。完整配置(推荐直接复制)
将下面配置写入 opencode.json,并把 apiKey 替换为你 控制台 生成的 Key:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "https://nexor.nexoraivision.com/v1",
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"models": {
"gpt-5.5": {
"name": "GPT-5.5",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"gpt-5.4": {
"name": "GPT-5.4",
"limit": { "context": 1050000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"gpt-5.4-mini": {
"name": "GPT-5.4 Mini",
"limit": { "context": 400000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex",
"limit": { "context": 400000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"gpt-5.3-codex-spark": {
"name": "GPT-5.3 Codex Spark",
"limit": { "context": 128000, "output": 32000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
},
"gpt-5.2": {
"name": "GPT-5.2",
"limit": { "context": 400000, "output": 128000 },
"options": { "store": false },
"variants": { "low": {}, "medium": {}, "high": {}, "xhigh": {} }
}
}
}
},
"agent": {
"build": { "options": { "store": false } },
"plan": { "options": { "store": false } }
}
}
字段详解
provider.openai.options
| 字段 | 必填 | 说明 |
|---|---|---|
baseURL | ✅ | https://nexor.nexoraivision.com/v1 |
apiKey | ✅ | 你的 Nexoraivision API Key |
provider.openai.models.<model-id>
| 字段 | 说明 |
|---|---|
name | 客户端展示名 |
limit.context | 该模型最大上下文 Token 数 |
limit.output | 单次最大输出 Token 数 |
options.store | false = 不在中转端持久化响应(隐私优先) |
variants | 推理强度变体:每个变体在 OpenCode 里以独立模型出现,可单独切换 |
agent.<agent-name>.options
OpenCode 内置两类 Agent:
- build — 执行编码任务(写代码、跑测试)
- plan — 拆解任务、产出执行计划
store: false 让 Agent 工作流也不存响应。
模型快速对照
| 模型 ID | 上下文 | 输出 | 适合 |
|---|---|---|---|
gpt-5.5 | 1,050K | 128K | 整库重构、超长上下文 |
gpt-5.4 | 1,050K | 128K | 日常默认,性能与成本平衡 |
gpt-5.4-mini | 400K | 128K | 轻量任务、高频补全 |
gpt-5.3-codex | 400K | 128K | 代码专用模型 |
gpt-5.3-codex-spark | 128K | 32K | 极速代码补全 |
gpt-5.2 | 400K | 128K | 稳定基线 |
推理变体(variants)
每个模型支持以下推理强度,在 OpenCode 里会展开成独立的模型选项:
| 变体 | 速度 | 适合 |
|---|---|---|
low | ⚡⚡⚡⚡ | 简单补全、对话 |
medium | ⚡⚡⚡ | 一般编码(默认) |
high | ⚡⚡ | 复杂逻辑、长函数 |
xhigh | ⚡ | 架构、整库 review |
使用示例
启动 OpenCode 进入交互模式:
opencode
选模型 / 切换变体:
/model gpt-5.4 # 切换到 GPT-5.4(默认 medium 变体)
/model gpt-5.4 xhigh # 切换到 GPT-5.4 xhigh 变体
/model gpt-5.3-codex high # Codex 模型 + high 推理
用 /connect 交互配置
如果你不想手编辑 JSON:
opencode
> /connect
按提示选 OpenAI provider → 输入 baseURL 和 apiKey,OpenCode 会自动写入 opencode.json。模型清单需要后续手动补完(用上面那段 JSON 替换即可)。
多 Provider 共存
如果你同时用官方 OpenAI + Nexoraivision,可以在 provider 下并列两个 entry:
{
"provider": {
"openai-official": {
"options": { "baseURL": "https://api.openai.com/v1", "apiKey": "sk-..." },
"models": { "gpt-4o": { "name": "GPT-4o", "limit": {...} } }
},
"openai": {
"options": { "baseURL": "https://nexor.nexoraivision.com/v1", "apiKey": "sk-..." },
"models": { ... 上面完整清单 ... }
}
}
}
模型名前缀会自动包含 provider id(如 openai/gpt-5.4),不会冲突。
故障排查
- 确认
opencode.json在正确路径(不要放到项目目录里) - JSON 语法错误:用 jsonlint.com 校验
- 跑
opencode --debug看启动日志
- Key 复制不完整(首尾空格、被截断)
- 控制台确认 Key 启用状态
- 直接 curl 验证 Key 见 故障排查
不是必须,但强烈建议保留。这能让 OpenCode 通过 Nexoraivision 时不在中转端落盘任何对话内容,是隐私最佳实践。
完全可以。在 models 里只保留你用得到的几个,删除其他。
其他编辑器(Cursor / Continue / Windsurf)的接入见 编辑器集成。
