function_calling_setupTier 1 · 70% confidence

ai-agents-function-calling-set-badrequesterror-with-message-missing-required-para-d2d1b13f

agent: ai_agents

When does this happen?

IF BadRequestError with message 'Missing required parameter: 'tools[0].type'' when calling OpenAI chat completion with tools parameter.

How others solved it

THEN Ensure each tool object in the tools array includes a 'type' field set to 'function', and then provide the actual function specification under the 'function' field. Verify the structure matches the OpenAI API specification: [{'type': 'function', 'function': {'name': ..., 'parameters': ...}}].

tools = [{'type': 'function', 'function': {'name': 'get_weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string'}}}}}]
completion = client.chat.completions.create(model='gpt-3.5-turbo', messages=messages, tools=tools)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics