Significant-Gravitas/AutoGPT · error · HTTPException

Codex credentials must be created through ChatGPT sign-in

Error message

Codex credentials must be created through ChatGPT sign-in

What it means

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.

Source

Thrown at autogpt_platform/backend/backend/api/external/v1/integrations.py:548

    """
    Create non-OAuth credentials for a provider.

    Supports creating:
    - API key credentials (type: "api_key")
    - Username/password credentials (type: "user_password")
    - Host-scoped credentials (type: "host_scoped")

    For OAuth credentials, use the OAuth initiate/complete flow instead.
    """
    # Validate provider exists
    all_providers = get_all_provider_names()
    if provider not in all_providers:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail=f"Provider '{provider}' not found",
        )
    if provider == "codex":
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Codex credentials must be created through ChatGPT sign-in",
        )

    # Create the appropriate credential type
    credentials: Credentials
    if request.type == "api_key":
        credentials = APIKeyCredentials(
            provider=provider,
            api_key=SecretStr(request.api_key),
            title=request.title,
            expires_at=request.expires_at,
        )
    elif request.type == "user_password":
        credentials = UserPasswordCredentials(
            provider=provider,
            username=SecretStr(request.username),
            password=SecretStr(request.password),

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Create Codex credentials via the ChatGPT sign-in flow in the platform UI (or the dedicated sign-in endpoint), not this API.
  2. Exclude `codex` from programmatic credential-creation loops; treat 400 here as expected behavior.
  3. If you need an OpenAI API key for blocks, create it under the appropriate non-codex provider instead.

Example fix

# before
POST /integrations/codex/credentials {"type": "api_key", "api_key": "sk-..."}  # 400

# after: use ChatGPT sign-in (platform UI / dedicated endpoint) to mint codex creds
Defensive patterns

Strategy: validation

Validate before calling

NON_CREATABLE = {"codex"}
if provider in NON_CREATABLE:
    raise ValueError(f"{provider} credentials require ChatGPT sign-in; use the sign-in flow")

Try / catch

try:
    client.post(f"/integrations/{provider}/credentials", json=body)
except HTTPError as e:
    if e.response.status_code == 400 and "ChatGPT sign-in" in e.response.text:
        redirect_user_to_sign_in(provider)  # expected path for codex
    else:
        raise

Prevention

When it happens

Trigger: POST `/api/external-api/v1/integrations/codex/credentials` with any body (api_key, user_password, or host_scoped type).

Common situations: 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.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/a8ac335742e279d0. Report an issue: GitHub.