Repository navigation
Conversation
diegosouzapw
added a commit
to cheaper-inference/OmniRoute
that referenced
this pull request
Aug 4, 2026
…9253) * fix(translator): harden Claude format detection for model validation Co-authored-by: Ervareza Naurian <rianskp644@gmail.com> Inspired-by: decolua/9router#2949 * chore(changelog): fragment for #9253 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Ervareza Naurian <rianskp644@gmail.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#9253) * fix(translator): harden Claude format detection for model validation Co-authored-by: Ervareza Naurian <rianskp644@gmail.com> Inspired-by: decolua/9router#2949 * chore(changelog): fragment for cheaper-inference#9253 --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: Ervareza Naurian <rianskp644@gmail.com>
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.
Problem
When validating custom models in Claude Code CLI (e.g.
/model cbai/glm-5.2), Claude Code sends a non-streaming (stream: false) POST request to/v1/messages.Upstream OpenAI-compatible providers return standard OpenAI JSON (
{"choices": [...], "usage": {"prompt_tokens": 751}}). 9router's format resolution defaulted toopenaibecause:detectFormatByEndpointwas attemptingnew URL(request.url)on relative endpoints, throwing an unhandledTypeError: Invalid URL.detectFormat(body)did not inspect the endpoint oranthropic-versionheader, falling back toopenai.As a result, 9router returned raw OpenAI format JSON without converting it to Anthropic format (
{"type": "message", "usage": {"input_tokens": 751}}), causing Claude Code CLI to crash with:Unable to validate model: undefined is not an object (evaluating 'z.usage.input_tokens')Fix
open-sse/translator/formats.js: UpdatedetectFormatByEndpointto match/messagesendpoints and safely handle null/relative paths.src/sse/handlers/chat.js: Extract endpoint safely fromclientRawRequest?.endpointbefore tryingrequest?.urlto avoidInvalid URLparsing errors.open-sse/handlers/chatCore.js: Set fallbacksourceFormattoFORMATS.CLAUDEwhenever the endpoint contains/messages.open-sse/services/provider.js: Add support foranthropic-versionheader in format detector.Tests
POST http://127.0.0.1:20128/v1/messageswithcbai/glm-5.2:type: "message"andusage: { input_tokens, output_tokens }.