{"record":{"id":"9c3698e4f9b3b861","repo":"odysseus-dev/odysseus","slug":"chatgpt-subscription-connected-but-no-usable-code","errorCode":null,"errorMessage":"ChatGPT Subscription connected, but no usable Codex models were discovered for this account.","messagePattern":"ChatGPT Subscription connected, but no usable Codex models were discovered for this account\\.","errorType":"http","errorClass":"ValueError","httpStatus":502,"severity":"error","filePath":"routes/chatgpt_subscription_routes.py","lineNumber":34,"sourceCode":")\nfrom src.auth_helpers import get_current_user\nfrom src import chatgpt_subscription\n\nlogger = logging.getLogger(__name__)\n\n_DEVICE_FLOW_STORE = PendingDeviceFlowStore()\n\n\ndef _provision_endpoint(tokens: Dict, owner: Optional[str]) -> Dict:\n    access_token = tokens.get(\"access_token\")\n    refresh_token = tokens.get(\"refresh_token\")\n    if not access_token or not refresh_token:\n        raise ValueError(\"ChatGPT token response was missing access_token or refresh_token\")\n\n    base = chatgpt_subscription.DEFAULT_CHATGPT_SUBSCRIPTION_BASE_URL\n    models = chatgpt_subscription.fetch_available_models(access_token)\n    if not models:\n        raise ValueError(\"ChatGPT Subscription connected, but no usable Codex models were discovered for this account.\")\n    db = SessionLocal()\n    try:\n        auth = (\n            db.query(ProviderAuthSession)\n            .filter(\n                ProviderAuthSession.provider == chatgpt_subscription.CHATGPT_SUBSCRIPTION_PROVIDER,\n                ProviderAuthSession.owner == owner,\n            )\n            .first()\n        )\n        if auth is None:\n            auth = ProviderAuthSession(\n                id=str(uuid.uuid4())[:8],\n                provider=chatgpt_subscription.CHATGPT_SUBSCRIPTION_PROVIDER,\n                owner=owner,\n                label=\"ChatGPT Subscription\",\n                base_url=base,\n                auth_mode=\"chatgpt\",","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/chatgpt_subscription_routes.py#L16-L52","documentation":"A server-side ValueError raised in _provision_endpoint after a successful token exchange when fetch_available_models(access_token) returns an empty list. The account authenticated fine, but the API exposed no Codex-capable models for it, so provisioning refuses to create a useless endpoint. Usually an account-entitlement problem rather than a code bug.","triggerScenarios":"Signing in with a free/unpaid ChatGPT account that has no Codex access; a Plus/Team account in a region or workspace where Codex models are not enabled; the models list endpoint returning an empty or unrecognized payload after an upstream API change.","commonSituations":"User connects the wrong ChatGPT account (personal instead of the subscribed one); subscription lapsed or is billed through a region without Codex; OpenAI renames model IDs so the client-side filter matches nothing.","solutions":["Verify the signed-in ChatGPT account actually has an active subscription that includes Codex, then reconnect with that exact account.","Sign out and redo the device flow, double-checking the user_code is entered under the intended account.","Check chatgpt_subscription.fetch_available_models filtering logic against the current OpenAI models API response (model IDs may have changed).","Confirm the subscription is active (not past-due/cancelled) in the ChatGPT billing settings."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    _provision_endpoint(tokens, owner)\nexcept ValueError as e:\n    if 'no usable Codex models' in str(e):\n        show_user('Connected account has no Codex access. Sign in with a subscribed ChatGPT account.')\n    raise","preventionTips":["Surface the device-flow user_code page so users can verify which account they are authorizing.","Check the account's Codex entitlement in onboarding docs before offering the connect button.","Monitor fetch_available_models filters for model-ID renames after upstream releases."],"tags":["chatgpt","codex","entitlement","models","provisioning"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}