anomalyco / anomalyco/opencode
BYOK providers with saved API-key credentials fail with SessionRunnerModel.ModelUnavailableError (v1.18.21)
@neriousy is already working on this.
Since Sep 6, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Summary
On v1.18.21 (Windows x64), every provider that authenticates via a stored "type": "api" credential in auth.json fails to run a prompt, throwing SessionRunnerModel.ModelUnavailableError: Model unavailable: <provider>/<model> — even though the credential itself is valid (confirmed by calling each provider's real API directly with the same key, which succeeds).
Providers that do not depend on auth.json (native free models, e.g. opencode/big-pickle, and providers that need no key, e.g. huggingface's public inference) work correctly and return real completions.
Reproduction
- Store a valid API key for any provider via the normal auth flow (results in
auth.jsoncontaining{"type":"api","key":"..."}). POST /api/sessionwith{"model":{"providerID":"<provider>","id":"<model>"}}— session is created successfully,GET /api/session/:idshows the correct model.POST /api/session/:id/promptwith a simple text prompt — request is accepted (200, admitted into the queue).- Poll
GET /api/session/:id/message— no assistant message ever appears. Server log shows:level=ERROR message="Failed to drain Session" cause="SessionRunnerModel.ModelUnavailableError: Model unavailable: <provider>/<model>"
Providers tested (all fail identically)
Groq, OpenRouter, Mistral, Cerebras, Chutes, Novita AI, NVIDIA, Google, Z.ai (zhipuai), Cloudflare Workers AI — 10/10 tested, each with a real key confirmed working against the provider's own API directly (e.g. curl https://api.groq.com/openai/v1/chat/completions with the same key succeeds; the OpenCode session for the same provider/model never completes).
Providers that work
opencode/big-pickle(built-in free model, noauth.jsonentry)huggingface/<any model>(noauth.jsonentry — public inference)
Environment
- OpenCode v1.18.21, Windows x64, downloaded from the official GitHub release asset (
opencode-windows-x64.zip) - Server started via
opencode serve --port <n> --hostname 127.0.0.1 - Confirmed on a freshly-recreated
opencode serveprocess (ruled out stale-process/cache as the cause) auth.jsoncredential shape:{"type":"api","key":"<valid key>"}(standard shape, same as used byopencode auth login)
What we ruled out
- Not a stale-process issue: restarted the server fresh, bug persists.
- Not an invalid-key issue: every key tested authenticates successfully against the provider's own API directly.
- Not a model-ID issue: tried multiple model IDs per provider, including ones taken directly from
/provider's own catalog listing for that provider. - Not a network/connectivity issue: the machine has normal internet access (confirmed against unrelated hosts), and providers that don't need
auth.jsonwork fine from the same process.
This suggests SessionRunnerModel.resolve() is failing to resolve/apply "type":"api" credentials from auth.json for third-party providers, even though the same auth.json is correctly used to populate /provider's connected list (which does show these providers as connected).
Happy to provide more logs/repro details if useful.
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.