feat(ai): Claude Opus 5 on OpenRouter (BYOK) + correct the Opus 1M context windows#42
Merged
Conversation
Gateway (LevelCode Cloud) users get Opus 5 from the server roster with no editor release — that side is thin.ly. This is the BYOK half: the OpenRouter picker, the local caps table, and the sketch cost meter. - providers/index.js — a picker row for `anthropic/claude-opus-5`. Placed second, under the flagship, since it is the frontier pick most people reach for. - providers/catalog.js — an explicit CAPS row, for the same reason Kimi K3 has one: the `claude-` heuristic reports 200K, so a 1M window would drive the in-run context meter to cry "full" at a fifth of the real budget. - sketch/pricing.js — Opus 5 ties Opus 4.8's $5/$25, which the `claude-opus` family fallback already produced. The FAST variant does NOT: it is $10/$50, and the fallback was quietly pricing it at half. Both are pinned now, so the meter is honest whichever slug a BYOK user types. - sketch.js — MODEL_TIERS openrouter.powerful moves 4.8 → 5. Same price, newer model. It also fixes a latent wart: the old id was never in the OpenRouter registry, so a per-node model override naming it failed validation and silently fell back. Revert this one line if you'd rather pin the tier to 4.8. Prices/context confirmed against the OpenRouter models API (2026-07-24): $5/M in · $25/M out · $0.50/M cached · 1M ctx (fast variant: $10/$50). Verified at runtime, not just in tests: the row renders in the picker, caps resolve to 1,000,000, tools/vision on, and isAnthropicFamily matches so explicit prompt-cache breakpoints are sent. Full gate green (24 suites).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds OpenRouter BYOK support for Claude Opus 5 and corrects local capability/pricing metadata so LevelCode’s model picker and in-run meters (context + cost + caching gating) stay accurate when users select it.
Changes:
- Add
anthropic/claude-opus-5to the OpenRouter picker defaults. - Pin Opus 5 1M context in the local caps table to avoid heuristic under-reporting in the context meter.
- Pin Opus 5 + Opus 5 Fast pricing rows and update the Sketch “powerful” tier to Opus 5.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/levelcode-ai/providers/index.js | Adds anthropic/claude-opus-5 to OpenRouter built-in picker models. |
| extensions/levelcode-ai/providers/catalog.js | Pins Opus 5 caps (1M context + tools/vision/caching) to keep context metering correct. |
| extensions/levelcode-ai/sketch/pricing.js | Adds explicit pricing rows for Opus 5 and Opus 5 Fast to avoid incorrect family-fallback pricing. |
| extensions/levelcode-ai/sketch.js | Updates OpenRouter “powerful” tier default model to anthropic/claude-opus-5. |
| extensions/levelcode-ai/test/catalog.test.js | Extends caps tests to assert Opus 5’s 1M context pin + heuristic behavior for unlisted Claude ids. |
| extensions/levelcode-ai/test/promptCaching.test.js | Extends Anthropic-family gating test to include Opus 5 OpenRouter id. |
| extensions/levelcode-ai/test/sketch.test.js | Adds pricing assertions for Opus 5 and Opus 5 Fast ids via OpenRouter prefix handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The CAPS row for Opus 4.8 said 200K, so the in-run context meter warned "full" at a fifth of the real budget for anyone on the OpenRouter/gateway route. Every OpenRouter endpoint for that model (Anthropic first-party, Bedrock, Azure, Google) advertises 1M/128K. Fixed under the OpenRouter slug ONLY, and deliberately not under the bare id: 'claude-opus-4-8' → 200000 direct Anthropic provider 'anthropic/claude-opus-4-8' → 1000000 OpenRouter / gateway Those are two different routes sharing one key today, and I can only vouch for one of them. This extension sends no `anthropic-beta` header on the native path, so I have not confirmed the long window is reachable there — and overstating it would be the worse failure, telling the user they have room the API will refuse. Exact-id lookup beats basename, so the rows coexist and each route reports its own truth. If the native path does support 1M unheadered, the bare row is a one-line follow-up. Tests pin both sides of the split plus the unlisted-Claude heuristic default. Full gate green (24 suites).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to thin.ly #390 (Opus 5 on the Pro gateway roster). Gateway users get it from the server with no editor release — this is the BYOK half, plus a context-meter correction that affects gateway users too.
Confirmed against the OpenRouter models API (2026-07-24):
anthropic/claude-opus-5— $5/M in · $25/M out · $0.50/M cached · 1M context (fast variant $10/$50).Changes
providers/index.jsanthropic/claude-opus-5.providers/catalog.jsclaude-heuristic returns 200K, so the in-run meter warned "full" at a fifth of the real budget.sketch/pricing.jssketch.jsMODEL_TIERS.openrouter.powerful4.8 → 5.The Opus 4.8 caps row is split by route, on purpose
Two routes share one key today and I can only vouch for one. Every OpenRouter endpoint advertises 1M, but this extension sends no
anthropic-betaheader on the native path, so I have not confirmed the long window is reachable there — and overstating it is the worse failure, since it tells the user they have room the API will refuse. Exact-id lookup beats basename, so both coexist. If the native path does support 1M unheadered, the bare row is a one-line follow-up.The one judgement call
Repointing the sketch
powerfultier is the only behavior change beyond adding the model. Identical price, newer model — and it fixes a latent wart, sinceanthropic/claude-opus-4-8was never in the OpenRouter registry, so a per-node override naming it failed validation and silently fell back. Revert that one line to pin the tier to 4.8.Verification
Runtime, not just tests:
Full gate green — 24 suites.
Not changed
The gateway default stays Kimi K2.7 Code. Opus 5 is 6.67× per turn — opt-in pick, same call as the K3 rollout.