Skip to content

🛠️ Tools Overview

Tools are used to allow models to call external capabilities when generating answers. Typical scenarios include:

  • Web Search: Get the latest information and provide cited sources in the answer.
  • Function Calling: Let the model call your own business API / database / internal services.

This platform adopts the same parameter design as the OpenAI interface for tool calls. There are two common access methods:

  • OpenAI Responses: Suitable for using built-in tools (e.g., Web Search).
  • OpenAI Chat Completions: Suitable for using custom function tools.

Use tools to enable the built-in web search tool web_search_preview, and the model will automatically initiate a search when needed to complete the answer.

curl https://api-cs-al.naci-tech.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "tool_choice": "auto",
    "tools": [
      { "type": "web_search_preview", "search_context_size": "medium" }
    ],
    "input": "Search and summarize: What are the key changes in the latest TypeScript version in 2026?"
  }'

✅ Quick Example: Custom Function (Chat Completions)

When you want the model to call your backend function (such as querying an order, checking weather, or retrieving inventory), use tools: [{type:"function", ...}] to define the function schema.

curl https://api-cs-al.naci-tech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      { "role": "user", "content": "Help me check the status of order 20240227001" }
    ],
    "tool_choice": "auto",
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_order_status",
          "description": "Query order status",
          "parameters": {
            "type": "object",
            "properties": {
              "order_id": { "type": "string", "description": "Order ID" }
            },
            "required": ["order_id"]
          }
        }
      }
    ]
  }'

If the model decides to call a function, it will provide tool_calls (containing the function name and JSON parameters) in the result. You need to execute the function on your business side, and send the result back to the model as a "tool message", allowing the model to complete the final natural language answer.

📚 View by Model