Repository navigation
Refuse unknown model ids before reserving - #144
Merged
Merged
Conversation
skyfallwastaken
force-pushed
the
unknown-models
branch
from
September 26, 2026 19:40
b1e84d4 to
1dc549f
Compare
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.
Requests for a model id OpenRouter doesn't list used to go upstream anyway. OpenRouter rejected them with a 400, but the gateway still reserved, recorded and settled each one, so every typo left a "phantom" error row in Activity.
Now the proxy refuses an id the model listing doesn't know with a 400, before anything is reserved or recorded. The message is the same one OpenRouter uses:
<id> is not a valid model ID.An id resolves if it matches, in order:
id(this includes~aliases and listed variants such as:freeand:batch);canonical_slug(dated ids);openai/gpt-4o-mini:nitro,:floor, …). As a bonus, these now reserve at the base model's price instead of the flat unknown-model hold.If the listing itself can't be fetched, requests still go through and OpenRouter decides, as before.
Screenshots
The same two typo'd requests from a fresh account, then that account's Activity:
(The
:nitrorow still says "nitro" on this branch. The Activity PR fixes that display.)Testing
proxy.integration.test.ts::nitrovariant is forwarded unchanged, finalized, and reserved at the base model's price.proxy.test.tsfixture now lists the requested model with no fixed price, so the unknown-model-hold tests still exercise the hold.bun run typecheck: 0 errors.bun test: 0 fail.🤖 Generated with Claude Code