BerriAI/litellm · error · Exception

Mode {mode} not supported. See modes here: https://docs.lite

Error message

Mode {mode} not supported. See modes here: https://docs.litellm.ai/docs/proxy/health

What it means

ahealth_check() dispatches on the mode argument via a mode_handlers registry (chat, embedding, audio transcription, etc.). A mode string that is not a key in that registry raises this Exception pointing at the health-check docs.

Source

Thrown at litellm/main.py:8421

                model_params=model_params,
                litellm_logging_obj=litellm_logging_obj,
            )

        mode_handlers: Final = HealthCheckHelpers.get_mode_handlers(
            model=model,
            custom_llm_provider=custom_llm_provider,
            model_params=model_params,
            prompt=prompt,
            input=input,
        )

        if mode in mode_handlers:
            _response: Final = await mode_handlers[mode]()
            # Only process headers for chat mode
            _response_headers: Final[dict] = getattr(_response, "_hidden_params", {}).get("headers", {}) or {}
            return _create_health_check_response(_response_headers)
        else:
            raise Exception(f"Mode {mode} not supported. See modes here: https://docs.litellm.ai/docs/proxy/health")
    except Exception as e:
        stack_trace = _redact_string(traceback.format_exc())
        if isinstance(stack_trace, str):
            stack_trace = stack_trace[:1000]

        if mode is None:
            return {
                "error": f"error:{e}. Missing `mode`. Set the `mode` for the model - https://docs.litellm.ai/docs/proxy/health#embedding-models  \nstacktrace: {stack_trace}",
                "exception": e,
            }

        error_to_return: Final = str(e) + "\nstack trace: " + stack_trace

        raw_request_typed_dict: Final = litellm_logging_obj.model_call_details.get("raw_request_typed_dict")

        return {
            "error": error_to_return,
            "raw_request_typed_dict": raw_request_typed_dict,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a supported mode value: 'chat', 'embedding', 'audio_transcription' (check the mode_handlers keys in litellm/main.py or the docs)
  2. Or omit mode and ensure the model is in litellm.model_cost so mode is inferred
  3. Validate mode against an allowlist before calling

Example fix

# before
await litellm.ahealth_check(params, mode="embeddings")

# after
await litellm.ahealth_check(params, mode="embedding")
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_MODES = {"chat", "embedding", "audio_transcription"}  # mirror mode_handlers keys
if mode is not None and mode not in SUPPORTED_MODES:
    raise ValueError(f"unsupported health-check mode: {mode!r}; use one of {sorted(SUPPORTED_MODES)}")

Try / catch

try:
    result = await litellm.ahealth_check(params, mode=mode)
except Exception as e:
    if "not supported" in str(e) and mode:
        raise ValueError(f"bad health-check mode: {mode!r}") from e
    raise

Prevention

When it happens

Trigger: await litellm.ahealth_check(params, mode='vision') or mode='completion' — strings outside the supported set; or passing an explicit mode for a model not in litellm.model_cost (where inference would otherwise fill it in).

Common situations: Guessing mode names; writing 'embeddings' (plural) instead of 'embedding'; accepting the mode from user input without validation; checking a capability the health endpoint does not support.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/dfe5f3ce7f6f205f. Report an issue: GitHub.