I’ve encountered an issue while using the GPT-4 API (model: gpt-4o-mini-2024-07-18) with a specified response_format and tool definitions. The model generates tool calls that do not adhere to the declared tool schema or specified parameters.
Sample Request Body:
{
"model": "gpt-4o-mini-2024-07-18",
"temperature": 0.3,
"messages": [
{
"role": "system",
"content": "save_answer tool should be called with param_1: '2', param_2: 'hello'"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "save_answer",
"parameters": {
"type": "object",
"properties": {
"param_1": {
"type": "string"
},
"param_2": {
"type": "string"
}
},
"required": [
"param_1",
"param_2"
]
}
}
}
],
"response_format": {
"json_schema": {
"name": "output_format",
"schema": {
"properties": {
"message": {
"title": "Response To User",
"type": "string"
}
},
"required": [
"message"
],
"additionalProperties": false,
"title": "schema_to_convert",
"type": "object"
},
"strict": true
},
"type": "json_schema"
}
}
API Response:
{
"id": "chatcmpl-AdCVU6d9OSDTFHtJBnxw28ozp3nU6",
"object": "chat.completion",
"created": 1733906232,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_Q7BGaeJxmZuvK4GRiPVZzetI",
"type": "function",
"function": {
"name": "FUNCTIONS",
"arguments": "{\"param_1\": \"two\", \"param_2\": \"hi\"}"
}
},
{
"id": "call_AO8FKTYX8LlJcJ8ppnfzmK7E",
"type": "function",
"function": {
"name": "FUNCTIONS",
"arguments": "{\"param_1\": \"two\", \"param_2\": \"hi\"}"
}
}
],
"refusal": null
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 96,
"completion_tokens": 58,
"total_tokens": 154,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"system_fingerprint": "fp_62208eb26c"
}
As seen in the example, func name is wrong and the params do not comply with the function definition. Sometimes the API returns timeout too.
This was functional up until a few hours ago. Anyone experiencing something similar?