invoke-ai/InvokeAI · error · HTTPException

Invalid or expired authentication token

Error message

Invalid or expired authentication token

What it means

When prediction_type is 'flow_prediction', the scheduler must operate in the rectified-flow sigma regime (use_flow_sigmas=True), since flow models predict velocity over flow sigmas. The constructor raises this ValueError when the combination is mismatched; the comment notes it is 'not strictly invalid' but almost certainly a misconfiguration.

Source

Thrown at invokeai/app/api/auth_dependencies.py:134

    Returns:
        TokenData containing user information from the token

    Raises:
        HTTPException: If token is missing, invalid, or expired (401 Unauthorized)
    """
    if credentials is None:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Missing authentication credentials",
            headers={"WWW-Authenticate": "Bearer"},
        )

    token = credentials.credentials
    token_data = verify_token(token)

    if token_data is None:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Invalid or expired authentication token",
            headers={"WWW-Authenticate": "Bearer"},
        )

    # Verify the token still grants access: user exists, is active, epoch is current.
    user = resolve_authorized_user(token_data)

    if user is None:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="User account is inactive or does not exist",
            headers={"WWW-Authenticate": "Bearer"},
        )

    return _db_derived_token_data(token_data, user)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Set use_flow_sigmas=True when prediction_type='flow_prediction'
  2. Keep use_flow_sigmas=False and switch prediction_type to 'epsilon' or 'v_prediction' for VP-SDE regime
  3. Update the scheduler config file/preset so the two flags agree

Example fix

// before
sched = ERSDEScheduler(prediction_type="flow_prediction", use_flow_sigmas=False)
// after
sched = ERSDEScheduler(prediction_type="flow_prediction", use_flow_sigmas=True)
Defensive patterns

Strategy: validation

Validate before calling

assert not (prediction_type == "flow_prediction" and not use_flow_sigmas)

Type guard

def is_consistent_flow_config(pt, use_flow_sigmas) -> bool:
    return pt != "flow_prediction" or bool(use_flow_sigmas)

Try / catch

try:
    sched = ERSDEScheduler(prediction_type=pt, use_flow_sigmas=u)
except ValueError as e:
    if "use_flow_sigmas" in str(e):
        sched = ERSDEScheduler(prediction_type=pt, use_flow_sigmas=True)
    else:
        raise

Prevention

When it happens

Trigger: ERSDEScheduler(prediction_type='flow_prediction', use_flow_sigmas=False) — e.g. reusing a VP-SDE-style config dict while only changing prediction_type, or a FLUX/Anima/rectified-flow model being loaded with the default use_flow_sigmas=False.

Common situations: Adapting a VP-diffusion pipeline to a rectified-flow checkpoint, copying scheduler args from a stable-diffusion config, or toggling prediction_type without updating use_flow_sigmas.

Understand the failure class

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/cae6983400f6d69a. Report an issue: GitHub.