Files
opencode/packages/web/src/content/docs/zh-tw/models.mdx
2026-02-10 20:22:30 +00:00

224 lines
5.2 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 使用[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 Codex
- Claude Opus 4.5
- Claude Sonnet 4.5
- Minimax M2.1
- Gemini 3 Pro
---
## 設置默認值
要將其中之一設置為默認模型,您可以在您的
OpenCode 配置。
```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)。
您還可以定義擴展內置變體的自定義變體。變體允許您為同一模型配置不同的設置,而無需創建重複的條目:
```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 附帶了許多提供商的默認變體:
**Anthropic**
- `high` - 高思維預算(默認)
- `max` - 最大思維預算
**OpenAI**
因型號而異,但大致如下:
- `none` - 沒有推理
- `minimal` - 最少的推理工作
- `low` - 推理工作量低
- `medium` - 中等推理努力
- `high` - 高推理能力
- `xhigh` - 極高的推理能力
**Google**:
- `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. 第一個模型使用內部優先級。