When to Use Tools
Reach for tools when the model needs live data, actions, or exact computation.
Tools add power but also complexity, latency, and cost. Use them when the model genuinely needs to reach outside itself.
Good reasons to use a tool
- Live or private data — prices, inventory, a user's orders.
- Actions — create a ticket, send a message, book a slot.
- Exact computation — math, date arithmetic, unit conversion.
When not to
- The model already knows the answer from general knowledge.
- A plain retrieval (RAG) would be simpler.
Example
{
"use_a_tool": ["look up an order status", "calculate a mortgage payment", "create a calendar event"],
"no_tool_needed": ["explain what a mortgage is", "rewrite this email politely"]
}When to use it
- A booking assistant uses tools to query real-time seat availability rather than relying on the model's training data, which has no live inventory.
- A calculator tool is added to a maths tutoring app because LLMs can make arithmetic errors, while a Python eval call is always exact.
- A content-generation feature does not use tools for creative writing because the task requires no external data — the model's language capability is sufficient.
More examples
Tool for live data, not static facts
Contrasts a direct question (risky hallucination) with a tool call that fetches the real live value.
from openai import OpenAI
import json
client = OpenAI()
# Without tool: model guesses current stock price (risky)
r_no_tool = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role':'user','content':'What is the current AAPL stock price?'}]
)
print('No tool:', r_no_tool.choices[0].message.content[:80])
# With tool: fetch live price
def get_stock_price(ticker): return f'{ticker}: $189.34 (live)'
tool = {'type':'function','function':{'name':'get_stock_price','description':'Live stock price.','parameters':{'type':'object','properties':{'ticker':{'type':'string'}},'required':['ticker']}}}
r = client.chat.completions.create(model='gpt-4o-mini',messages=[{'role':'user','content':'Current AAPL price?'}],tools=[tool])
print('Tool call:', r.choices[0].message.tool_calls[0].function.arguments)Tool for exact computation
Routes arithmetic to a safe eval function so the answer is always exact, avoiding LLM arithmetic errors.
from openai import OpenAI
import json
client = OpenAI()
def calculate(expression: str) -> str:
try:
result = eval(expression, {'__builtins__': {}})
return str(result)
except Exception as e:
return f'Error: {e}'
tool = {'type':'function','function':{'name':'calculate','description':'Evaluate a maths expression.','parameters':{'type':'object','properties':{'expression':{'type':'string'}},'required':['expression']}}}
messages = [{'role':'user','content':'What is 1234 * 5678?'}]
r = client.chat.completions.create(model='gpt-4o-mini', messages=messages, tools=[tool])
tc = r.choices[0].message.tool_calls[0]
result = calculate(**json.loads(tc.function.arguments))
print('Exact result:', result)Skip tools for pure language tasks
Shows that tools are unnecessary for pure language tasks — omitting them keeps the call simpler and cheaper.
from openai import OpenAI
client = OpenAI()
# Creative writing needs no tools — language capability is sufficient
r = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role':'user','content':'Write a haiku about autumn leaves.'}]
# No tools= parameter — the model handles it purely with language
)
print(r.choices[0].message.content)
Discussion