Chat With Tool Calling
Header parameters
AuthorizationstringRequiredExample:
sk-lZxzBody
modelstringRequired
tool_choicestring · enumOptionalExample:
autoPossible values: streambooleanOptional
Responses
200Success
application/json
idstringRequired
modelstringRequired
objectstringRequired
createdintegerRequired
request_idstringRequired
post/v1/chat/completions
POST /v1/chat/completions HTTP/1.1
Host: llm.onerouter.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 526
{
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_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"
],
"description": "The unit for temperature"
}
},
"required": [
"location"
]
}
}
}
],
"tool_choice": "auto",
"stream": false
}200Success
{
"id": "chatcmpl-DL1tfXWqe8PTi4YHVFxFLW0SA5uou",
"model": "openai/gpt-5.4",
"object": "chat.completion",
"created": 1773904551,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_udj4IpfC2snQz0fA3z8jXjcZ",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"
}
}
]
},
"finish_reason": "tool_calls",
"logprobs": null
}
],
"request_id": "0d1d1c8188a246838bf6d0ce13123bf3",
"usage": {
"prompt_tokens": 166,
"completion_tokens": 25,
"total_tokens": 191,
"prompt_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0,
"audio_tokens": 0,
"video_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"image_tokens": 0,
"audio_tokens": 0
}
}
}Last updated