Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3887fb5
feat(ai): add ProviderTool phantom-branded subtype
AlemTuzlak Apr 17, 2026
de743dc
feat(ai): add toolCapabilities to TextAdapter type channel
AlemTuzlak Apr 17, 2026
561aa9f
feat(ai): gate TextActivityOptions.tools on model toolCapabilities
AlemTuzlak Apr 17, 2026
bec006f
fix(ai): prevent ProviderTool subsumption in TextActivityOptions.tool…
AlemTuzlak Apr 17, 2026
49b39da
test(ai): type tests for TextActivityOptions.tools gating
AlemTuzlak Apr 17, 2026
cf8ff8e
test(ai): fix import order and cover broad-TKind ProviderTool rejection
AlemTuzlak Apr 17, 2026
6f86c1c
feat(ai-anthropic): add supports.tools and ToolCapabilitiesByName map
AlemTuzlak Apr 17, 2026
e7b0565
refactor(ai-anthropic): use Array for supports.tools to match support…
AlemTuzlak Apr 17, 2026
5e679b0
feat(ai-anthropic): brand provider tool factory return types
AlemTuzlak Apr 17, 2026
401a542
refactor(ai-anthropic): replace tools barrel with named re-exports
AlemTuzlak Apr 17, 2026
801255b
fix(ai-anthropic): build AnthropicTool union from branded types
AlemTuzlak Apr 17, 2026
b996e07
Revert "fix(ai-anthropic): build AnthropicTool union from branded types"
AlemTuzlak Apr 17, 2026
29dc52f
feat(ai-anthropic): thread toolCapabilities through text adapter
AlemTuzlak Apr 17, 2026
2bc673a
feat(ai-anthropic): export AnthropicChatModelToolCapabilitiesByName
AlemTuzlak Apr 17, 2026
628f20f
feat(ai-anthropic): add /tools subpath export
AlemTuzlak Apr 17, 2026
86a2df5
test(ai-anthropic): per-model type tests for provider tools
AlemTuzlak Apr 17, 2026
e3cba77
test(ai-anthropic): cover all unsupported tools in haiku-3-5 negative…
AlemTuzlak Apr 17, 2026
0e4ad1c
feat(ai-openai): add ToolCapabilitiesByName and expanded supports.tools
AlemTuzlak Apr 17, 2026
32a18ce
feat(ai-openai): brand provider tool factories and replace barrel export
AlemTuzlak Apr 17, 2026
1fd3c38
feat(ai-openai): add /tools subpath export
AlemTuzlak Apr 17, 2026
7d82f69
test(ai-openai): per-model type tests for provider tools
AlemTuzlak Apr 17, 2026
65ce658
feat(ai-gemini): split capabilities into capabilities + tools
AlemTuzlak Apr 17, 2026
868b71f
feat(ai-gemini): brand provider tool factories and replace barrel export
AlemTuzlak Apr 17, 2026
269d281
feat(ai-gemini): add /tools subpath export and type tests
AlemTuzlak Apr 17, 2026
31aa38f
feat(ai-openrouter)!: move and rename createWebSearchTool to webSearc…
AlemTuzlak Apr 17, 2026
cff729e
feat(ai-grok, ai-groq): add supports.tools, /tools subpath, and threa…
AlemTuzlak Apr 17, 2026
782554d
chore(scripts): update sync-models templates to include supports.tools
AlemTuzlak Apr 17, 2026
cdcfe6d
test(ai-anthropic): runtime smoke test for provider tool factories
AlemTuzlak Apr 17, 2026
95a1ba9
docs: add provider tools concept page
AlemTuzlak Apr 17, 2026
2fe3d04
docs(adapters): add Provider Tools sections for every adapter
AlemTuzlak Apr 17, 2026
24b3b49
docs: cross-link provider tools concept page and migration section 6
AlemTuzlak Apr 17, 2026
cd4d7fb
chore: changesets for provider-tools surface
AlemTuzlak Apr 17, 2026
66aece4
fix(ai-groq): reorder imports to satisfy import/first ESLint rule
AlemTuzlak Apr 17, 2026
c78f146
fix(changesets): bump adapters to minor for new /tools subpath + open…
AlemTuzlak Apr 17, 2026
ec01981
fix(ai-openrouter): match @deprecated tag wording across adapters
AlemTuzlak Apr 17, 2026
b700eb1
fix(changesets): confirm gemini relocation claim is accurate for all …
AlemTuzlak Apr 17, 2026
6861e55
fix(ai-gemini): export convertToolsToProviderFormat from /tools
AlemTuzlak Apr 17, 2026
29ba0a8
test(ai-openai): cover all 10 unsupported tools in gpt-3.5-turbo
AlemTuzlak Apr 17, 2026
a02e67d
test(ai-gemini): add negative cases for gemini-3.1-pro-preview
AlemTuzlak Apr 17, 2026
8be4835
fix(ai-anthropic): debrand customTool — return plain Tool (universal)
AlemTuzlak Apr 17, 2026
1f4cc44
fix(ai-openai): debrand customTool/functionTool — remove unused brand…
AlemTuzlak Apr 17, 2026
6970466
docs: remove customTool from branded-factories matrix
AlemTuzlak Apr 17, 2026
1e25129
test(ai-anthropic): cover debranded customTool acceptance on any model
AlemTuzlak Apr 17, 2026
0c1bd22
ci: apply automated fixes
autofix-ci[bot] Apr 17, 2026
6e9919c
Merge remote-tracking branch 'origin/main' into worktree-cheeky-mappi…
AlemTuzlak Apr 20, 2026
416d8b0
review: address CodeRabbit PR feedback
AlemTuzlak Apr 20, 2026
aa33f67
review: address CodeRabbit feedback (round 2)
AlemTuzlak Apr 21, 2026
c2d4beb
review: rename generic `A` to `TAdapter` in typedTools helpers
AlemTuzlak Apr 21, 2026
3d6da70
fix(ai-openrouter): type metadata.web_search as unknown for runtime n…
AlemTuzlak Apr 21, 2026
a69b70c
chore: remove accidentally-committed terminalOutput artifact
AlemTuzlak Apr 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/provider-tools-ai-anthropic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-anthropic': minor
---

