BerriAI/litellm · error · BadRequestError

{custom_llm_provider.capitalize()}Exception - Use 'watsonx_t

Error message

{custom_llm_provider.capitalize()}Exception - Use 'watsonx_text' route instead. IBM WatsonX does not support `/text/chat` endpoint. - {error_str}

What it means

Raised as BadRequestError when the provider error string contains 'model_no_support_for_function'. The message is hard-coded to talk about the watsonx 'watsonx_text' route, which is misleading: this fires for ANY provider whose error mentions that token, not just watsonx. The underlying problem is you passed tools/functions to a model or endpoint that does not support function calling.

Source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:746

            llm_provider=custom_llm_provider,
            response=getattr(original_exception, "response", None),
            litellm_debug_info=extra_information,
        )
    elif "token_quota_reached" in error_str:
        raise RateLimitError(
            message=f"{custom_llm_provider.capitalize()}Exception: Rate Limit Errror - {error_str}",
            llm_provider=custom_llm_provider,
            model=model,
            response=getattr(original_exception, "response", None),
        )
    elif "The server received an invalid response from an upstream server." in error_str:
        raise litellm.InternalServerError(
            message=f"{custom_llm_provider.capitalize()}Exception - {original_exception.message}",
            llm_provider=custom_llm_provider,
            model=model,
        )
    elif "model_no_support_for_function" in error_str:
        raise BadRequestError(
            message=f"{custom_llm_provider.capitalize()}Exception - Use 'watsonx_text' route instead. IBM WatsonX does not support `/text/chat` endpoint. - {error_str}",
            llm_provider=custom_llm_provider,
            model=model,
        )
    elif hasattr(original_exception, "status_code"):
        if original_exception.status_code == 500:
            raise litellm.InternalServerError(
                message=f"{custom_llm_provider.capitalize()}Exception - {original_exception.message}",
                llm_provider=custom_llm_provider,
                model=model,
            )
        elif original_exception.status_code == 401 or original_exception.status_code == 403:
            raise AuthenticationError(
                message=f"{custom_llm_provider.capitalize()}Exception - {original_exception.message}",
                llm_provider=custom_llm_provider,
                model=model,
            )
        elif original_exception.status_code == 400:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. For watsonx: change the model string to use the 'watsonx_text' route (e.g. 'watsonx/ibm/granite-...' via the text route) instead of '/text/chat'.
  2. Check litellm.get_model_info(model).get('supports_function_calling') before sending tools.
  3. Drop the tools/functions parameter if the model cannot use them, and parse structured output from plain text instead.
  4. Switch to a model that supports function calling (gpt-4o, claude, mistral function-call variants).

Example fix

# before
resp = litellm.completion(model="watsonx/google/flan-t5-xl", messages=msgs, tools=tools)

# after
info = litellm.get_model_info("watsonx/google/flan-t5-xl")
if not info.get("supports_function_calling"):
    resp = litellm.completion(model="watsonx/google/flan-t5-xl", messages=msgs)  # no tools
else:
    resp = litellm.completion(model="watsonx/google/flan-t5-xl", messages=msgs, tools=tools)
Defensive patterns

Strategy: validation

Validate before calling

import litellm

def supports_tools(model: str) -> bool:
    try:
        return bool(litellm.get_model_info(model).get("supports_function_calling", False))
    except Exception:
        return False

Type guard

import litellm

def is_no_function_support(e: BaseException) -> bool:
    return isinstance(e, litellm.BadRequestError) and "model_no_support_for_function" in str(e)

Try / catch

try:
    resp = litellm.completion(model=m, messages=msgs, tools=tools)
except litellm.BadRequestError as e:
    if "model_no_support_for_function" in str(e):
        resp = litellm.completion(model=m, messages=msgs)  # retry without tools
    else:
        raise

Prevention

When it happens

Trigger: Calling litellm.completion(..., tools=[...]) against a model or endpoint without function-calling support — classically the watsonx '/text/chat' endpoint instead of the 'watsonx_text' route, or a base model served behind a gateway that rejects the tools parameter.

Common situations: Using IBM watsonx with the wrong model string (chat-tuned vs base text endpoint), pointing a tools-enabled agent at a completion-only or base model, or a gateway stripping/forbidding the tools field.

Related errors


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