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
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
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:
Plus account, GPT-6.2 Sol on the Codex sign-in
- Standard, Fast, Ultrafast (Ultrafast silently runs at normal speed)
+ Standard, Fast
Pro account
Standard, Fast, Ultrafast
How a model is decided:
account list names the model?
yes → offer it, with only the speeds the account list names
no → models.dev plan list, as before
account list not loaded yet or failed → models.dev plan list, as before
The account list never hides a model on its own. When GPT-6.1 Sol launched, /v1/models left 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.start and SharedCache, like the Copilot and DigitalOcean lists: at startup, on an account switch and every 10 minutes, reloading providers only when the list changed.
- Codex:
GET https://chatgpt.com/backend-api/codex/models?client_version=99.0.0. The endpoint requires client_version and hides models whose minimal_client_version is newer, so it asks as the newest client.
- Sign in with ChatGPT:
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/models sync it replaces from chatgpt.ts.
How did you verify your code works?
- Live, on a Plus account: both endpoints return
{ models: [{ slug, visibility, supported_in_api, service_tiers: [{ id }] }] }, and every listed model has only priority. The Codex endpoint returns 400 without client_version.
- New tests in
provider-openai.test.ts and provider-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 check passes. The changed test files pass with --rerun-each 10.
Not verified live: a Pro account's list. The /v1/models dump from a Pro $200 account in #64968 lists priority and ultrafast for gpt-6.2-sol, which is what this matches. The Codex list for a Pro account is unconfirmed.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR