Skip to content
Source
Sign inSign up
TanStack/schemas

Route OpenCode Zen rows on each model's protocol api #347

Mergedposthog[bot](GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/347/headmerged by tombeckenham View on GitHub

Why

The daily OpenCode Zen spec sync now fails with a 404, so the provider shows as degraded and its routes cannot be refreshed. The cause is a change in the upstream source format, not an outage.

Observed

  • ingest_failed for opencode at the 2026-10-17 spec-sync shard: fetch failed: https://raw.githubusercontent.com/anomalyco/opencode/dev/packages/console/app/src/routes/zen/openai/v1/chat/completions.ts → 404 Not Found.
  • /v1/status shows opencode as degraded. opencode-go is not affected.

Cause

  • models.dev 05585a4 ("give each model its own inference endpoint") changed the OpenCode provider api from https://opencode.ai/inference/v1 to .../inference/openai/v1. It also gave each model its own provider.api: inference/openai/v1, inference/anthropic/v1 or inference/google/v1beta.
  • parseOpenCodeCatalog applied the provider api to every row. So Anthropic rows got inference/openai/v1/messages and Gemini rows got inference/openai/v1/models/<id>. These are not served paths.
  • opencode-routes.ts mapped inference/openai/v1/... to routes/zen/openai/v1/..., and that directory does not exist. The console's lib/inference-proxy.ts maps the routes/zen/v1 handlers onto the protocol paths (/openai/v1/chat/completions, /openai/v1/responses, /anthropic/v1/messages, /google/v1beta/models/<model>). This matches the Inference API docs.

Fix

  • opencode-catalog.ts: a Zen row uses its own provider.api when the row states one. Otherwise it uses the provider api. Both must be opencode.ai paths.
  • opencode-routes.ts: protocol paths map back to the routes/zen/v1 handler that the proxy serves them from. A path that its protocol does not serve (for example openai/v1/messages) is refused, and nothing is fetched.
  • Go is unchanged. It keeps its documented v1/... ids, and a test now pins this.
  • Review follow-ups:
    • The schemaEndpointId fact source now points at the model's provider object when that object states api.
    • An unreadable api names its model.
    • An unknown inference/<x>/... prefix is refused with an opencode: error instead of a raw fetch 404.

Evidence

  • Live reproduction with the adapter's real fetchSpec against models.dev and GitHub:
    • Before: FAIL fetch failed: …/routes/zen/openai/v1/chat/completions.ts → 404 Not Found. This is the same as production.
    • After: the spec builds. The listing binds inference/openai/v1/chat/completions (25), inference/openai/v1/responses (30), inference/anthropic/v1/messages (17), and inference/google/v1beta/models/<id> (8) to v1/chat/completions.ts, v1/responses.ts, v1/messages.ts and v1/models/[model].ts.
  • New regression tests in opencode-catalog.test.ts and opencode-routes.test.ts: all 7 original cases fail before the fix and pass after it. The follow-up adds cases for an empty api, unknown prefixes, Go ids, and fact-source provenance.
  • CI steps run locally: frozen install, check, lint, typecheck, check:client, test (217 files, 2038 tests), build. All pass.

Review

Independent review of the first commit found no blocking issues. Its non-blocking points are addressed above, except two that were declined on purpose:

  • Refusing an npm/api disagreement in the catalog parser. The 15-minute poll must not fail for the whole provider over one row. Spec sync already fails closed, and bindSyncedRoutesOnly keeps unsynced ids from being served.
  • A Go error-prefix nit. It cannot trigger.

Notes

  • Stored Zen route ids move from inference/v1/... to the protocol paths that models.dev now states. Each moved row emits one model.updated.
  • No pricing code changed. The other open signals have their own issues and are not part of this PR: #346 (Vercel), #324 and #331 (Azure), #304 (FAL).

Created with PostHog Desktop

🤖 Generated with Claude Code

    1. Deploying with &nbsp;Cloudflare Workers &nbsp;Cloudflare Workers

      The latest updates on your project. Learn more about integrating Git with Workers.

      StatusNameLatest CommitPreview URLUpdated (UTC)
      ✅ Deployment successful!
      View logs
      modelschemas86512d44Commit Preview URL

      Branch Preview URL
      Oct 18 2026, 08:44 AM
    2. tombeckenham merged thisf617ad4

    3. tombeckenham closed this

Sign in to join this conversation.