I’m connected to realtime API from React. When I say ‘get all orders’, realtime gives me an event to call a tool with a call ID, I “call” that tool to get some fake orders in React, then I send those fake orders back to realtime with the call ID. The problem is, realtime says there is no Tool call ID in the conversation.
This is what I’m trying to copy. https://github.com/openai/openai-realtime-console.
This is how I send the tool output back to realtime API.
function sendClientEvent(message:any) {
if (dataChannel) {
message.event_id = message.event_id || crypto.randomUUID()
dataChannel.send(JSON.stringify(message))
setEvents((prev):any => [message, ...prev])
} else {
console.error(
'Failed to send message - no data channel available',
message
)
}
}
sendClientEvent({
type: 'response.create',
response: {
input: [
{
type: 'function_call_output',
// object: 'realtime.item', // docs have this but it doesn't work
// status: 'completed', // docs have this but it doesn't work
call_id: output.call_id,
// name: 'get_all_orders_data', // docs have this but it doesn't work
// arguments: output.arguments, // docs have this but it doesn't work
output: JSON.stringify(fakeOrders),
},
],
},
})
The error I’m getting is
{
"type":"error",
"event_id":"event_AhmHYxjw4sT8zOJfGjiJ1",
"error":{
"type":"invalid_request_error",
"code":null,
"message":"Tool call ID 'call_rN75uHvEvPOp0C0f' not found in conversation.",
"param":null,
"event_id":null
}
}
Even though there is a tool call ID that was sent to me from realtime
{
"id": "item_AhmHX6bzvL0v44k42Ogfd",
"object": "realtime.item",
"type": "function_call",
"status": "completed",
"name": "get_all_orders_data",
"call_id": "call_rN75uHvEvPOp0C0f", <----call id
"arguments": "{}"
}