Description
When using a custom @ai-sdk/openai-compatible provider with model-specific options (e.g. reasoning.effort for OpenRouter), the options are silently ignored and never sent to the API. This affects all headless usage (opencode run --format json) and makes it impossible to enable extended thinking/reasoning for any custom provider model.
Environment
- OpenCode version:
1.14.48
- OS: Ubuntu 24.04 LTS
- Mode: headless (
opencode run --format json)
- Provider: OpenRouter via
@ai-sdk/openai-compatible
- Model:
qwen/qwen3.6-plus
Steps to Reproduce
1. Create config with reasoning options:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://openrouter.ai/api/v1",
"name": "Openrouter"
},
"models": {
"qwen/qwen3.6-plus": {
"options": {
"reasoning": { "effort": "high" }
}
}
}
}
}
}
2. Run in headless mode:
OPENCODE_CONFIG=/tmp/test_thinking.json \
OPENROUTER_API_KEY=sk-or-v1-... \
opencode run \
--model openrouter/qwen/qwen3.6-plus \
--format json \
--dangerously-skip-permissions \
"explain recursion briefly"
3. Observe output:
{"type":"step_start",...}
{"type":"text","part":{"text":"Recursion is..."}}
Model responds instantly with no reasoning — reasoning.effort: high was not sent to the API.
Expected Behavior
OpenCode should forward model-level options to the API call, resulting in the model performing extended thinking before responding. OpenRouter confirms qwen/qwen3.6-plus supports reasoning parameter:
curl https://openrouter.ai/api/v1/models | jq '.data[] | select(.id=="qwen/qwen3.6-plus") | .supported_parameters'
# ["include_reasoning", "max_tokens", "presence_penalty", "reasoning", ...]
When called directly with reasoning parameter, the model thinks before responding (verified via direct API call).
Actual Behavior
Model options are silently ignored. The reasoning parameter is never sent to OpenRouter. Model responds without any thinking regardless of config.
Additional Investigation
We also tested:
Attempt 1 — options at provider level via defaultQuery:
"options": {
"baseURL": "...",
"name": "Openrouter",
"defaultQuery": { "reasoning": {"effort": "high"} }
}
→ Same result. Options ignored.
Attempt 2 — using built-in OpenRouter provider (no npm field):
{
"provider": {
"openrouter": {
"models": {
"qwen/qwen3.6-plus": {
"options": { "reasoning": {"effort": "high"} }
}
}
}
}
}
→ Same result. Options ignored.
Root Cause (suspected)
Related to issue #971 — model options are not forwarded for openai-compatible providers. The options object appears to be parsed from config but never merged into the actual AI SDK provider call parameters.
The name field in provider options IS applied correctly (baseURL routing works), suggesting provider-level options are forwarded but model-level options are dropped somewhere between config parsing and the API call.
Use Case / Impact
This blocks implementing dynamic thinking/reasoning toggle for any custom or OpenRouter-hosted model in headless/programmatic OpenCode usage. Specifically, it prevents building OpenWebUI pipe integrations that toggle reasoning per-request via OPENCODE_CONFIG environment variable.
Workaround
None found. The only alternative is to use models with thinking built-in at the model level (e.g. qwen/qwen3-235b-a22b-thinking), but this removes the ability to toggle thinking on/off dynamically.
References
Plugins
No response
OpenCode version
1.14.48
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
When using a custom
@ai-sdk/openai-compatibleprovider with model-specificoptions(e.g.reasoning.effortfor OpenRouter), the options are silently ignored and never sent to the API. This affects all headless usage (opencode run --format json) and makes it impossible to enable extended thinking/reasoning for any custom provider model.Environment
1.14.48opencode run --format json)@ai-sdk/openai-compatibleqwen/qwen3.6-plusSteps to Reproduce
1. Create config with reasoning options:
{ "$schema": "https://opencode.ai/config.json", "provider": { "openrouter": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://openrouter.ai/api/v1", "name": "Openrouter" }, "models": { "qwen/qwen3.6-plus": { "options": { "reasoning": { "effort": "high" } } } } } } }2. Run in headless mode:
OPENCODE_CONFIG=/tmp/test_thinking.json \ OPENROUTER_API_KEY=sk-or-v1-... \ opencode run \ --model openrouter/qwen/qwen3.6-plus \ --format json \ --dangerously-skip-permissions \ "explain recursion briefly"3. Observe output:
{"type":"step_start",...} {"type":"text","part":{"text":"Recursion is..."}}Model responds instantly with no reasoning —
reasoning.effort: highwas not sent to the API.Expected Behavior
OpenCode should forward model-level
optionsto the API call, resulting in the model performing extended thinking before responding. OpenRouter confirmsqwen/qwen3.6-plussupportsreasoningparameter:When called directly with
reasoningparameter, the model thinks before responding (verified via direct API call).Actual Behavior
Model options are silently ignored. The
reasoningparameter is never sent to OpenRouter. Model responds without any thinking regardless of config.Additional Investigation
We also tested:
Attempt 1 — options at provider level via
defaultQuery:→ Same result. Options ignored.
Attempt 2 — using built-in OpenRouter provider (no
npmfield):{ "provider": { "openrouter": { "models": { "qwen/qwen3.6-plus": { "options": { "reasoning": {"effort": "high"} } } } } } }→ Same result. Options ignored.
Root Cause (suspected)
Related to issue #971 — model options are not forwarded for
openai-compatibleproviders. Theoptionsobject appears to be parsed from config but never merged into the actual AI SDK provider call parameters.The
namefield in provideroptionsIS applied correctly (baseURL routing works), suggesting provider-level options are forwarded but model-level options are dropped somewhere between config parsing and the API call.Use Case / Impact
This blocks implementing dynamic thinking/reasoning toggle for any custom or OpenRouter-hosted model in headless/programmatic OpenCode usage. Specifically, it prevents building OpenWebUI pipe integrations that toggle reasoning per-request via
OPENCODE_CONFIGenvironment variable.Workaround
None found. The only alternative is to use models with thinking built-in at the model level (e.g.
qwen/qwen3-235b-a22b-thinking), but this removes the ability to toggle thinking on/off dynamically.References
Plugins
No response
OpenCode version
1.14.48
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response