Expose provider-tool factories (`webSearchTool`, `codeExecutionTool`, `computerUseTool`, `bashTool`, `textEditorTool`, `webFetchTool`, `memoryTool`, `customTool`) on a new `/tools` subpath. Each factory now returns a branded type (e.g. `AnthropicWebSearchTool`) that is gated against the selected model's `supports.tools` list. Existing factory signatures and runtime behavior are unchanged; old config-type aliases (`WebSearchTool`, `BashTool`, etc.) remain as `@deprecated` aliases pointing at the renamed `*ToolConfig` types.
5 changes: 5 additions & 0 deletions .changeset/provider-tools-ai-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai': minor
---

Add `ProviderTool<TProvider, TKind>` phantom-branded tool subtype and a `toolCapabilities` channel on `TextAdapter['~types']`. `TextActivityOptions['tools']` is now typed so that adapter-exported provider tools are gated against the selected model's `supports.tools` list. User tools from `toolDefinition()` remain unaffected.
7 changes: 7 additions & 0 deletions .changeset/provider-tools-ai-gemini.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/ai-gemini': minor
---

Expose provider-tool factories (`codeExecutionTool`, `fileSearchTool`, `googleSearchTool`, `googleSearchRetrievalTool`, `googleMapsTool`, `urlContextTool`, `computerUseTool`) on a new `/tools` subpath, each returning a branded type gated against the selected model's `supports.tools` list.

Note: `supports.capabilities` entries that described tools (`code_execution`, `file_search`, `grounding_with_gmaps` → renamed `google_maps`, `search_grounding` → renamed `google_search`, `url_context`) have been relocated to the new `supports.tools` field. The `capabilities` array loses those entries. This is a model-meta shape change but not a runtime break.
Comment on lines +1 to +7
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider flagging the supports.capabilities reshape as breaking for consumers reading model metadata.

