High severity intermediate · Fix: 2-5 min

ValueError

litellm.errors.ValueError: Function calling not supported for this model

What this error means
LiteLLM raises a ValueError when attempting function calling with a model that does not support this feature.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    response = client.chat.completions.create(
  File "/usr/local/lib/python3.9/site-packages/litellm/client.py", line 120, in create
    raise ValueError("Function calling not supported for this model")
ValueError: Function calling not supported for this model
QUICK FIX
Use a LiteLLM model that supports function calling, like 'litellm-4o', or disable function calling parameters in your request.

Why it happens

LiteLLM only supports function calling with specific models that have this capability enabled. When you try to use function calling with a model that lacks this support, the client raises a ValueError to prevent unsupported API calls.

Detection

Check the model name or capabilities before enabling function calling. Catch ValueError exceptions from the client to log unsupported model usage.

Causes & fixes

1

Using a LiteLLM model that does not support function calling (e.g., base or older models).

✓ Fix

Switch to a LiteLLM model version that explicitly supports function calling, such as 'litellm-4o' or newer models documented to support this feature.

2

Passing function calling parameters to the client when the selected model does not have function calling enabled.

✓ Fix

Remove function calling parameters from the request or conditionally add them only if the model supports function calling.

Code: broken vs fixed

Broken - triggers the error
python
import os
from litellm import LiteLLM

client = LiteLLM(api_key=os.environ['LITELLM_API_KEY'])

response = client.chat.completions.create(
    model="litellm-base",
    messages=[{"role": "user", "content": "Call a function"}],
    functions=[{"name": "get_time", "parameters": {}}],  # This triggers the error
)
print(response)
Fixed - works correctly
python
import os
from litellm import LiteLLM

client = LiteLLM(api_key=os.environ['LITELLM_API_KEY'])

response = client.chat.completions.create(
    model="litellm-4o",  # Changed to a model that supports function calling
    messages=[{"role": "user", "content": "Call a function"}],
    functions=[{"name": "get_time", "parameters": {}}],  # Function calling now supported
)
print(response)  # Should print the function call response without error
Changed the model to 'litellm-4o' which supports function calling, preventing the ValueError from being raised.

Workaround

Wrap the call in try/except ValueError, and if caught, retry the request without function calling parameters or switch to a supported model dynamically.

Prevention

Check the LiteLLM model documentation for function calling support before enabling it in your requests, and implement model capability checks in your code.

Python 3.9+ · litellm >=0.1.0 · tested on 0.2.x
Verified 2026-04 · litellm-4o, litellm-base
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.