Skip to Content

Interface AnthropicTool

One tool as the Anthropic Messages API takes it.

A definition only. Toolset.toAnthropic builds the array to pass as tools on a messages.create call, and every tool_use block that comes back goes to Toolset.call, whose text is the content of the tool_result block you send in reply.

const toolset = session.tools()
const tools: AnthropicTool[] = toolset.toAnthropic()
// tools -> anthropic.messages.create({ model, max_tokens, messages, tools })

// Each tool_use block carries a name and an input object:
async function used(name: string, input: Record<string, unknown>) {
const text = await toolset.call(name, input)
// text -> the content of a tool_result block, back to the model
}
interface AnthropicTool {
    name: string;
    description: string;
    input_schema: ToolParameters;
}
Index
name: string

The name a model calls.

description: string

What the operation is for.

input_schema: ToolParameters

The JSON Schema for its arguments.