feat: SSE streaming support + flexible model routing for CCR integration#67
Open
gyy0592 wants to merge 3 commits intoAmm1rr:masterfrom
Open
feat: SSE streaming support + flexible model routing for CCR integration#67gyy0592 wants to merge 3 commits intoAmm1rr:masterfrom
gyy0592 wants to merge 3 commits intoAmm1rr:masterfrom
Conversation
- chat.py: implement stream_openai_format() generator returning proper SSE events (role delta -> content delta -> stop); use StreamingResponse with text/event-stream so CCR can relay responses to Claude Code - models/gemini.py: add MODEL_ALIASES dict + resolve_model_name() for short aliases (flash, thinking, pro) and compatibility mappings - gemini.py / chat.py: remove .value calls now that model is plain str - schemas/request.py: replace GeminiModels enum with plain str field to allow arbitrary model names without schema drift Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Gemini web UI shows marketing names (e.g. "3.1 Flash") which differ from the internal identifiers accepted by gemini-webapi. Removed unverified aliases and documented the confirmed mapping: flash -> gemini-2.0-flash-exp (web UI: Gemini 3.1 Flash) thinking -> gemini-2.0-exp-advanced (web UI: Gemini 3.1 Flash Thinking) pro -> gemini-1.5-pro (web UI: Gemini 3.1 Pro) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Old model names used stale x-goog-ext header hashes from v1.8.3. Upgrade to v1.21.0 with correct identifiers: flash -> gemini-3.0-flash thinking -> gemini-3.0-flash-thinking pro -> gemini-3.1-pro Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
Update: gemini-webapi upgraded to v1.21.0 + model name fixesRoot cause foundThe previous model aliases ( Changes since last update
RecommendationUpdate |
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.
Description:
Summary
Fix streaming:
/v1/chat/completionsnow returns a proper SSEStreamingResponse(text/event-stream) whenstream=true, insteadof a plain JSON blob. This allows claude-code-router (CCR) to correctly
relay responses back to Claude Code.
Flexible model names: Removed the
GeminiModelsenum restriction.modelfield is now a plainstr, accepting any model name withoutschema drift.
Model alias resolution: Added
MODEL_ALIASESinmodels/gemini.pywith verified short names:
flash→gemini-2.0-flash-exp(UI: Gemini 3.1 Flash)thinking→gemini-2.0-exp-advanced(UI: Gemini 3.1 Flash Thinking)pro→gemini-1.5-pro(UI: Gemini 3.1 Pro)Note: the Gemini web UI shows marketing names ("3.1 Flash") which differ
from the internal identifiers accepted by gemini-webapi.
Files Changed
src/app/endpoints/chat.py— SSE streaming viastream_openai_format()generator
src/app/endpoints/gemini.py— remove.valuecall (model no longer anenum)
src/models/gemini.py—MODEL_ALIASES+resolve_model_name()src/schemas/request.py— replaceGeminiModelsenum withstr