Renaming/relocating entries (grounding_with_gmapsgoogle_maps, search_groundinggoogle_search, and removal of code_execution/file_search/url_context from capabilities) is a visible shape change to exported model metadata. Downstream code that inspects model.supports.capabilities at runtime/type-level will break, even if no adapter runtime path changes. A minor bump may be appropriate only if these maps are considered internal; otherwise this warrants a major or at least a prominent note in the migration guide.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/provider-tools-ai-gemini.md around lines 1 - 7, This changeset
reshapes exported model metadata by moving entries from supports.capabilities
into supports.tools and renaming grounding_with_gmaps→google_maps and
search_grounding→google_search while removing code_execution, file_search, and
url_context from capabilities; update the changeset to reflect a breaking change
by changing the release type from minor to major (or add a prominent “BREAKING
CHANGE” header and migration note) so consumers inspecting
model.supports.capabilities at runtime/types know to migrate to supports.tools
and the new names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this at minor. Same reasoning as the openrouter changeset reply: pre-1.0 convention in this repo is to bump breaking changes as minor. The changeset body already explicitly calls out the capabilities reshape (renames + relocations) so consumers reading model metadata have a clear migration note.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlemTuzlak, understood — that's a reasonable pre-1.0 convention. I'll note it going forward and won't flag minor bumps for breaking changes in this repo.


✏️ Learnings added
Learnt from: AlemTuzlak
Repo: TanStack/ai PR: 466
File: .changeset/provider-tools-ai-gemini.md:1-7
Timestamp: 2026-04-21T11:28:25.192Z
Learning: In the TanStack/ai repository (pre-1.0), the project convention is to release breaking changes as `minor` version bumps rather than `major`. Changesets documenting breaking/shape changes (e.g. model-meta reshapes, renamed exports) use `minor`, not `major`. Do not flag `minor` changesets as potentially needing a `major` bump in this repo.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: AlemTuzlak
Repo: TanStack/ai PR: 433
File: packages/typescript/ai-openrouter/src/model-meta.ts:0-0
Timestamp: 2026-04-09T08:49:17.178Z
Learning: Repo TanStack/ai (packages/typescript/ai-openrouter): Lyria and other non‑chat families are excluded from OPENROUTER_CHAT_MODELS via two safeguards — convert-openrouter-models.ts (nonChatFamilies ['lyria','veo','imagen','sora','dall-e','tts']) and sync-provider-models.ts (NON_CHAT_MODEL_PREFIXES with the same set). OpenRouterTextModels derives from OPENROUTER_CHAT_MODELS, keeping OpenRouterTextAdapter text-only.

Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-10T17:53:42.706Z
Learning: Applies to packages/*/src/adapters/*.ts : Create separate tree-shakeable adapters for each provider capability (text, embedding, summarize, image) rather than monolithic exports

Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-10T17:53:42.706Z
Learning: Applies to packages/typescript/ai-*/package.json : Export tree-shakeable adapters from /adapters subpath exports in provider adapter packages

Learnt from: tombeckenham
Repo: TanStack/ai PR: 237
File: packages/typescript/ai-fal/src/adapters/image.ts:39-44
Timestamp: 2026-02-04T01:39:19.784Z
Learning: In the TanStack/ai-fal package, when creating adapter type mappings for 600+ fal.ai models, use mapped types over the known EndpointTypeMap keys with a Record fallback for unknown models: `{ [K in keyof EndpointTypeMap]: ProviderOptions<K> } & Record<string, any>` instead of `Record<FalModel, ProviderOptions<TModel>>` to preserve per-model type safety.

Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-10T17:53:42.706Z
Learning: Applies to packages/typescript/ai-*/src/model-meta.ts : Provide type safety per model by using model-specific provider options in adapter packages

Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-10T17:53:42.706Z
Learning: Applies to packages/typescript/ai-*/src/adapters/**/*.ts : Use adapter pattern system for tree-shakeable provider implementations to minimize bundle size

5 changes: 5 additions & 0 deletions .changeset/provider-tools-ai-grok.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-grok': patch
---

Expose the `/tools` subpath and add an empty `supports.tools: []` channel per model so Grok adapters participate in the core tool-capability type gating. No provider-specific tool factories are exposed yet — define your own tools with `toolDefinition()` from `@tanstack/ai`.
5 changes: 5 additions & 0 deletions .changeset/provider-tools-ai-groq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-groq': patch
---

