It’s really ODD, maybe I am in a bad habit that I love reading documentation, API reference, I just couldn’t find a place to get function name of a function call so I can perform the function call?
Which server events I am supposed to look into?
I searched the internet, there’re a couple examples, but it’s obvious that the event definition in the examples are different than on OPENAI websites. I even suspect those examples are bogus, and would never work.
Who has done REALTIME API function calling? and point me to the API reference that which server event has function name to call?
Congrats on your superpower of reading documentation, rare to find, and the basic secret to presenting expertise.
I can guide you to the documentation available…
The client can set default functions for the server in a
session.update
message, or set per-response functions in theresponse.create
message. The server will respond withfunction_call
items, if appropriate. The functions are passed in the format of the Chat Completions API.When the server calls a function, it may also respond with audio and text, for example “Ok, let me submit that order for you”. The function
description
field is useful for guiding the server on these cases, for example “do not confirm the order is completed yet” or “respond to the user before calling the tool”.The client must respond to the function call before by sending a
conversation.item.create
message withtype: "function_call_output"
. Adding a function call output does not automatically trigger another model response, so the client may wish to trigger one immediately usingresponse.create
.
For the actual name of the tool, you will look to the .item event, now over to the API reference - and will need to expand the collapsed tiers of the object in the documentation page. Which I will do for you here.
Conversation Item Created event
API Return Object: conversation.item.created
This object is returned when a conversation item is created. Below are the parameters:
Top-Level Parameters
-
event_id
- Type:
string
- Description: The unique ID of the server event.
- Type:
-
type
- Type:
string
- Description: The event type, must be
"conversation.item.created"
.
- Type:
-
previous_item_id
- Type:
string
- Description: The ID of the preceding item.
- Type:
-
item
- Type:
object
- Description: The item that was created.
- Type:
Item Object Parameters
-
id
- Type:
string
- Description: The unique ID of the item.
- Type:
-
object
- Type:
string
- Description: The object type, must be
"realtime.item"
.
- Type:
-
type
- Type:
string
- Description: The type of the item. It can be one of the following:
"message"
"function_call"
"function_call_output"
- Type:
-
status
- Type:
string
- Description: The status of the item. Possible values:
"completed"
"in_progress"
"incomplete"
- Type:
-
role
- Type:
string
- Description: The role associated with the item. Possible values:
"user"
"assistant"
"system"
- Type:
-
content
- Type:
array
- Description: The content of the item. It contains the following fields:
- Type:
Content Object Parameters
-
type
- Type:
string
- Description: The content type. Possible values:
"text"
"audio"
"input_text"
"input_audio"
- Type:
-
text
- Type:
string
- Description: The text content.
- Type:
-
audio
- Type:
string
- Description: Base64-encoded audio data.
- Type:
-
transcript
- Type:
string
- Description: The transcript of the audio.
- Type:
Function Call Parameters (for type: "function_call"
)
-
call_id
- Type:
string
- Description: The ID of the function call.
- Type:
-
name
- Type:
string
- Description: The name of the function being called.
- Type:
-
arguments
- Type:
string
- Description: The arguments of the function call.
- Type:
Function Call Output Parameters (for type: "function_call_output"
)
output
- Type:
string
- Description: The output of the function call.
- Type:
You still will likely need to inspect the content of events actually being returned by the API in order to build a parser in your event collector, a bit of trial and error in text mode, before finding out if you can actually talk to the AI and coax it to use any function by changing modalities.
Thank you so much for taking the time to answer my questions, Now I see where to get the name.
I never tried to look into this item, The reason I ask here is when I search the internet, they all point me to different event, and show me the screenshot, with a name I can’t see on my browser.
Anyway, Thank you so much.
You’ve got to click the little drop-down icon at every nest level to expand the API reference presentation of parameters within objects. Very tedious. You’re welcome!
Best thing to do is read the documentation, in detail.
If your query is solved, mark @_j 's answer the solution.