Files
opencode/packages/web/src/content/docs/zh-cn/models.mdx
2026-02-09 13:55:55 -06:00

224 lines
5.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 型號
description: 配置LLM提供者和模型。
---
OpenCode 使用[人工智能软件开发工具包](https://ai-sdk.dev/) 和[模型.dev](https://models.dev) 来支持**75+ LLM 成功**,并且支持运行本地模型。
---
## 供應商
默认情况下会预加载大多数流行的提供程序。如果您已通过 `/connect` 命令添加了提供程序的辅助程序,那么它们将在您启动 OpenCode 时可用。
了解有关[提供者](/docs/providers) 的更多信息。
---
## 選擇型號
配置完提供商後,您可以通過輸入以下內容來選擇您想要的型號:
```bash frame="none"
/models
```
---
## 推薦型號
那裡有很多型號,每週都會有新型號問世。
:::tip
考慮使用我們推薦的模型之一。
:::
然而,既擅長生成代碼又擅長工具調用的只有少數。
以下是与 OpenCode 配合良好的几个模型,排名不分前面。(这不是好看的列表,也不一定是最新的):
- GPT 5.2
- GPT 5.1 法典
- 近距離工作4.5
- 克勞德十四行詩 4.5
- 极小极M2.1
- 雙子座 3 專業版
---
## 設置默認值
要將其中之一設置為默認模型,您可以在您的
打開代碼配置。
```json title="opencode.json" {3}
{
"$schema": "https://opencode.ai/config.json",
"model": "lmstudio/google/gemma-3n-e4b"
}
```
这里完整的ID是`provider_id/model_id`。例如,如果您使用[开放代码禅](/docs/zen),则您将使用`opencode/gpt-5.1-codex`来表示GPT 5.1 Codex。
如果您配置了[定制生产](/docs/providers#custom),则`provider_id` 是配​​置中`provider` 部分的按键,`model_id` 是`provider.models` 中的按键。
---
## 配置模型
您可以通过 config.json 全局配置模型的选项。
```jsonc title="opencode.jsonc" {7-12,19-24}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"models": {
"gpt-5": {
"options": {
"reasoningEffort": "high",
"textVerbosity": "low",
"reasoningSummary": "auto",
"include": ["reasoning.encrypted_content"],
},
},
},
},
"anthropic": {
"models": {
"claude-sonnet-4-5-20250929": {
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 16000,
},
},
},
},
},
},
}
```
在这里,我们为两个内置模型配置全局设置:`gpt-5`(通过 `openai` 提供程序访问时间)和 `claude-sonnet-4-20250514`(通过 `anthropic` 提供程序访问时间)。
内置结构和型号名称可以在[模型.dev](https://models.dev) 上找到。
您还可以为您正在使用的任何代理配置这些选项。代理配置会覆盖此处的所有全局选项。 [了解更多](/docs/agents/#additional)。
您還可以定義擴展內置變體的自定義變體。變體允許您為同一模型配置不同的設置,而無需創建重複的條目:
```jsonc title="opencode.jsonc" {6-21}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"opencode": {
"models": {
"gpt-5": {
"variants": {
"high": {
"reasoningEffort": "high",
"textVerbosity": "low",
"reasoningSummary": "auto",
},
"low": {
"reasoningEffort": "low",
"textVerbosity": "low",
"reasoningSummary": "auto",
},
},
},
},
},
},
}
```
---
## 變體
许多型号支持具有不同配置的多种变体。OpenCode附带了流行建设的内置默认变体。
### 內置變體
OpenCode 附带了许多重大的默认变体:
**人擇**
- `high` - 高思维预算(默认)
- `max` - 最大预算规划
**開放人工智能**
因型號而異,但大致如下:
- `none` - 没有推理
- `minimal` - 最少的推理工作
- `low` - 推理工作量低
- `medium` - 中等推理努力
- `high` - 高推理能力
- `xhigh` - 极高的推理能力
**谷歌**
- `low` - 降低工作量/代幣預算
- `high` - 更高的努力/代幣預算
:::tip
該列表並不全面。許多其他提供商也有內置的默認值。
:::
### 定制變體
您可以覆蓋現有變體或添加您自己的變體:
```jsonc title="opencode.jsonc" {7-18}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"models": {
"gpt-5": {
"variants": {
"thinking": {
"reasoningEffort": "high",
"textVerbosity": "low",
},
"fast": {
"disabled": true,
},
},
},
},
},
},
}
```
### 循環變體
使用按键绑定`variant_cycle`在变体之间快速切换。 [了解更多](/docs/keybinds)。
---
## 加載模型
当OpenCode启动时它会按以下优先顺序检查模型
1. `--model` 或 `-m` 配置命令行标志。格式与文件中的相同:`provider_id/model_id`。
2. OpenCode 配置中的模型列表。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-20250514"
}
```
这里的格式是`provider/model`。
3. 最後使用的型號。
4. 第一個模型使用內部優先級。