import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
get_order = {
"name": "get_order",
"description": "Look up an order by ID and return its status and items.",
"strict": True,
"input_schema": {"type": "object", "additionalProperties": False,
"properties": {"order_id": {"type": "string"}}, "required": ["order_id"]},
}
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=4096,
cache_control={"type": "ephemeral"}, # automatic prompt caching
output_config={"effort": "medium"},
system="You are Acme's support agent. Check orders with tools before answering.",
tools=[get_order],
messages=[{"role": "user", "content": "Where is order A-1042?"}],
)
for block in response.content:
if block.type == "tool_use": # stop_reason is "tool_use"
print(block.name, block.input)