BerriAI/litellm · error · Exception

Invalid value passed in for aget_assistants. Only bool or No

Error message

Invalid value passed in for aget_assistants. Only bool or None allowed

What it means

Raised by litellm.assistants.get_assistants when the caller passes an 'aget_assistants' kwarg that is neither a bool nor None. This kwarg is a LiteLLM-internal switch used to route between the sync and async implementations, and the function guards its type before proceeding. Note this variant raises a bare Exception (unlike the sibling functions which raise ValueError).

Source

Thrown at litellm/assistants/main.py:83

            model="",
            custom_llm_provider=custom_llm_provider,
            original_exception=e,
            completion_kwargs={},
            extra_kwargs=kwargs,
        )


def get_assistants(
    custom_llm_provider: Literal["openai", "azure"],
    client: Any | None = None,
    api_key: str | None = None,
    api_base: str | None = None,
    api_version: str | None = None,
    **kwargs,
) -> SyncCursorPage[Assistant]:
    aget_assistants: Final[bool | None] = kwargs.pop("aget_assistants", None)
    if aget_assistants is not None and not isinstance(aget_assistants, bool):
        raise Exception("Invalid value passed in for aget_assistants. Only bool or None allowed")
    optional_params: Final = GenericLiteLLMParams(api_key=api_key, api_base=api_base, api_version=api_version, **kwargs)
    litellm_params_dict: Final = get_litellm_params(**kwargs)

    ### TIMEOUT LOGIC ###
    timeout = optional_params.timeout or kwargs.get("request_timeout", 600) or 600
    # set timeout for 10 minutes by default

    if (
        timeout is not None
        and isinstance(timeout, httpx.Timeout)
        and supports_httpx_timeout(custom_llm_provider) is False
    ):
        read_timeout: Final = timeout.read or 600
        timeout = read_timeout  # default 10 min timeout
    elif timeout is not None and not isinstance(timeout, httpx.Timeout):
        timeout = float(timeout)
    elif timeout is None:
        timeout = 600.0

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass a real boolean: aget_assistants=True (or omit it for None).
  2. If the flag comes from config/env, coerce it: aget_assistants=parse_bool(value).
  3. Remember most users should never set this flag — call the aget_assistants async function directly instead of toggling it.

Example fix

# before
res = litellm.get_assistants(custom_llm_provider="openai", aget_assistants="true")

# after
res = await litellm.aget_assistants(custom_llm_provider="openai")
# or: litellm.get_assistants(custom_llm_provider="openai", aget_assistants=True)
Defensive patterns

Strategy: type-guard

Validate before calling

if "aget_assistants" in kwargs and not isinstance(kwargs["aget_assistants"], (bool, type(None))):
    kwargs["aget_assistants"] = parse_bool(kwargs["aget_assistants"])

Type guard

def is_valid_assistants_flag(v) -> bool:
    return v is None or isinstance(v, bool)

Try / catch

try:
    assistants = litellm.get_assistants(custom_llm_provider="openai", **kwargs)
except Exception as e:
    if "aget_assistants" in str(e):
        kwargs.pop("aget_assistants", None)
        assistants = litellm.get_assistants(custom_llm_provider="openai", **kwargs)
    else:
        raise

Prevention

When it happens

Trigger: Calling litellm.get_assistants(...) (or the a* variant) with aget_assistants set to a non-bool, e.g. aget_assistants='true', aget_assistants=1, or aget_assistants='yes'. Because it is popped from **kwargs, any truthy string triggers it.

Common situations: Passing CLI/env-var flags as strings into the kwargs dict; copying code from a tutorial that used a string flag; programmatically building kwargs where the flag came from JSON/YAML as a string.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/9d667a54150ea3f1. Report an issue: GitHub.