High severity intermediate · Fix: 2-5 min

OpenAIError

openai.OpenAIError

What this error means
The OpenAI function tool call output was not submitted, causing the assistant to fail to return the expected function call response.

Stack trace

traceback
openai.OpenAIError: Function tool call output not submitted. The assistant did not provide the required function call output in the response.
QUICK FIX
Ensure the 'functions' parameter is included with valid function definitions in the chat.completions.create call.

Why it happens

When using OpenAI's function calling feature, the assistant must include a function call output in its response. This error occurs if the assistant returns a message without the required function call data, often due to prompt misconfiguration or missing function definitions in the API call.

Detection

Check the API response for the presence of the 'function_call' field in the message object; if missing when expected, log and handle the error before processing the output.

Causes & fixes

1

The functions parameter was omitted or empty in the chat.completions.create call.

✓ Fix

Include the functions list with properly defined function schemas in the API call to enable function calling.

2

The prompt or system message does not instruct the model to use function calls.

✓ Fix

Add clear instructions in the system or user messages to trigger function calls, such as 'Use the function to get data.'

3

Using a model that does not support function calling or an outdated SDK version.

✓ Fix

Use a supported model like gpt-4o or gpt-4o-mini and update the OpenAI SDK to the latest version.

Code: broken vs fixed

Broken - triggers the error
python
from openai import OpenAI
import os

client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])

response = client.chat.completions.create(
    model='gpt-4o-mini',
    messages=[{'role': 'user', 'content': 'Get me the weather.'}]
)

# This will raise error because no functions parameter is provided, so no function call output is submitted
print(response.choices[0].message.function_call)
Fixed - works correctly
python
from openai import OpenAI
import os

client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])

functions = [
    {
        "name": "get_weather",
        "description": "Get the current weather for a location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "City and state, e.g. San Francisco, CA"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
        }
    }
]

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Get me the weather."}],
    functions=functions
)

print(response.choices[0].message.function_call)  # Now outputs the function call data
Added the 'functions' parameter with a valid function schema to enable the assistant to submit function call output.

Workaround

Catch the OpenAIError and fallback to parsing the assistant's message content manually or retry the request with the functions parameter included.

Prevention

Always include the 'functions' parameter with correct function definitions and use models that support function calling to guarantee function call outputs.

Python 3.9+ · openai >=1.0.0 · tested on 1.5.0
Verified 2026-04 · gpt-4o-mini, gpt-4o
Verify ↗

Community Notes

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