Repository navigation
fix(web): tag ChatGPT BYOK models and skip its balance gate - #6310
Conversation
…edit gate Tag models the ChatGPT connection serves with `hasUserByokAvailable`, so the model picker and the extension show the BYOK badge like pasted BYOK keys. The tag reuses the same served-model gate as routing, so only models the delegated route can carry are tagged. Skip the zero-balance paid-model block when the ChatGPT subscription pays for the request. The request bills the ChatGPT plan, not Kilo credits, so a zero-balance account must not be blocked before reaching OpenAI. Abuse and organization policy checks still apply.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit Files Reviewed (1 file)
Previous Review Summaries (2 snapshots, latest commit 33a69d2)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 33a69d2)Status: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit Files Reviewed (6 files)
Previous review (commit 66f0f23)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (7 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
An organization member resolves an eligible ChatGPT request through their personal connection, but the organization catalog only tagged organization BYOK keys. Apply the same tag in getAvailableModelsForOrganization for member subjects, so the organization model pickers and the extension match the personal list. Share the tag through tagOpenAiChatGptByokModels so the personal and organization catalog paths cannot drift.
The models route now reads the ChatGPT connection, but this suite's drizzle mock has no `where`, so every authenticated request returned 500. Mock `tagOpenAiChatGptByokModels` in the suite, like the route test does.
Summary
An enabled "Sign in with ChatGPT" connection now behaves like a user BYOK credential in two places:
GET /api/openrouter/modelstags every OpenAI model the ChatGPT project serves withhasUserByokAvailable: true. The model picker and the extension then show theBYOKbadge, matching the pasted-key path. The tag reuses the same served-model gate as routing, so only models the delegated route can carry are tagged;-proaliases,gpt-oss, and Kilo-exclusive slugs stay untagged.402 Paid Model - Credits Required. The request bills the ChatGPT plan, not Kilo credits. A newskipBalanceCheckprovider flag carries this; abuse and organization policy checks still apply.Verification
Manual paths on the local stack (
http://localhost:5200) with a personal user and a real ChatGPT connection:POST /api/openrouter/responses(openai/gpt-5-nano) at zero balance: server loggedRouting request to openai-chatgpt; OpenAI returned429 subscription_sharing_usage_limit_exceeded. No402. The account is at its sharing quota, so no200.POST /api/openrouter/responses(anthropic/claude-sonnet-4) at zero balance: still402, so the gate is unchanged for other providers.GET /api/openrouter/models: 44 of 60 OpenAI models taggedhasUserByokAvailable: true;openai/gpt-5.6-luna-pro,openai/gpt-oss-120b, andopenai/gpt-5.6-sol-discounteduntagged.Visual Changes
N/A
Reviewer Notes
computeCloudAgentNextBalanceCheckEligibility, which does not know about the ChatGPT connection. A zero-balance user can still hit the worker-side $1 minimum. Out of scope for this change.getOpenAiChatGptByokModelIdsreads the connection once and calls the cached served-model lookup per OpenAI model.