Skip to content

feat: dynamic model list via browser-captured ListModels RPC - #250

Open
CharoenwitKunna wants to merge 1 commit into
iBUHub:mainfrom
CharoenwitKunna:fix/dynamic-models
Open

feat: dynamic model list via browser-captured ListModels RPC#250
CharoenwitKunna wants to merge 1 commit into
iBUHub:mainfrom
CharoenwitKunna:fix/dynamic-models

Conversation

@CharoenwitKunna

@CharoenwitKunna CharoenwitKunna commented Aug 25, 2026

Copy link
Copy Markdown

Closes #249

Changes

  • BrowserManager: capture app's own ListModels response via page.on('response') before page.goto, auto-detect API base URL from CoJqbf page config, compute SAPISIDHASH in Node to avoid Xray TypedArray issues
  • ConfigLoader: add DYNAMIC_MODELS (default true) and DYNAMIC_MODELS_TTL (default 3600000ms) env vars
  • ProxyServerSystem: make GET /v1/models and GET /v1beta/models async with live model fetch (fallback to config), add POST /api/models/refresh endpoint
  • .env.example: document new dynamic model configuration

How it works

  1. On every page.goto, the app's own POST .../ListModels RPC response is captured (URL, headers, parsed models)
  2. fetchLiveModels() returns captured models (TTL-aware), falling back to manual RPC using captured URL/API key
  3. If no capture yet, auto-detects base URL from page config (CoJqbf) and API key from page scripts
  4. Hardcoded fallback is last resort only

Testing

  • With DYNAMIC_MODELS=true and empty configs/models.json: server fetches 36 live models
  • GET /v1beta/models returns all 36 models (vs 30 static)

- BrowserManager: capture app's own ListModels response via page.on('response')
- BrowserManager: auto-detect API base URL from CoJqbf page config
- BrowserManager: compute SAPISIDHASH in Node to avoid Xray TypedArray issues
- ConfigLoader: add DYNAMIC_MODELS (default true) and DYNAMIC_MODELS_TTL env vars
- ProxyServerSystem: make /v1/models and /v1beta/models async with live fetch
- ProxyServerSystem: add POST /api/models/refresh endpoint
- .env.example: document new dynamic model configuration
@bbbugg bbbugg added the 🗓️ Planned This will be worked on later label Aug 25, 2026
@bbbugg

bbbugg commented Aug 25, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution! I tested this PR and found an important compatibility issue with the dynamically discovered model list.

For example, deep-research-preview is returned by ListModels, but the current proxy still routes requests through the generateContent API, resulting in:

400 INVALID_ARGUMENT: This model only supports Interactions API.

A model being returned by ListModels does not necessarily mean it is compatible with the proxy’s current request path. Properly supporting the full dynamic model list will require capability detection and routing different model types to the appropriate APIs, including the Interactions API.

I plan to update the model discovery and request-routing logic together when I have more time. For now, I’ll keep this PR open and continue using the manually maintained model list until the necessary API support can be implemented and tested.

Thanks again for the contribution and investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗓️ Planned This will be worked on later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: dynamic model list via browser-captured ListModels RPC

2 participants