# Tool Use कैसे काम करता है — Claude API / OpenAI API की बुनियाद

Source: https://www.geekswithgeeks.com/hi/llm-apis/t-concept

> अनुरोध, tool call और परिणाम का loop देखें।

## मॉडल आपका कोड कभी नहीं चलाता

मॉडल अपने आप आपके orders नहीं देख सकता या ईमेल नहीं भेज सकता। **Tool use (function calling)** में आप अनुरोध में functions का वर्णन करते हैं (नाम, उद्देश्य और arguments का JSON Schema)। मॉडल तय करे कि tool मदद करेगा, तो उसका उत्तर अंतिम पाठ नहीं बल्कि **संरचित अनुरोध** होता है: "`get_order_status` को `order_id = 481516` के साथ बुलाओ", और stop reason यही बताता है (Anthropic के लिए `tool_use`, OpenAI के लिए `tool_calls`)। **आपका कोड** arguments validate करता है, function चलाता है, और अगले अनुरोध में पहले के messages के साथ **परिणाम** लौटाता है। फिर मॉडल आगे बढ़ता है, शायद और tools माँगते हुए, जब तक सामान्य उत्तर न लौटाए। Loop आपका है, इसलिए आप अनुमतियाँ, सीमाएँ और logging लागू कर सकते हैं।

## मॉडल माँगता है, आपका कोड करता है

आप tools का वर्णन करते हैं; मॉडल call माँगता है; आपका कोड उसे चलाकर परिणाम लौटाता है।

![चार चरण: परिभाषित, माँग, चलाना, लौटाना।](assets/figures/llm-apis/section-4-map.svg) — चित्र 4.1 — परिभाषित, माँग, चलाना और लौटाना।

## एक चित्र में tool loop

दो API calls और एक स्थानीय function call एक user सवाल का उत्तर देती हैं।

```text
user: "Where is order 481516?"
  -> API call 1 (with tool definitions)
  <- model: stop_reason = tool_use / tool_calls
         "call get_order_status(order_id='481516')"
  -> YOUR CODE validates args, runs get_order_status -> {"status": "shipped"}
  -> API call 2 (history + the tool result)
  <- model: "Your order 481516 has shipped."   (stop_reason = end_turn / stop)
```

## एक उत्तर में कई tools

एक ही मॉडल उत्तर कई tool calls माँग सकता है। अगले अनुरोध से पहले हर एक का परिणाम लौटाएँ।

**Quiz:** Tool call वास्तव में कौन चलाता है?

- [ ] Browser
- [ ] मॉडल
- [ ] Provider का GPU
- [x] आपका application कोड

*Answer:* आपका application कोड. मॉडल सिर्फ़ call माँगता है; चलाना है या नहीं और कैसे, यह आप तय करते हैं।
