Skip to main content

Claude LLM Tools

A library for auto-generating JSON Schema and dispatching tool calls in applications that use the Anthropic API to interact with Claude.

Installation

pip install claude-llm-tools

Usage

import anthropic
import claude_llm_tools


@claude_llm_tools.tool
def add_numbers(req: claude_llm_tools.Request, a: int, b: int) -> int:
    """
    Add two numbers together and return the result.

    Args:
        a: The first number
        b: The second number

    Returns:
        The sum of a and b
    """
    print(req.tool_use.id)
    return a + b


@claude_llm_tools.tool(
    name='multiply_numbers',
    description='Multiply two numbers together and return the product.'
)
def multiply(req: claude_llm_tools.Request, x: int, y: int) -> int:
    """This docstring will be overridden by the description parameter above."""
    print(req.tool_use.id)
    return x * y


client = anthropic.Anthropic()

# You can implement the Anthropic text editor contract
claude_llm_tools.add_tool(..., tool_type='text_editor_20250124')

message = client.messages.create(
    model="claude-3-7-sonnet-20250219",
    max_tokens=1000,
    temperature=1,
    system="You are a world-class poet. Respond only with short poems about math.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Why is the ocean salty?"
                }
            ]
        }
    ],
    tools=claude_llm_tools.tools()
)

for block in message.content:
    match block.type:
        case 'text':
            ...
        case 'tool_use':
            result = await claude_llm_tools.dispatch(block)

Release files for claude-llm-tools 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-llm-tools 0.3.0
File Size Uploaded
claude_llm_tools-0.3.0.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-llm-tools 0.3.0
File Interpreter ABI Platform
claude_llm_tools-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / claude_llm_tools-0.3.0.tar.gz

Download URL claude_llm_tools-0.3.0.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
60bfd6c20793103aa6b0dfb477b3105a541bad2dec63798bd8b3981537c29f07
BLAKE2b-256 checksum
How to use checksums
e49982ffd4546dc8d86080ee7b8f26371b2bfd4e351164fd6f5e6072a6adf66f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / claude_llm_tools-0.3.0-py3-none-any.whl

Download URL claude_llm_tools-0.3.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c2297002eff63c4ec28ab28c111d81c5a64f9a830502adbc729610c17191586
BLAKE2b-256 checksum
How to use checksums
0a937e0b47988dc54096733cc1780c806604ae3044ae37356bb090e63810e124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page