Skip to main content
Function tools let the model ask your app for data or actions during a conversation. Your app runs the function and returns the result. The model then speaks the answer.

Define tools

Add tools to session. Each tool uses the OpenAI GA shape.

Handle a call

The loop has four steps:
1

Collect the arguments

The model streams arguments as response.function_call_arguments.delta. Wait for response.function_call_arguments.done, which has the full JSON string and call_id.
2

Run your function

Parse arguments and run your code. Keep this on your server or in a trusted backend.
3

Return the output

Send the result as a function_call_output item that uses the same call_id:
4

Ask for the reply

Send response.create. The model speaks the answer using the output.

Example event flow

Notes

  • output must be a string. Return JSON as a string.
  • Return an error message in output when your function fails, so the model can apologize.
  • Keep tool results short. Long results make the reply slower.
MCP tools inside a Realtime session are not supported yet. Define function tools that call your own backend.