Expose the `/tools` subpath and add an empty `supports.tools: []` channel per model so Groq adapters participate in the core tool-capability type gating. No provider-specific tool factories are exposed yet — define your own tools with `toolDefinition()` from `@tanstack/ai`.
5 changes: 5 additions & 0 deletions .changeset/provider-tools-ai-openai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-openai': minor
---

Expose provider-tool factories (`webSearchTool`, `webSearchPreviewTool`, `fileSearchTool`, `imageGenerationTool`, `codeInterpreterTool`, `mcpTool`, `computerUseTool`, `localShellTool`, `shellTool`, `applyPatchTool`, `customTool`) on a new `/tools` subpath. Each factory returns a branded type (e.g. `OpenAIWebSearchTool`) gated against the selected model's `supports.tools` list. `supports.tools` was expanded to include `web_search_preview`, `local_shell`, `shell`, `apply_patch`. Existing factory signatures and runtime behavior are unchanged.
7 changes: 7 additions & 0 deletions .changeset/provider-tools-ai-openrouter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/ai-openrouter': minor
---

**Breaking export change.** `createWebSearchTool` has been removed from the package root. Import `webSearchTool` from `@tanstack/ai-openrouter/tools` instead. See Migration Guide §6 for the before/after snippet.

Alongside: the new `/tools` subpath exposes `webSearchTool` (branded `OpenRouterWebSearchTool`) and the existing `convertToolsToProviderFormat`. A new `supports.tools` channel on each chat model gates provider tools at the type level.
Comment on lines +1 to +7
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check current version and any prior breaking-change changesets for precedent.
fd -t f 'package.json' packages/typescript/ai-openrouter --exec jq -r '.name + " " + .version' {} \;
# Look at recent changesets for how past breaking changes were bumped
fd -t f -e md . .changeset | head -50

Repository: TanStack/ai

Length of output: 466


🏁 Script executed:

# Check the other provider-tools changesets to see how breaking changes were bumped
cat .changeset/provider-tools-ai-anthropic.md
cat .changeset/provider-tools-ai-core.md
cat .changeset/provider-tools-ai-openai.md

Repository: TanStack/ai

Length of output: 1566


🏁 Script executed:

# Check .changeset configuration to understand versioning policy
cat .changeset/config.json 2>/dev/null || cat .changeset/config.js 2>/dev/null || echo "No config found"

Repository: TanStack/ai

Length of output: 498


🏁 Script executed:

# Look for versioning policy documentation
fd -t f -e md '(CONTRIBUTING|README|CHANGELOG)' . | head -5 | xargs -I {} grep -l "major\|minor\|breaking\|pre-1.0\|0\." {} 2>/dev/null || echo "No policy found in docs"

Repository: TanStack/ai

Length of output: 114


Change semantic version to major for this breaking export removal.

This changeset describes an actual breaking change—createWebSearchTool is removed from the package root without a deprecation path. The similar provider-tools changesets (@tanstack/ai-anthropic, @tanstack/ai-openai) are marked minor because they add new /tools exports while preserving backward compatibility via deprecated aliases. The openrouter change removes an export entirely, which is a breaking change and should be major per semver, regardless of the 0.x version number.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/provider-tools-ai-openrouter.md around lines 1 - 7, The changeset
incorrectly uses a minor bump for a breaking export removal; update the
changeset to mark the release as major. Change the version tag from 'minor' to
'major' in the .changeset file for '@tanstack/ai-openrouter' and adjust the
description to clearly state that createWebSearchTool was removed from the
package root and consumers must import webSearchTool from
'@tanstack/ai-openrouter/tools' (mentioning symbols createWebSearchTool and
webSearchTool/OpenRouterWebSearchTool and the tools subpath) so the changeset
accurately represents the breaking change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this at minor. The package is pre-1.0 (0.7.7) and the project's existing convention is to ship breaking export changes as minor at 0.x — see recent precedent in commits c78f1463 ("bump adapters to minor for new /tools subpath + openrouter breaking") and 7e02c600 ("downgrade @tanstack/ai AG-UI interop changeset to minor"). The breaking nature is already called out in the changeset body and in Migration Guide §6.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

