BerriAI/litellm · error · ValueError

Invalid value passed in for async_delete_assistants. Only…

Error message

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

What it means

litellm.delete_assistants() pops async_delete_assistants to select the sync or async deletion path. As with the other assistant endpoints, the flag must be bool or None — any other type raises this ValueError before the delete request is built. The public API never requires you to pass it.

Solutions

  1. Use litellm.delete_assistants() sync or litellm.async_delete_assistants() async rather than the flag
  2. If passing it, pass True/False (or None), never a string or int
  3. Strip internal flags (async_delete_assistants, aget_assistants, async_create_assistants) from forwarded kwargs
  4. Normalize booleans at your API boundary before calling LiteLLM

Example fix

# before
result = litellm.delete_assistants(
    custom_llm_provider="openai",
    assistant_id="asst_123",
    async_delete_assistants="yes",
)

# after
result = await litellm.async_delete_assistants(
    custom_llm_provider="openai",
    assistant_id="asst_123",
)
Defensive patterns

Strategy: type-guard

Validate before calling

kwargs.pop("async_delete_assistants", None)
deleted = litellm.delete_assistants(custom_llm_provider="openai", **kwargs)

Type guard

def is_bool_or_none(value: object) -> bool:
    return value is None or isinstance(value, bool)

Try / catch

try:
    deleted = litellm.delete_assistants(custom_llm_provider="openai", **kwargs)
except ValueError as e:
    if "async_delete_assistants" in str(e):
        raise TypeError("pass a bool or use litellm.async_delete_assistants()") from e
    raise

Prevention

When it happens

Trigger: Calling litellm.delete_assistants(..., async_delete_assistants="true") or =1; forwarding unsanitized kwargs dicts (e.g. from a web handler) that contain the internal flag as a non-bool.

Common situations: JSON request bodies where booleans are strings; framework adapters that pass through everything; older snippets using string flags copied into new code.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at litellm/assistants/main.py:425

        )


def delete_assistant(
    custom_llm_provider: Literal["openai", "azure"],
    assistant_id: str,
    client: Any | None = None,
    api_key: str | None = None,
    api_base: str | None = None,
    api_version: str | None = None,
    **kwargs,
) -> AssistantDeleted | Coroutine[Any, Any, AssistantDeleted]:
    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)

    async_delete_assistants: Final[bool | None] = kwargs.pop("async_delete_assistants", None)
    if async_delete_assistants is not None and not isinstance(async_delete_assistants, bool):
        raise ValueError("Invalid value passed in for async_delete_assistants. Only bool or None allowed")

    ### 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

    response: AssistantDeleted | Coroutine[Any, Any, AssistantDeleted] | None = None

View on GitHub (pinned to 77b7c6c40c)