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
I tried working with Aiden on discord to add the service through a custom provider. I suspect there's some filtering on the part of Agentrouter that prevents non-approved tool use. They have listed codex, claude as supported. I have attempted another CLI tool as well which also fails. I've written to the Agentrouter team and they have not responded.
Got this working on opencode 1.14.22. Three separate problems stacking on top of each other:
AgentRouter fingerprints the HTTP client. Their backend is OneAPI-based (you can see X-Oneapi-Request-Id in response headers), and unless the request looks like Claude Code they reject it with unauthorized client detected. A spoofed User-Agent alone isn't enough, you also need the x-stainless-* set and anthropic-* headers that the real Claude Code CLI sends.
opencode bug #22608: custom headers in opencode.json (especially User-Agent) are silently dropped before fetch. So any config-based approach (like the RooCode one posted above) can't work regardless of what you put in there.
AgentRouter emits a malformed data: null SSE chunk inside streams, which makes the AI SDK's Zod validator throw Type validation failed: Value: null has to be filtered.
Workaround: a small plugin that patches globalThis.fetch for agentrouter.org only while other providers are untouched.
Fully quit and restart opencode after adding this (config + plugins load at startup).
Heads up on title generation
Opencode uses small_model for background title generation. When that goes through AgentRouter you'll occasionally get sensitive_words_detected from their Chineeese content filter on otherwise normal prompts, the actual chat works fine, only the auto-title fails.
Activity
github-actions commentedon Sep 25, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Sep 25, 2025
We will need to add to models.dev, you should still be able to use it if you define custom provider tho: https://opencode.ai/docs/providers/#custom-provider
santoshd commentedon Oct 15, 2025
I tried working with Aiden on discord to add the service through a custom provider. I suspect there's some filtering on the part of Agentrouter that prevents non-approved tool use. They have listed codex, claude as supported. I have attempted another CLI tool as well which also fails. I've written to the Agentrouter team and they have not responded.
alpgul commentedon Nov 28, 2025
Temporary solution:
gethoopp commentedon Apr 23, 2026
unauthorized client detected, contact support for assistance at https://discord.com/invite/V6kaP6Rg44
got this when use api key from agent router
Lypt1x commentedon Apr 23, 2026
@gethoopp
Got this working on opencode 1.14.22. Three separate problems stacking on top of each other:
AgentRouter fingerprints the HTTP client. Their backend is OneAPI-based (you can see
X-Oneapi-Request-Idin response headers), and unless the request looks like Claude Code they reject it withunauthorized client detected. A spoofedUser-Agentalone isn't enough, you also need thex-stainless-*set andanthropic-*headers that the real Claude Code CLI sends.opencode bug #22608: custom
headersin opencode.json (especiallyUser-Agent) are silently dropped before fetch. So any config-based approach (like the RooCode one posted above) can't work regardless of what you put in there.AgentRouter emits a malformed
data: nullSSE chunk inside streams, which makes the AI SDK's Zod validator throwType validation failed: Value: nullhas to be filtered.Workaround: a small plugin that patches globalThis.fetch for
agentrouter.orgonly while other providers are untouched.~/.config/opencode/opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "agentrouter": { "npm": "@ai-sdk/openai-compatible", "name": "agentrouter", "options": { "baseURL": "https://agentrouter.org/v1", "apiKey": "sk-YOUR_KEY" }, "models": { "glm-4.6": { "name": "glm-4.6", "limit": { "context": 200000, "output": 65536 } }, "claude-opus-4-6": { "name": "claude-opus-4-6", "limit": { "context": 200000, "output": 65536 } }, "claude-haiku-4-5-20251001": { "name": "claude-haiku-4-5-20251001", "limit": { "context": 200000, "output": 65536 } }, "deepseek-v3.1": { "name": "deepseek-v3.1", "limit": { "context": 200000, "output": 65536 } } } } } }No
headersblock, the plugin does that.apiKeyhandlesAuthorization: Bearerautomatically via the SDK.~/.config/opencode/plugins/agentrouter-headers.jsFully quit and restart opencode after adding this (config + plugins load at startup).
Heads up on title generation
Opencode uses
small_modelfor background title generation. When that goes through AgentRouter you'll occasionally getsensitive_words_detectedfrom their Chineeese content filter on otherwise normal prompts, the actual chat works fine, only the auto-title fails.Workarounds:
Route titles elsewhere:
{ "model": "agentrouter/claude-opus-4-6", "small_model": "anthropic/claude-haiku-4-5" }Or force titles onto the main model:
{ "model": "agentrouter/claude-opus-4-6", "small_model": "agentrouter/claude-opus-4-6" }Would obviously be nicer if opencode just fixed #22608 so you could configure the headers directly in opencode.json, but for now this does the job.
Hope it helps, happy coding!
sbeygi commentedon Jun 26, 2026
The solution offered by Lypt1x works. This is just an updated JSON for opencode.