This guide provides detailed instructions for using OpenAI's GPT-4o models with the Function Call feature, including parameter descriptions, request formatting, and example responses.
Supported Model List
GPT-4
GPT-4 Turbo
GPT-4o
GPT-4o mini
GPT-4o Realtime
GPT-4o mini Realtime
GPT-4o mini Search Preview
GPT-4o Search Preview
ChatGPT-4o
Top-Level Parameters
model
Meaning: Specifies the name of the model to be used.
Example Value:
"gpt-4.1"
.Explanation: Indicates that this request will use OpenAI's GPT-4.1 model.
messages
Meaning: Contains the dialogue information including user input and context.
Structure:
role
: The role of the message. Possible values include:"user"
: Represents the user's input."assistant"
: Represents the assistant's response."system"
: Represents system-level instructions.
content
: The content of the message, typically the user's input.
Example Value:
[
{
"role": "user",
"content": "What is the weather like in Boston today?"
}
]
tools
Meaning: Defines the tools or functions that can be invoked during the conversation.
Structure:
type
: The type of tool, currently set to"function"
.function
: Defines the specific function details:name
: The name of the function (e.g.,"get_current_weather"
).description
: A description of the function, explaining its purpose.parameters
: The definition of the function's parameters:type
: The type of parameters, usually"object"
.properties
: The specific attributes of the parameters and their descriptions.required
: The list of required parameters.
tool_choice
Meaning: Specifies the strategy for selecting the tool.
Example Value:
"auto"
.Explanation: Automatically selects the most appropriate tool for invocation.
Parameters in Tool Definition
location
Meaning: Specifies the location for which to query the weather.
Type:
string
.Description: Described as "city and state, e.g., San Francisco, CA".
Example Value:
"Boston, MA"
.
unit
Meaning: Specifies the unit of temperature.
Type:
string
.Optional Values:
"celsius"
: Celsius temperature."fahrenheit"
: Fahrenheit temperature.
Explanation: If a specific unit of temperature is needed, it can be specified through this parameter.
required
Meaning: Specifies which parameters are mandatory when calling the function.
Example Value:
["location"]
.Explanation: Indicates that
location
is a required parameter, whileunit
is optional.
Example Request
Here is an example of how to make a request using the Function Call feature:
curl https://ai.burncloud.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4.1",
"messages": [
{
"role": "user",
"content": "What is the weather like in Boston today?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}'
Example Response
Below is an example of the response to the above request:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699896916,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\n\"location\": \"Boston, MA\"\n}"
}
}
]
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 82,
"completion_tokens": 17,
"total_tokens": 99,
"completion_tokens_details": {
"reasoning_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
This guide provides a comprehensive overview of how to use OpenAI's GPT-4o models with Function Call capabilities. For further details, refer to the official OpenAI API documentation.