tool use
Allows Claude to call developer-defined functions. Claude decides when to invoke tools and with what arguments based on the user's request.
Syntax
claude-api
{ tools: [{ name, description, input_schema }], messages }Example
claude-api
const response = await client.messages.create({
model: "claude-opus-4-5",
max_tokens: 1024,
tools: [{
name: "get_weather",
description: "Get weather for a city",
input_schema: { type: "object", properties: { city: { type: "string" } }, required: ["city"] }
}],
messages: [{ role: "user", content: "What is the weather in Paris?" }]
});