anomalyco / anomalyco/opencode
V2 runner sends a non-credential env var as the bearer API key for env-configured providers
@neriousy is already working on this.
Since Aug 22, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
models.dev lists a provider's env vars in setup order, e.g.
cloudflare-workers-ai: ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_KEY"].
The integration layer registers that list verbatim and connection resolution picks the
first set var as the credential, so with the standard two-var setup the account id is
sent as Authorization: Bearer <account-id> → every request fails with Cloudflare's
{"code":10000,"message":"Authentication error"}.
Same shape for:
| provider | env order (models.dev) | wrong bearer value |
|---|---|---|
| cloudflare-workers-ai | ACCOUNT_ID → API_KEY | account id |
| snowflake-cortex | SNOWFLAKE_ACCOUNT → CORTEX_PAT | account identifier |
| databricks | DATABRICKS_HOST → TOKEN | host name |
| neon | NEON_AI_GATEWAY_BASE_URL → TOKEN | base URL |
#43077 fixed this class for google-vertex only (v2 branch); these four are still
unfiltered on both dev and v2. v1 is unaffected — its loader picks
CLOUDFLARE_API_KEY explicitly and refuses to derive a key when several vars exist.
Suggested fix: when registering the integration's env method, keep only
credential-shaped names (*_API_KEY, *_TOKEN, *_PAT) if any match, falling back to
the full list otherwise. I have a fix and tests, opening a PR against this.
Plugins
No response
OpenCode version
dev @ 1.18.21 (also reproducible on the v2 branch)
Steps to reproduce
export CLOUDFLARE_ACCOUNT_ID=<id>andexport CLOUDFLARE_API_KEY=<key>(no stored auth)- Start opencode in any project
- Select a
cloudflare-workers-ai/*model and send any prompt - Every request returns
401 {"code":10000,"message":"Authentication error"};
the outbound request carriesAuthorization: Bearer <ACCOUNT_ID>instead of the key
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.