{"record":{"id":"a8ac335742e279d0","repo":"Significant-Gravitas/AutoGPT","slug":"codex-credentials-must-be-created-through-chatgpt","errorCode":null,"errorMessage":"Codex credentials must be created through ChatGPT sign-in","messagePattern":"Codex credentials must be created through ChatGPT sign-in","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/external/v1/integrations.py","lineNumber":548,"sourceCode":"    \"\"\"\n    Create non-OAuth credentials for a provider.\n\n    Supports creating:\n    - API key credentials (type: \"api_key\")\n    - Username/password credentials (type: \"user_password\")\n    - Host-scoped credentials (type: \"host_scoped\")\n\n    For OAuth credentials, use the OAuth initiate/complete flow instead.\n    \"\"\"\n    # Validate provider exists\n    all_providers = get_all_provider_names()\n    if provider not in all_providers:\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND,\n            detail=f\"Provider '{provider}' not found\",\n        )\n    if provider == \"codex\":\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Codex credentials must be created through ChatGPT sign-in\",\n        )\n\n    # Create the appropriate credential type\n    credentials: Credentials\n    if request.type == \"api_key\":\n        credentials = APIKeyCredentials(\n            provider=provider,\n            api_key=SecretStr(request.api_key),\n            title=request.title,\n            expires_at=request.expires_at,\n        )\n    elif request.type == \"user_password\":\n        credentials = UserPasswordCredentials(\n            provider=provider,\n            username=SecretStr(request.username),\n            password=SecretStr(request.password),","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/v1/integrations.py#L530-L566","documentation":"Raised (HTTP 400) by the external create-credentials endpoint when `provider == \"codex\"`. Codex credentials are special: they are minted through ChatGPT sign-in (an interactive OAuth-style flow) and cannot be constructed from a raw API key or password, so the generic credential-creation path is blocked for that provider.","triggerScenarios":"POST `/api/external-api/v1/integrations/codex/credentials` with any body (api_key, user_password, or host_scoped type).","commonSituations":"Users trying to paste an OpenAI/ChatGPT API key into the platform as a Codex credential; automation scripts that uniformly create credentials across all providers and hit the codex special case.","solutions":["Create Codex credentials via the ChatGPT sign-in flow in the platform UI (or the dedicated sign-in endpoint), not this API.","Exclude `codex` from programmatic credential-creation loops; treat 400 here as expected behavior.","If you need an OpenAI API key for blocks, create it under the appropriate non-codex provider instead."],"exampleFix":"# before\nPOST /integrations/codex/credentials {\"type\": \"api_key\", \"api_key\": \"sk-...\"}  # 400\n\n# after: use ChatGPT sign-in (platform UI / dedicated endpoint) to mint codex creds","handlingStrategy":"validation","validationCode":"NON_CREATABLE = {\"codex\"}\nif provider in NON_CREATABLE:\n    raise ValueError(f\"{provider} credentials require ChatGPT sign-in; use the sign-in flow\")","typeGuard":null,"tryCatchPattern":"try:\n    client.post(f\"/integrations/{provider}/credentials\", json=body)\nexcept HTTPError as e:\n    if e.response.status_code == 400 and \"ChatGPT sign-in\" in e.response.text:\n        redirect_user_to_sign_in(provider)  # expected path for codex\n    else:\n        raise","preventionTips":["Maintain a client-side exclusion list of sign-in-only providers (codex) in automation scripts.","Do not assume every provider accepts raw API keys via the credentials endpoint."],"tags":["credentials","codex","authorization","external-api"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}