{
"model": "gpt-4.1-mini",
"messages": [
{
"role": "user",
"content": "波士顿今天的天气怎么样?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "获取指定位置的当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市和州,例如 San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location"
]
}
}
}
],
"tool_choice": "auto"
}curl --location -g --request POST 'http://api.example.com/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4.1-mini",
"messages": [
{
"role": "user",
"content": "波士顿今天的天气怎么样?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "获取指定位置的当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市和州,例如 San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location"
]
}
}
}
],
"tool_choice": "auto"
}'{
"choices": [
{
"content_filter_result": {
"error": {
"code": "content_filter_error",
"message": "The contents are not filtered"
}
},
"content_filter_results": {},
"finish_reason": "tool_calls",
"index": 0,
"logprobs": null,
"message": {
"annotations": [],
"content": null,
"refusal": null,
"role": "assistant",
"tool_calls": [
{
"function": {
"arguments": "{\"location\":\"Boston, MA\",\"unit\":\"celsius\"}",
"name": "get_current_weather"
},
"id": "call_9Tu5ZwYvMpV1csPXLqTeM5UI",
"type": "function"
}
]
}
}
],
"created": 1764342878,
"id": "chatcmpl-CguT8XqGPVXTUe64KZgmjuF3oPms6",
"model": "gpt-4.1-mini-2025-04-14",
"object": "chat.completion",
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {}
}
],
"system_fingerprint": "fp_3dcd5944f5",
"usage": {
"completion_tokens": 23,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 75,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 98
}
}