BerriAI/litellm · error · ValueError

Invalid value passed in for async_create_assistants. Only…

Error message

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

What it means

litellm.create_assistants() pops async_create_assistants to route between sync and async creation. The flag must be bool or None; anything else raises this ValueError before any API call. It is an internal switch set by litellm.async_create_assistants(), not a user-facing parameter.

Solutions

  1. Use litellm.create_assistants() for sync and litellm.async_create_assistants() for async instead of the flag
  2. Pass only a real bool or omit async_create_assistants entirely
  3. Coerce incoming flags: bool(flag) or strip them from forwarded kwargs
  4. Add a type check on dynamic kwargs before delegating to LiteLLM

Example fix

# before
assistant = litellm.create_assistants(
    custom_llm_provider="openai",
    name="math_tutor",
    async_create_assistants="true",
)

# after
assistant = await litellm.async_create_assistants(
    custom_llm_provider="openai",
    name="math_tutor",
)
Defensive patterns

Strategy: type-guard

Validate before calling

kwargs.pop("async_create_assistants", None)
assistant = litellm.create_assistants(custom_llm_provider="openai", **kwargs)

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling litellm.create_assistants(..., async_create_assistants="yes"); passing async_create_assistants=1; generic proxying of a request kwargs dict that includes the internal flag with a string value.

Common situations: Bridges from REST/JSON payloads where booleans arrive as strings; code migration from older examples that used string flags; double-wrapping LiteLLM APIs and leaking internal kwargs through.

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/16808c80ac2a6e95. Report an issue: GitHub.

Appendix: source

Thrown at litellm/assistants/main.py:250

    model: str,
    name: str | None = None,
    description: str | None = None,
    instructions: str | None = None,
    tools: list[dict[str, Any]] | None = None,
    tool_resources: dict[str, Any] | None = None,
    metadata: dict[str, str] | None = None,
    temperature: float | None = None,
    top_p: float | None = None,
    response_format: str | dict[str, str] | None = None,
    client: Any | None = None,
    api_key: str | None = None,
    api_base: str | None = None,
    api_version: str | None = None,
    **kwargs,
) -> Assistant | Coroutine[Any, Any, Assistant]:
    async_create_assistants: Final[bool | None] = kwargs.pop("async_create_assistants", None)
    if async_create_assistants is not None and not isinstance(async_create_assistants, bool):
        raise ValueError("Invalid value passed in for async_create_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 77b7c6c40c)