LLMs can select and call external tools — search, calculate, fetch data, run code.
# Claude tool use
import anthropic
tools = [
{
'name': 'get_weather',
'description': 'Get current weather for a city',
'input_schema': {
'type': 'object',
'properties': {
'city': {'type':'string','description':'City name'}
},
'required': ['city']
}
},
{
'name': 'search_docs',
'description': 'Search internal documentation',
'input_schema': {
'type': 'object',
'properties': {
'query': {'type':'string'}
},
'required': ['query']
}
}
]
client = anthropic.Anthropic()
response = client.messages.create(
model='claude-opus-4-5', max_tokens=1024,
tools=tools,
messages=[{'role':'user','content':'Weather in London?'}]
)
for block in response.content:
if block.type == 'tool_use':
print('Tool:', block.name, 'Input:', block.input)
# Execute tool, feed result back to model