You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No opencode provider recipe — redirecting OPENROUTER_BASE_URL mislabels diagnostics and inherits OpenRouter's prompt-cache body rewriting
#8151
Moved from #4038, opened by @awilhite on 2026-08-12. Feature requests now live in Discussions > Ideas.
What problem does this solve?
There is no recipe for opencode zen (https://opencode.ai/zen/go/v1), so the only way to route gbrain at it is to point an unrelated provider's base URL there:
This works, because both endpoints are OpenAI-compatible. It creates two problems.
1. Diagnostics report a provider that was never contacted.
think returns modelUsed: "openrouter:glm-5.2" for a call that went entirely to opencode. The same label appears in mcp_request_log. Anyone pricing that call against OpenRouter's public rates, checking OpenRouter status during an incident, or reasoning about rate limits is looking at the wrong vendor — and nothing in the output hints at the redirect. The provider prefix reads as provenance but is only a slot name.
2. The borrowed slot carries provider-specific request mutation.
src/core/ai/recipes/openrouter.ts is not a neutral OpenAI-compatible passthrough. openrouterSupportsPromptCache() matches openai/gpt-*, ^openai/o\d, and anthropic/claude-*, and for Claude routes a fetch shim rewrites the request body to inject cache_control (via the private x-gbrain-anthropic-prompt-cache marker header).
Today that is latent — a model id like glm-5.2 matches none of those prefixes, so the shim never fires. But any user who borrows this slot for a differently-named model can silently get OpenRouter's Anthropic cache-control body rewriting sent to an endpoint that never asked for it. The failure would surface as an opaque upstream API error with no visible connection to the cause.
What does the solution look like?
A first-class opencode recipe under src/core/ai/recipes/, following the existing per-provider pattern (OPENCODE_BASE_URL / OPENCODE_API_KEY, default base URL https://opencode.ai/zen/go/v1), registered in recipes/index.ts so provider:model resolves as opencode:<model>.
The endpoint is OpenAI-compatible, so the recipe should be close to the generic shape — the value is a truthful label and the absence of another provider's request mutation, not new transport logic.
Result: modelUsed reports the vendor actually contacted, and no user has to borrow a slot whose quirks they then inherit.
Alternatives considered
Point LITELLM_BASE_URL at it instead.litellm-proxy is the closest thing to a neutral OpenAI-compatible slot, so it avoids the cache-shim risk — but it is still a false label, and it collides with anyone already running an actual LiteLLM proxy (one base URL per slot).
Borrow another unused recipe (together, perplexity). Same false-label problem, and it trades one provider's quirks for another's — unknown until you read each recipe.
Document the redirect and move on. What we're doing locally now. It works, but the knowledge lives outside the tool: every future reader of modelUsed has to already know about the redirect to interpret it correctly.
Make the provider label reflect the resolved base URL (e.g. report the host alongside the slot). Would fix the diagnostic half generically for every redirected slot, without a new recipe — possibly worth doing regardless, since users will keep redirecting base URLs for endpoints that have no recipe.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Moved from #4038, opened by @awilhite on 2026-08-12. Feature requests now live in Discussions > Ideas.
What problem does this solve?
There is no recipe for opencode zen (
https://opencode.ai/zen/go/v1), so the only way to route gbrain at it is to point an unrelated provider's base URL there:This works, because both endpoints are OpenAI-compatible. It creates two problems.
1. Diagnostics report a provider that was never contacted.
thinkreturnsmodelUsed: "openrouter:glm-5.2"for a call that went entirely to opencode. The same label appears inmcp_request_log. Anyone pricing that call against OpenRouter's public rates, checking OpenRouter status during an incident, or reasoning about rate limits is looking at the wrong vendor — and nothing in the output hints at the redirect. The provider prefix reads as provenance but is only a slot name.2. The borrowed slot carries provider-specific request mutation.
src/core/ai/recipes/openrouter.tsis not a neutral OpenAI-compatible passthrough.openrouterSupportsPromptCache()matchesopenai/gpt-*,^openai/o\d, andanthropic/claude-*, and for Claude routes a fetch shim rewrites the request body to injectcache_control(via the privatex-gbrain-anthropic-prompt-cachemarker header).Today that is latent — a model id like
glm-5.2matches none of those prefixes, so the shim never fires. But any user who borrows this slot for a differently-named model can silently get OpenRouter's Anthropic cache-control body rewriting sent to an endpoint that never asked for it. The failure would surface as an opaque upstream API error with no visible connection to the cause.What does the solution look like?
A first-class
opencoderecipe undersrc/core/ai/recipes/, following the existing per-provider pattern (OPENCODE_BASE_URL/OPENCODE_API_KEY, default base URLhttps://opencode.ai/zen/go/v1), registered inrecipes/index.tssoprovider:modelresolves asopencode:<model>.The endpoint is OpenAI-compatible, so the recipe should be close to the generic shape — the value is a truthful label and the absence of another provider's request mutation, not new transport logic.
Result:
modelUsedreports the vendor actually contacted, and no user has to borrow a slot whose quirks they then inherit.Alternatives considered
LITELLM_BASE_URLat it instead.litellm-proxyis the closest thing to a neutral OpenAI-compatible slot, so it avoids the cache-shim risk — but it is still a false label, and it collides with anyone already running an actual LiteLLM proxy (one base URL per slot).together,perplexity). Same false-label problem, and it trades one provider's quirks for another's — unknown until you read each recipe.modelUsedhas to already know about the redirect to interpret it correctly.Environment: gbrain 0.42.73.1, engine postgres, macOS.
All reactions