Repository navigation
"Provider returned error" with openrouter/openai/gpt-5.1-codex #4608
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Here's the error from above with --print-logs:
Here's a formatted version of the big error={...} json blob from --print-logs:
Here's my config:
$ opencode debug config
{
"$schema": "https://opencode.ai/config.json",
"theme": "jdanbrown",
"keybinds": {
"leader": "ctrl+o",
"app_exit": "ctrl+d,<leader>q",
"editor_open": "<leader>e",
"theme_list": "<leader>t",
"sidebar_toggle": "<leader>b",
"status_view": "<leader>s",
"session_export": "<leader>x",
"session_new": "<leader>n",
"session_list": "<leader>l",
"session_timeline": "<leader>g",
"session_share": "none",
"session_unshare": "none",
"session_interrupt": "ctrl+c",
"session_compact": "<leader>c",
"messages_page_up": "pageup",
"messages_page_down": "pagedown",
"messages_half_page_up": "ctrl+alt+u",
"messages_half_page_down": "ctrl+alt+d",
"messages_first": "ctrl+alt+a",
"messages_last": "ctrl+alt+e",
"messages_copy": "<leader>y",
"messages_undo": "<leader>u",
"messages_redo": "<leader>r",
"messages_toggle_conceal": "<leader>h",
"model_list": "<leader>m,ctrl+j",
"model_cycle_recent": "f2",
"model_cycle_recent_reverse": "shift+f2",
"command_list": "ctrl+_",
"agent_list": "<leader>a",
"agent_cycle": "tab",
"agent_cycle_reverse": "shift+tab",
"input_clear": "ctrl+c",
"input_forward_delete": "ctrl+d",
"input_paste": "ctrl+v",
"input_submit": "return",
"input_newline": "shift+enter,alt+enter",
"history_previous": "up,ctrl+p",
"history_next": "down,ctrl+n",
"session_child_cycle": "<leader>right",
"session_child_cycle_reverse": "<leader>left"
},
"tui": {
"scroll_speed": 2
},
"share": "manual",
"autoupdate": false,
"model": "openrouter/anthropic/claude-haiku-4.5",
"small_model": "openrouter/google/gemini-2.5-flash",
"provider": {
"openrouter": {
"models": {
"anthropic/claude-sonnet-4.5@thinking-32k": {
"id": "anthropic/claude-sonnet-4.5",
"options": {
"reasoning": {
"effort": "high"
}
}
}
}
}
},
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": ...
}
}
},
"formatter": {
"swiftformat": {
"command": [
"swiftformat",
"$FILE"
],
"extensions": [
".swift"
]
}
},
"instructions": [],
"permission": {
"bash": {
"*": "ask",
"git status": "allow",
"git diff": "allow",
"git log": "allow"
}
},
"agent": {},
"mode": {},
"plugin": [],
"command": {},
"username": "danb"
}OpenCode version
1.0.85
Steps to reproduce
(above)
Screenshot and/or share link
No response
Operating System
macOS 15.5
Terminal
VS Code terminal
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
jdanbrown commentedon Nov 21, 2025
Same error if I comment out the
"mcp": { ... }block in my config.jdanbrown commentedon Nov 21, 2025
Same error with empty config, too.
jdanbrown commentedon Nov 21, 2025
Same error with
openrouter/openai/gpt-5.1-codex-mini.jdanbrown commentedon Nov 21, 2025
Does not error with
openai/gpt-5.1-codex(i.e. without openrouter).rekram1-node commentedon Nov 21, 2025
Hmmm
rekram1-node commentedon Nov 21, 2025
I have a fix for this, that's really weird tho I think the openrouter ai sdk has a bug maybe
jdanbrown commentedon Nov 21, 2025
Maybe related to the gemini-3 openrouter issue?
rekram1-node commentedon Nov 21, 2025
yeah it's related to their ai sdk doing something
rekram1-node commentedon Nov 21, 2025
or we are doing something wrong w it
rekram1-node commentedon Nov 21, 2025
Talked w/ openrouter they are fixing it
jhkim2goqual commentedon Nov 23, 2025
I’ve been running into the same issue when using OpenCode with OpenRouter + OpenAI models (e.g.
openrouter/openai/gpt-5.1-codex).After digging into the logs and request payload, I confirmed that the root cause is:
OpenCode re-sends prior "assistant" messages including the
reasoning/reasoning_detailsmetadataWhen OpenRouter forwards that to OpenAI, the encrypted reasoning blocks (
providerMetadatawithreasoning.encrypteditems likers_...) no longer match the OpenAI project/key OpenRouter is usingOpenAI then rejects the request with:
To work around this, I patched my local OpenCode clone to strip reasoning provider metadata only when using the OpenRouter provider.
Concretely, I added an option to
MessageV2.toModelMessage(...):and when
model.npm === "@openrouter/ai-sdk-provider", I call it withstripReasoningMetadata: true.Inside
toModelMessage, for assistant messages I now do (simplified):So the encrypted reasoning blocks are no longer forwarded when going through OpenRouter, but everything else (including the reasoning text itself) is preserved. Other providers (direct OpenAI, Anthropic, etc.) keep the original behavior.
With this patch in place, I can now use
openrouter/openai/gpt-5.1-codexin OpenCode without hitting the “Provider returned error / encrypted content could not be verified” issue.If it’s helpful, I’m happy to turn this into a PR — or feel free to adapt this approach in whatever way best fits the existing provider abstractions.
rekram1-node commentedon Nov 24, 2025
if you update to latest this should be fixed, may need to clear your cache too, try:
opencode models --refreshjdanbrown commentedon Nov 25, 2025
👍 Thanks! I got through one non-trivial prompt without issues with openrouter/openai/gpt-5.1-codex. I'll bang on it more tomorrow.
JohnBakhmat commentedon Dec 17, 2025
for people in sanctioned regions (Russia, Iran, etc. i don't know them all) try running it through proxy. i thought issue persisted but it was in fact a region restriction
NathanRHD commentedon Jan 10, 2026
I appear to be having the same from my vultr vps but non gpt models from the same openrouter seem to be working?
rekram1-node commentedon Jan 16, 2026
This should be fixed in the next release (1.1.24) by commit: 40836e9
jdanbrown commentedon Jan 16, 2026
Yep, appears to now be fixed in 1.1.25:
jdanbrown commentedon Jan 16, 2026
Did you also fix this other issue in the process? I just confirmed that my repro from the top of it is now working for me in 1.1.25: