> ## Documentation Index
> Fetch the complete documentation index at: https://docs.partfinder.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The PartFinder API is served at https://api.partfinder.dev. Authenticate with `Authorization: Bearer $PARTFINDER_API_KEY`; create an account at https://console.partfinder.dev/sign-up and pick pay as you go or a monthly or yearly plan (see https://partfinder.dev/pricing), then create a key. Pay as you go starts with 100 free credits, once per person and per company.
> Install the PartFinder agent skill with `npx skills add https://docs.partfinder.dev` (skill file: https://docs.partfinder.dev/skill.md).
> The OpenAPI document at https://api.partfinder.dev/v1/openapi.json is the source of truth for request and response schemas.
> What each call costs and current plans: https://api.partfinder.dev/llms.txt.

# Use PartFinder with Anthropic tool calling

> Give Claude the PartFinder API as tools built from the OpenAPI document, run by the Anthropic SDK's tool runner.

This page gives Claude the PartFinder API as tools. The Anthropic SDK's tool runner (Python or TypeScript) calls `call_tool` / `callTool` for each tool call and sends the result back until Claude answers.

## Install

```bash theme={null}
pip install anthropic requests   # Python
npm install @anthropic-ai/sdk       # JavaScript
export ANTHROPIC_API_KEY="..."
export PARTFINDER_API_KEY="ak_..."
```

Save [`partfinder_tools.py` or `partfinder-tools.mjs`](https://docs.partfinder.dev/ai-agent-integration#build-the-tools-from-the-openapi-document)
next to your code. It builds the tools from the [OpenAPI document](https://api.partfinder.dev/v1/openapi.json)
and makes each call with the key from `PARTFINDER_API_KEY`.

## Give the model the tools

```python Python theme={null}
from anthropic import Anthropic, beta_tool

from partfinder_tools import call_tool, operations

client = Anthropic()


def partfinder_tool(op):
    return beta_tool(
        lambda **args: call_tool(op["name"], args),
        name=op["name"],
        description=op["description"],
        input_schema=op["parameters"],
    )


runner = client.beta.messages.tool_runner(
    model="claude-opus-5-5",
    max_tokens=1024,
    tools=[partfinder_tool(op) for op in operations],
    messages=[{"role": "user", "content": "Is my PartFinder API key working?"}],
)
final_message = runner.until_done()

for block in final_message.content:
    if block.type == "text":
        print(block.text)
```

```javascript JavaScript theme={null}
import Anthropic from "@anthropic-ai/sdk";
import { betaTool } from "@anthropic-ai/sdk/helpers/beta/json-schema";
import { operations, callTool } from "./partfinder-tools.mjs";

const client = new Anthropic();

const tools = operations.map((op) =>
  betaTool({
    name: op.name,
    description: op.description,
    inputSchema: op.parameters,
    run: (input) => callTool(op.name, input),
  }),
);

const finalMessage = await client.beta.messages.toolRunner({
  model: "claude-opus-5-5",
  max_tokens: 1024,
  tools,
  messages: [{ role: "user", content: "Is my PartFinder API key working?" }],
});

for (const block of finalMessage.content) {
  if (block.type === "text") console.log(block.text);
}
```

`beta_tool` (Python) and `betaTool` (JavaScript) take each operation's JSON Schema as `input_schema` / `inputSchema`. The tool runner is in beta in the Anthropic SDK. Save it as `agent.py` or `agent.mjs` next to the tools file.

## Jobs and refusals

`searchParts`, `compareParts` and `analyzeBom` start a job. `call_tool` (`callTool`) waits for the job and returns the
finished result, so the model does not need to poll. A refused call returns the API's JSON with its `error` code and
`summary`, and the model reads it like any other result. See [AI agent integration](https://docs.partfinder.dev/ai-agent-integration.md)
for the rest of the rules.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.