Skip to content

add tool use example#1221

Open
ozge-devops wants to merge 1 commit intoanthropics:mainfrom
ozge-devops:main
Open

add tool use example#1221
ozge-devops wants to merge 1 commit intoanthropics:mainfrom
ozge-devops:main

Conversation

@ozge-devops
Copy link

Description

Add a tool use (function calling) example to the examples/ directory.

This example demonstrates the complete tool use workflow:

  • Defining tools with JSON Schema input descriptions
  • Sending a message that triggers tool use
  • Processing tool calls in a loop (handling multiple tool calls)
  • Returning tool results back to Claude
  • Getting Claude's final response incorporating the tool results

The example uses a simulated weather API to keep it simple and runnable without external dependencies.

Motivation

The SDK supports tool use but the examples/ directory doesn't have a dedicated example for it. This makes it harder for new users to get started with function calling. The README references tool use support but links to external docs rather than a working example.

Testing

Tested locally with ANTHROPIC_API_KEY set — Claude correctly

## Description

Add a tool use (function calling) example to the `examples/` directory.

This example demonstrates the complete tool use workflow:
- Defining tools with JSON Schema input descriptions
- Sending a message that triggers tool use
- Processing tool calls in a loop (handling multiple tool calls)
- Returning tool results back to Claude
- Getting Claude's final response incorporating the tool results

The example uses a simulated weather API to keep it simple and runnable without external dependencies.

## Motivation

The SDK supports tool use but the `examples/` directory doesn't have a dedicated example for it. This makes it harder for new users to get started with function calling. The README references tool use support but links to external docs rather than a working example.

## Testing

Tested locally with `ANTHROPIC_API_KEY` set — Claude correctly
@ozge-devops ozge-devops requested a review from a team as a code owner March 5, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant