when there is no “tool_choice":“required” in my http request, things be okay
but after I added it, it’s response’s content changed from
"message": {
"role": "assistant",
"content": "The weather in Boston is sunny with a temperature of 24°C.",
"refusal": null,
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": [],
"reasoning_content": null
}
to
"message": {
"role": "assistant",
"content": "",
"refusal": null,
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": [
{
"id": "chatcmpl-tool-327da18a717e4da98f2923a108de1d71",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"Boston\"}"
}
}
],
"reasoning_content": null
}
theirs request is almost the same:
POST /v1/chat/completions HTTP/1.1
Host: 192.168.10.166:8000
Accept-Encoding: gzip, deflate, zstd
Connection: keep-alive
Accept: application/json
Content-Type: application/json
User-Agent: OpenAI/Python 2.6.1
X-Stainless-Lang: python
X-Stainless-Package-Version: 2.6.1
X-Stainless-OS: Windows
X-Stainless-Arch: other:amd64
X-Stainless-Runtime: CPython
X-Stainless-Runtime-Version: 3.10.11
Authorization: Bearer vllm-key
X-Stainless-Async: false
X-Stainless-Raw-Response: true
x-stainless-retry-count: 0
Content-Length: 702
{
"messages": [
{
"content": "What's the weather in Boston?",
"role": "user"
},
{
"content": null,
"role": "assistant",
"tool_calls": [
{
"type": "function",
"id": "chatcmpl-tool-933cb0158e8144f8b2f36036b315bc19",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"Boston\"}"
}
}
]
},
{
"content": "sunny, 24°C",
"role": "tool",
"tool_call_id": "chatcmpl-tool-933cb0158e8144f8b2f36036b315bc19"
}
],
"model": "qwen3-32b-bnb-4bit",
"max_completion_tokens": 100,
"stream": false,
"temperature": 0.3,
"tool_choice": "required", # this line does not exist when "tool_choice" is not specified
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather at a location.",
"parameters": {
"properties": {
"location": {
"type": "string"
}
},
"required": [
"location"
],
"type": "object"
}
}
}
]
}