Skip to content

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)

NameTypeRequiredDescription
toolsarrayNoTool list. Each tool is typically {"type":"function","function":{...}}.
tool_choicestring / objectNoTool selection strategy: "auto" / "none", or explicitly pick one tool.

tools.function fields

FieldTypeRequiredDescription
namestringYesFunction name (recommended: English + underscores).
descriptionstringNoWhat the function does.
parametersobjectYesJSON 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"
  }'
  • First request: include tools and let the model return tool_calls
  • Your app runs the tool: call the real capability based on tool_calls[].function.name and arguments
  • Second request: send the tool result back as a role: "tool" message and let the model produce the final answer