195 changes: 195 additions & 0 deletions docs/adapters/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,198 @@ Creates an Anthropic summarization adapter with an explicit API key.
- [Getting Started](../getting-started/quick-start) - Learn the basics
- [Tools Guide](../tools/tools) - Learn about tools
- [Other Adapters](./openai) - Explore other providers

## Provider Tools

Anthropic exposes several native tools beyond user-defined function calls.
Import them from `@tanstack/ai-anthropic/tools` and pass them into
`chat({ tools: [...] })`.

> For the full concept, a comparison matrix, and type-gating details, see
> [Provider Tools](../tools/provider-tools.md).

### `webSearchTool`

Enables Claude to run Anthropic's native web search with inline citations.
Scope the search with `allowed_domains` or `blocked_domains` (mutually
exclusive); set `max_uses` to cap per-turn cost.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { webSearchTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-opus-4-6"),
messages: [{ role: "user", content: "What's new in AI this week?" }],
tools: [
webSearchTool({
name: "web_search",
type: "web_search_20250305",
max_uses: 2,
}),
],
});
```

**Supported models:** every current Claude model. `claude-3-haiku` supports
only `web_search` (not `web_fetch`). See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `webFetchTool`

Lets Claude fetch the contents of a URL directly, useful when you want the
model to read a specific page rather than run a search. Takes no required
arguments — pass an optional config object to override defaults.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { webFetchTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Summarise https://example.com" }],
tools: [webFetchTool()],
});
```

**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `codeExecutionTool`

Gives Claude a sandboxed code-execution environment so it can run Python
snippets, analyse data, and return results inline. Choose the version string
that matches your desired API revision.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { codeExecutionTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Plot a histogram of [1,2,2,3,3,3]" }],
tools: [
codeExecutionTool({ name: "code_execution", type: "code_execution_20250825" }),
],
});
```

**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `computerUseTool`

Allows Claude to observe a virtual desktop (screenshots) and interact with it
via keyboard and mouse events. Provide the screen resolution so Claude can
calculate accurate coordinates.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { computerUseTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Open the browser and go to example.com" }],
tools: [
computerUseTool({
type: "computer_20250124",
name: "computer",
display_width_px: 1024,
display_height_px: 768,
}),
],
});
```

**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `bashTool`

Provides Claude with a persistent bash shell session, letting it run arbitrary
commands, install packages, or manipulate files on the host. Choose the type
string that matches your API revision.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { bashTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "List all TypeScript files in src/" }],
tools: [bashTool({ name: "bash", type: "bash_20250124" })],
});
```

**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `textEditorTool`

Gives Claude a structured text-editor interface for viewing and modifying files
using `str_replace`, `create`, `view`, and `undo_edit` commands. Choose the
type string for the API revision you target.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { textEditorTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Fix the bug in src/index.ts" }],
tools: [
textEditorTool({ type: "text_editor_20250124", name: "str_replace_editor" }),
],
});
```

**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `memoryTool`

Enables Claude to store and retrieve information across conversation turns
using Anthropic's managed memory service. Call with no arguments to use
default configuration.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { memoryTool } from "@tanstack/ai-anthropic/tools";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Remember that I prefer metric units" }],
tools: [memoryTool()],
});
```

**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `customTool`

Creates a tool with an inline JSON Schema input definition instead of going
through `toolDefinition()`. Useful when you need fine-grained control over the
schema shape or want to add `cache_control`. Unlike branded provider tools,
`customTool` returns a plain `Tool` and is accepted by any chat model.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { customTool } from "@tanstack/ai-anthropic/tools";
import { z } from "zod";

const stream = chat({
adapter: anthropicText("claude-sonnet-4-5"),
messages: [{ role: "user", content: "Look up user 42" }],
tools: [
customTool(
"lookup_user",
"Look up a user by ID and return their profile",
z.object({ userId: z.number() }),
),
],
});
```

**Supported models:** all current Claude models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).
Loading
Loading