Help me with function call for OpenAI realtime preview model #167399
Replies: 2 comments
-
Hi @IU1004 In the Realtime Preview model, function calling works via tool events (not function_call like older APIs). Define tools when creating/updating the session: { Check for tool calls in messages from the model: if (msg.type === "tool") { Send result back using another tool message: ws.send(JSON.stringify({ That’s it — watch for tool events, run the function, and return the result. |
Beta Was this translation helpful? Give feedback.
-
1.Define tools and tool_choice in your API call. Here's a basic implementation using the OpenAI Node.js SDK with a streaming response and tool handling:
Note : THIS IS AN LLM GENERATED CODE. MAKE CHANGES THAT SUIT YOUR NEEDS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
I'm implementing function call for OpenAI realtime preview model.
Please help me if you have experience with function calling in OpenAI realtime preview model.
After setting tools parameter in OpenAI model, then how can I know if there's function call in model's response.
I'm using realtime preview model for voice.
Please share node.js implementation if you have.
Thanks & Regards.
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions