summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/content/docs/zh-cn/models.mdx
blob: 1a9b5b4c07a6b43a9860d4437ebefe7f1027c698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
---
title: 模型
description: 配置 LLM 提供商和模型。
---

opencode 使用 [AI SDK](https://ai-sdk.dev/) 和 [Models.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`。例如,如果您使用[OpenCode Zen](/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` 提供商访问)。
内置结构和模型名称可以在[Models.dev](https://models.dev) 上找到。

您还可以为您正在使用的任何代理配置这些选项。代理配置会覆盖此处的所有全局选项。 [了解更多](/docs/agents/#additional)。

你还可以定义扩展内置 variants 的自定义 variants。variants 允许你为同一模型配置不同设置,而无需创建重复条目:

```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` - 最大预算规划

**OpenAI**:

因模型而異,但大致如下:

- `none` - 没有推理
- `minimal` - 最少的推理工作
- `low` - 推理工作量低
- `medium` - 中等推理努力
- `high` - 高推理能力
- `xhigh` - 极高的推理能力

**谷歌**:

- `low` - 降低工作量/Tokens預算
- `high` - 更高的努力/Tokens預算

:::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. 第一个模型使用内部优先級。