Chat - Function Calling
Enable the model to call external functions by providing atools array. The model will generate structured JSON input for the function instead of a text response.
For more details, see the OpenAI Function Calling Guide.
Request
Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | application/json |
Authorization | Yes | Bearer sk-xxx |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name (e.g. gpt-5.5) |
messages | array | Yes | Array of message objects |
tools | array | Yes | Array of tool/function definitions |
tools[].type | string | Yes | Always function |
tools[].function.name | string | Yes | Function name (a-z, A-Z, 0-9, underscores, dashes, max 64) |
tools[].function.description | string | No | Function description |
tools[].function.parameters | object | Yes | JSON Schema object defining parameters |
tools[].function.parameters.type | string | Yes | Usually object |
tools[].function.parameters.properties | object | Yes | Parameter definitions |
tools[].function.parameters.required | array | No | Required parameter names |
tools[].function.strict | boolean | No | Enable strict schema adherence |
Example Request
curl https://kiosapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxx" \
-d '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "What is the weather like in Paris today?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Paris, France"
}
},
"required": ["location"],
"additionalProperties": false
},
"strict": true
}
}
]
}'
Python Example
import openai
import json
openai.api_key = "sk-xxx"
openai.base_url = "https://kiosapi.com/v1/"
response = openai.chat.completions.create(
model="gpt-5.5",
messages=[
{"role": "user", "content": "What is the weather like in Paris today?"}
],
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Paris, France"
}
},
"required": ["location"],
"additionalProperties": False
},
"strict": True
}
}
]
)
# The model returns a function call
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(args) # {"location": "Paris, France"}
Response
When the model decides to call a function, the response will containtool_calls instead of a text content:
{
"id": "chatcmpl-Ax2bU1RFE8P0Y9uqKcErQNLcx4dDe",
"object": "chat.completion",
"created": 1738634724,
"model": "gpt-5.5-2024-08-06",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_FezxjoWuDV1CL3dITVFOjUzK",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Paris, France\"}"
}
}
],
"refusal": null
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 65,
"completion_tokens": 16,
"total_tokens": 81
},
"system_fingerprint": "fp_f3927aa00d"
}
The
finish_reason will be tool_calls when the model wants to call a function. Execute the function yourself, then send the result back in a new message with role: "tool".