Repository navigation
fix(core): read ChatGPT plan speeds from the account's own model list - #66705
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks sound. I read the diff against ProviderRefresh.start, SharedCache and how models.dev names speeds. The changed test files pass (34/34) and tsc -b for packages/core passes. I couldn't run either sign-in live without ChatGPT credentials.
Public API: unchanged. The new endpoints are internal fetches, with no new config, flags or plugin API.
On the Pro case you couldn't check: a user's dump of /v1/models from a Pro $200 account in #64968 shows service_tiers IDs priority and ultrafast for gpt-6.2-sol (and only priority for gpt-6.2-astra). That is exactly what allowed matches, so Ultrafast should come back for eligible Sign in with ChatGPT accounts. The Codex list's tier IDs for a Pro account are still unconfirmed.
No blocking concerns.
Issue for this PR
Closes #64968
Supersedes #64528, which turned the account list back on for Sign in with ChatGPT only and let it hide models. This covers both sign-ins and also decides speeds.
Type of change
What does this PR do?
The ChatGPT sign-ins (Codex and Sign in with ChatGPT) now read the signed-in account's own model list from OpenAI and use it to decide which speeds each model offers. The models.dev plan lists are the fallback.
Speeds depend on the plan, not just the model. Ultrafast is on Pro and eligible Enterprise and Edu plans only (OpenAI help), and models.dev can only list it for everyone or no one. OpenAI lists each model's speeds per account (
service_tiers), so opencode now follows that:How a model is decided:
The account list never hides a model on its own. When GPT-6.1 Sol launched,
/v1/modelsleft it out for some accounts for days (#52878), which is why full syncing was turned off in #53466. A model it doesn't name still follows the plan list. A model it names that the plan list doesn't have is offered, as long as the OpenAI catalog has it.The lists load in the background through
ProviderRefresh.startandSharedCache, like the Copilot and DigitalOcean lists: at startup, on an account switch and every 10 minutes, reloading providers only when the list changed.GET https://chatgpt.com/backend-api/codex/models?client_version=99.0.0. The endpoint requiresclient_versionand hides models whoseminimal_client_versionis newer, so it asks as the newest client.GET https://api.openai.com/v1/models, the account list OpenAI documents for this route.The shared part is
packages/core/src/plugin/provider/openai-account-models.ts. This also removes the commented-out/v1/modelssync it replaces fromchatgpt.ts.How did you verify your code works?
{ models: [{ slug, visibility, supported_in_api, service_tiers: [{ id }] }] }, and every listed model has onlypriority. The Codex endpoint returns 400 withoutclient_version.provider-openai.test.tsandprovider-chatgpt.test.ts: the account list removes a speed the plan list has, adds one it lacks, adds a model only it lists, and leaves a model it omits to the plan list. Existing tests now serve an unavailable list instead of reaching the network.bun run checkpasses. The changed test files pass with--rerun-each 10.Not verified live: a Pro account's list. The
/v1/modelsdump from a Pro $200 account in #64968 listspriorityandultrafastforgpt-6.2-sol, which is what this matches. The Codex list for a Pro account is unconfirmed.Screenshots / recordings
Not a UI change.
Checklist