ValueError
groq_sdk.exceptions.ValueError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
response = client.tools.call_tool(model="unsupported-model", tool_name="my_tool", input_data=data)
File "/usr/local/lib/python3.9/site-packages/groq_sdk/tools.py", line 88, in call_tool
raise ValueError(f"Model '{model}' does not support tool calling.")
ValueError: Model 'unsupported-model' does not support tool calling. Why it happens
The Groq SDK restricts tool calling to a specific set of supported models. If you specify a model that does not have tool calling capability, the SDK raises a ValueError to prevent unsupported operations. This ensures compatibility and prevents runtime failures.
Detection
Catch ValueError exceptions when calling tools and check the error message for unsupported model usage to log and handle gracefully before crashing.
Causes & fixes
Using a model name that is not in Groq's supported tool calling model list
Change the model parameter to a supported model such as 'groq-1b' or 'groq-2b' that allows tool calling.
Typo or incorrect model string passed to the tool calling method
Verify and correct the model string to exactly match one of the supported Groq models for tool calling.
Outdated Groq SDK version that lacks newer supported models
Upgrade the Groq SDK to the latest version to get updated model support lists.
Code: broken vs fixed
from groq_sdk import GroqClient
client = GroqClient()
# This line triggers the error because 'unsupported-model' is not allowed
response = client.tools.call_tool(model="unsupported-model", tool_name="my_tool", input_data={}) import os
from groq_sdk import GroqClient
os.environ["OPENAI_API_KEY"] = "your_api_key_here"
client = GroqClient()
# Fixed: Use a supported model for tool calling
response = client.tools.call_tool(model="groq-1b", tool_name="my_tool", input_data={})
print(response) Workaround
Wrap the tool calling code in try/except ValueError, and if caught, fallback to a default supported model or skip the tool call.
Prevention
Always check Groq SDK documentation for the current list of supported models for tool calling and validate model names before making calls.