invoke-ai/InvokeAI · error · HTTPException

Authentication required

Error message

Authentication required

What it means

set_timesteps accepts exactly one of num_inference_steps, timesteps, or sigmas; the internal n_set count must equal 1. Passing none, two, or all three raises this ValueError, because the resulting sigma schedule would be ambiguous.

Source

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

        credentials: The HTTP authorization credentials containing the Bearer token

    Returns:
        TokenData containing user information from the token, or system user in single-user mode

    Raises:
        HTTPException: 401 Unauthorized if in multiuser mode and credentials are missing, invalid, or user is inactive
    """
    # Get configuration to check if multiuser is enabled
    config = ApiDependencies.invoker.services.configuration

    # In single-user mode (multiuser=False), always return system user with admin privileges
    if not config.multiuser:
        return TokenData(user_id="system", email="system@system.invokeai", is_admin=True)

    # Multiuser mode is enabled - validate credentials
    if credentials is None:
        # In multiuser mode, authentication is required
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Authentication required")

    token = credentials.credentials
    token_data = verify_token(token)

    if token_data is None:
        # Invalid token in multiuser mode - reject
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid or expired token")

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

    if user is None:
        # Missing, inactive, or revoked in multiuser mode - reject
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found or inactive")

    return _db_derived_token_data(token_data, user)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass exactly one argument — drop the others, e.g. set_timesteps(num_inference_steps=20)
  2. If using pre-shifted sigmas (Anima/FLUX/Z-Image), pass sigmas only
  3. Guard with an assertion/logic that clears num_inference_steps when sigmas are supplied
  4. Fix the calling pipeline (init_scheduler/_run_diffusion/denoise) to select one source

Example fix

// before
sched.set_timesteps(num_inference_steps=20, sigmas=custom_sigmas)
// after
sched.set_timesteps(sigmas=custom_sigmas)
Defensive patterns

Strategy: validation

Validate before calling

opts = [x for x in (num_inference_steps, timesteps, sigmas) if x is not None]
assert len(opts) == 1, "pass exactly one of num_inference_steps/timesteps/sigmas"

Type guard

def has_single_schedule_source(n, t, s) -> bool:
    return sum(x is not None for x in (n, t, s)) == 1

Try / catch

try:
    sched.set_timesteps(num_inference_steps=n, timesteps=t, sigmas=s)
except ValueError as e:
    if "exactly one" in str(e):
        sched.set_timesteps(num_inference_steps=n or 30)
    else:
        raise

Prevention

When it happens

Trigger: Calling set_timesteps() with no args, set_timesteps(num_inference_steps=20, sigmas=custom_sigmas), or a pipeline wrapper that forwards both a step count and an explicit sigma list from model config.

Common situations: Combining a UI 'steps' setting with a preset sigma schedule from FLUX/Z-Image, refactored pipeline code adding sigmas while keeping num_inference_steps, or calling set_timesteps() as a no-op refresh with defaults all None.

Understand the failure class

Related errors


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