NotImplementedError
together_ai.exceptions.NotImplementedError
Stack trace
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/together_ai/client.py", line 88, in create
raise NotImplementedError("Function calling is not supported in Together AI SDK")
together_ai.exceptions.NotImplementedError: Function calling is not supported in Together AI SDK Why it happens
Together AI's Python SDK does not implement the function calling feature available in other LLM providers. When developers try to pass function calling parameters, the SDK raises a NotImplementedError because this capability is not yet supported.
Detection
Detect this error by catching NotImplementedError exceptions from the Together AI client when calling chat completions with function calling parameters, and log the error message for clarity.
Causes & fixes
Using function calling parameters with Together AI's chat completion client
Remove function calling parameters from the request or switch to a provider that supports function calling.
Assuming Together AI SDK supports OpenAI-compatible function calling features
Consult Together AI SDK documentation to confirm supported features before implementation.
Code: broken vs fixed
from together_ai import TogetherAI
client = TogetherAI(api_key=os.environ['TOGETHER_API_KEY'])
response = client.chat.completions.create(
model="together-large",
messages=[{"role": "user", "content": "Hello"}],
functions=[{"name": "get_time", "parameters": {}}], # This triggers the error
)
print(response) import os
from together_ai import TogetherAI
client = TogetherAI(api_key=os.environ['TOGETHER_API_KEY'])
response = client.chat.completions.create(
model="together-large",
messages=[{"role": "user", "content": "Hello"}]
# Removed functions parameter to fix NotImplementedError
)
print(response) # Now works without function calling Workaround
If function calling is essential, catch the NotImplementedError and fallback to manual prompt engineering to simulate function calls or switch to a provider like OpenAI or Anthropic that supports function calling.
Prevention
Before implementing advanced features like function calling, verify the SDK's feature support in official Together AI documentation to avoid unsupported calls.