I’m having an issue where the tools calling only works in the platform but not in the Python SDK. Given the same prompt and input, in the SDK i’m getting a response from the bot and in the platform I’m getting the correct output for function calling.
Below is my code and function definition and the message that I used to test both on Playground and SKD is “How’s my nutrition and sleep?”
EDIT: I’m using the same parameters for both SDK and Playground (model, temperature, tools=auto)
COACHING_TOOLS = [
{
"type": "function",
"name": "get_nutrition_data_by_user_and_date_range",
"description": "Retrieves nutrition data for a user within a specified date range.",
"strict": True,
"parameters": {
"type": "object",
"properties": {
"start_timestamp": {
"type": "string",
"format": "date-time",
"description": "The start timestamp for the date range (ISO 8601 format). If no date specified in user message leave this field empty to retrieve data for the last 7 days."
},
"end_timestamp": {
"type": "string",
"format": "date-time",
"description": "The end timestamp for the date range (ISO 8601 format). If no date specified in user message leave this field empty to retrieve data for the last 7 days."
}
},
"required": [
"start_timestamp",
"end_timestamp"
],
"additionalProperties": False
}
},
{
"type": "function",
"name": "get_sleep_data_by_user_and_date_range",
"description": "Retrieves sleep and recovery data for a user within a specified date range.",
"strict": True,
"parameters": {
"type": "object",
"properties": {
"start_timestamp": {
"type": "string",
"format": "date-time",
"description": "The start timestamp for the date range (ISO 8601 format). If no date specified in user message leave this field empty to retrieve data for the last 7 days."
},
"end_timestamp": {
"type": "string",
"format": "date-time",
"description": "The end timestamp for the date range (ISO 8601 format). If no date specified in user message leave this field empty to retrieve data for the last 7 days."
}
},
"required": [
"start_timestamp",
"end_timestamp"
],
"additionalProperties": False
}
}
]
response = client.responses.create(
model="gpt-4.1",
temperature=0.5,
tool_choice="auto",
input=conversation_messages,
tools=COACHING_TOOLS,
)
Output from platform:
Output from SDK:
[ResponseOutputMessage(id=‘msg_6861490192a481a2898aedde3206623d06adad9ab2ad6c28’, content=[ResponseOutputText(annotations=, t…in mind. How can I assist you today?', type=‘output_text’, logprobs=)], role=‘assistant’, status=‘completed’, type=‘message’)]