Tool / Function Calling
- Endpoint:
POST https://api.olddog.shop/v1/chat/completions - Purpose: Let the model “call tools” in a structured format. Your application executes the tool and sends the result back to the model.
Note: This page follows the OpenAI tool-calling convention. Support may vary by model; please refer to the models available in the console.
Request parameters (additional)
| Name | Type | Required | Description |
|---|---|---|---|
| tools | array | No | Tool list. Each tool is typically {"type":"function","function":{...}}. |
| tool_choice | string / object | No | Tool selection strategy: "auto" / "none", or explicitly pick one tool. |
tools.function fields
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Function name (recommended: English + underscores). |
| description | string | No | What the function does. |
| parameters | object | Yes | JSON Schema for parameters (type, properties, required, etc.). |
cURL example (declare tools)
bash
curl --request POST "https://api.olddog.shop/v1/chat/completions" \
--header "Authorization: Bearer $OLD_DOG_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gpt-4o-mini",
"messages": [
{ "role": "user", "content": "北京今天的天气怎么样?如果不知道就调用查询工具。" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "查询指定城市的实时天气",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string", "description": "城市名称,如 北京" }
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}'Typical flow (recommended)
- First request: include
toolsand let the model returntool_calls - Your app runs the tool: call the real capability based on
tool_calls[].function.nameandarguments - Second request: send the tool result back as a
role: "tool"message and let the model produce the final answer
