{"record":{"id":"581fe1b3ea80936f","repo":"Significant-Gravitas/AutoGPT","slug":"codex-credential-required","errorCode":null,"errorMessage":"codex_credential_required","messagePattern":"codex_credential_required","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/chat/routes.py","lineNumber":593,"sourceCode":"            raise HTTPException(\n                status_code=503,\n                detail=\"chat_transport_not_configured\",\n            )\n        return \"platform\", None\n\n    transports = await _get_chat_transports(user_id)\n    if request is not None:\n        route_was_explicit = bool(\n            {\"llm_auth_provider\", \"llm_credential_id\"} & request.model_fields_set\n        )\n        if route_was_explicit:\n            if auth_provider == \"platform\" and credential_id is not None:\n                raise HTTPException(\n                    status_code=422,\n                    detail=\"codex_credential_not_allowed\",\n                )\n            if auth_provider == \"codex\" and credential_id is None:\n                raise HTTPException(\n                    status_code=422,\n                    detail=\"codex_credential_required\",\n                )\n            selected_route = next(\n                (\n                    transport\n                    for transport in transports\n                    if transport.auth_provider == auth_provider\n                    and transport.credential_id == credential_id\n                    and transport.available\n                ),\n                None,\n            )\n            if selected_route is None:\n                if auth_provider == \"codex\":\n                    raise HTTPException(\n                        status_code=404,\n                        detail=\"codex_credential_not_found\",","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/chat/routes.py#L575-L611","documentation":"A 422 from _resolve_new_session_llm_route: the client explicitly requested the codex route (llm_auth_provider='codex') but did not supply llm_credential_id. Codex sessions are authenticated per-user via a specific stored credential, so the provider alone is under-specified and the request is rejected.","triggerScenarios":"POST /chat/sessions with {\"llm_auth_provider\": \"codex\"} and no llm_credential_id, where at least one of the two routing fields was explicitly set (which it was — the provider).","commonSituations":"Client sends the provider from a dropdown but the credential selector is optional/empty; user has credentials listed but the form failed to attach the selected one; partial JSON serialization dropping the credential key.","solutions":["Include the codex credential id in the request: {\"llm_auth_provider\": \"codex\", \"llm_credential_id\": \"<id>\"}.","Make the credential selector required in the client when provider is 'codex'.","If the user has no codex credential, have them add one first (or fall back to the platform route by omitting both fields)."],"exampleFix":"// before\ncreateSession({llm_auth_provider: 'codex'})\n\n// after\ncreateSession({llm_auth_provider: 'codex', llm_credential_id: selectedCredentialId})","handlingStrategy":"validation","validationCode":"if (provider === 'codex' && !credentialId) {\n  showPicker('Select a codex credential first');\n  return;\n}\nawait createSession({llm_auth_provider: provider, ...(provider === 'codex' && credentialId ? {llm_credential_id: credentialId} : {})});","typeGuard":"function isCompleteCodexRoute(provider: string, credId?: string | null): boolean {\n  return provider !== 'codex' || typeof credId === 'string' && credId.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Require the credential selector when codex is chosen.","If the user has no codex credentials, steer to the platform route."],"tags":["backend","chat","codex","session-creation","http-422"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}