Error for message's assistant tool calls' id object

Hello everyone.
I’m trying to make a call through with function calling history.
I’m using openai==1.12.0 and python 3.11.4.

The body of the message is like this:

[{'role': 'system',
  'content': 'you are an assistant-like content'},
{'role': 'user',
  'content': 'Question'},
 {'role': 'assistant',
  'tool_calls': {'id': 'call_id',
   'function': {'arguments': '{"args":"args"}',
    'name': 'get_function'},
   'type': 'function'}},
 {'tool_call_id': 'call_id',
  'role': 'tool',
  'content': "content"}]

and chat completion call it’s like the following:

response =
    tool_choice = "auto",
    response_format={"type": "json_object"},

I obtain a Bad Request Error:
BadRequestError: Error code: 400 - {'error': {'message': "'id' is not of type 'object' - 'messages.2.tool_calls.0'", 'type': 'invalid_request_error', 'param': None, 'code': None}}

Anybody any idea? from the API documentation the body of the message and the objects should be correctly called.

I wrote out a much longer tutorial, showing the building of tools as schemas, progressing to the inclusion of tools in a request that gets tool_call emitted to you, then through including the two messages that must be returned in order to continue.

1 Like