【求助】关于opencode请求出现Invalid argument for parameter maxOutputTokens的异常
- 内容介绍
- 文章标签
- 相关推荐
image976×519 6.74 KB
如截图不知道有没有佬遇到这个问题,报错信息AI_InvalidArgumentError: Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1。
我的opencode.json配置如下, 我配了很多次不是cpa的问题,即使不放在cpa也会出现这个报错
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"oh-my-opencode@latest",
"opencode-antigravity-auth@1.2.8",
"opencode-openai-codex-auth@4.3.0"
],
"provider": {
"cpa-claude": {
"npm": "@ai-sdk/anthropic",
"name": "cpa-claude",
"options": { "baseURL": "http://xxx:8317/v1" },
"models": {
"claude-opus-4-5-20251101": {
"name": "claude-opus-4-5-20251101",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
},
"claude-sonnet-4-5-20250929": {
"name": "claude-sonnet-4-5-20250929",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
},
"claude-haiku-4-5-20251001": {
"name": "claude-haiku-4-5-20251001",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
}
}
}
}
}
网友解答:
--【壹】--:
好的好的,谢谢佬!!我试试去hhhhhh
--【贰】--:
抱歉佬,太久了,有点忘记怎么解决了,记得好像就是配置问题,就按照官方默认的去配置就好,可以先删掉opencode.json,然后让opencode处理重新生成一份opencode.json,然后你再去配置供应商url跟Key就行, 其他不需要改
--【叁】--:
同问,也遇到这个问题,请问楼主解决了吗?
--【肆】--:
好像是思考token量不能大于输出token量,佬可以参考以下我的配置:
"provider": {
"77Code": {
"name": "xxx",
"npm": "@ai-sdk/anthropic",
"models": {
"claude-opus-4-6-20260205": {
"name": "Claude Opus 4.6",
"attachment": true,
"limit": {
"context": 200000,
"output": 64000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"budgetTokens": 16000,
"type": "enabled"
}
}
--【伍】--:
好的好的,十分感谢,我再去试试hhhhh
image976×519 6.74 KB
如截图不知道有没有佬遇到这个问题,报错信息AI_InvalidArgumentError: Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1。
我的opencode.json配置如下, 我配了很多次不是cpa的问题,即使不放在cpa也会出现这个报错
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"oh-my-opencode@latest",
"opencode-antigravity-auth@1.2.8",
"opencode-openai-codex-auth@4.3.0"
],
"provider": {
"cpa-claude": {
"npm": "@ai-sdk/anthropic",
"name": "cpa-claude",
"options": { "baseURL": "http://xxx:8317/v1" },
"models": {
"claude-opus-4-5-20251101": {
"name": "claude-opus-4-5-20251101",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
},
"claude-sonnet-4-5-20250929": {
"name": "claude-sonnet-4-5-20250929",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
},
"claude-haiku-4-5-20251001": {
"name": "claude-haiku-4-5-20251001",
"options": {
"maxOutputTokens": 64000,
"thinking": {
"type": "enabled",
"budgetTokens": 32000
}
}
}
}
}
}
}
网友解答:
--【壹】--:
好的好的,谢谢佬!!我试试去hhhhhh
--【贰】--:
抱歉佬,太久了,有点忘记怎么解决了,记得好像就是配置问题,就按照官方默认的去配置就好,可以先删掉opencode.json,然后让opencode处理重新生成一份opencode.json,然后你再去配置供应商url跟Key就行, 其他不需要改
--【叁】--:
同问,也遇到这个问题,请问楼主解决了吗?
--【肆】--:
好像是思考token量不能大于输出token量,佬可以参考以下我的配置:
"provider": {
"77Code": {
"name": "xxx",
"npm": "@ai-sdk/anthropic",
"models": {
"claude-opus-4-6-20260205": {
"name": "Claude Opus 4.6",
"attachment": true,
"limit": {
"context": 200000,
"output": 64000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"options": {
"thinking": {
"budgetTokens": 16000,
"type": "enabled"
}
}
--【伍】--:
好的好的,十分感谢,我再去试试hhhhh

