Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build LLM-powered apps with the Anthropic Claude API or SDK across Python, TypeScript, Java, Go, Ruby, C#, and PHP.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
ruby/claude-api/tool-use.md
1# Tool Use — Ruby23For conceptual overview (tool definitions, tool choice, tips), see [shared/tool-use-concepts.md](../../shared/tool-use-concepts.md).45## Tool Use67The Ruby SDK supports tool use via raw JSON schema definitions and also provides a beta tool runner for automatic tool execution.89### Tool Runner (Beta)1011```ruby12class GetWeatherInput < Anthropic::BaseModel13required :location, String, doc: "City and state, e.g. San Francisco, CA"14end1516class GetWeather < Anthropic::BaseTool17doc "Get the current weather for a location"1819input_schema GetWeatherInput2021def call(input)22"The weather in #{input.location} is sunny and 72°F."23end24end2526client.beta.messages.tool_runner(27model: :"claude-opus-4-8",28max_tokens: 16000,29tools: [GetWeather.new],30messages: [{ role: "user", content: "What's the weather in San Francisco?" }]31).each_message do |message|32puts message.content33end34```3536### Manual Loop3738See the [shared tool use concepts](../../shared/tool-use-concepts.md) for the tool definition format and agentic loop pattern.3940---4142