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

# Vercel AI SDK

> Give an AI SDK agent product search and live retailer offers with @channel3/agent-toolkit.

`@channel3/agent-toolkit` adds Channel3 product search to any [Vercel AI SDK](https://ai-sdk.dev) agent. It provides the same two tools as the [Channel3 MCP](/docs/mcp-overview.md): `search_products` and `get_products`. It works with AI SDK v6 and v7.

## Install

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install ai @channel3/agent-toolkit
```

Set `CHANNEL3_API_KEY` in your environment. [Create a free API key](https://channel3.ai/sign-up/developer) if you don't have one yet.

## Use the tools

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { generateText, isStepCount } from "ai";
import { searchProductsTool, getProductsTool } from "@channel3/agent-toolkit/ai-sdk";

const { text } = await generateText({
  model: "anthropic/claude-sonnet-5.5",
  prompt: "Find me a leather golf glove under $40 and tell me which retailer has it cheapest.",
  tools: {
    search_products: searchProductsTool,
    get_products: getProductsTool,
  },
  stopWhen: isStepCount(5),
});
```

The agent searches, picks a product, fetches its details, and compares offers across retailers.

The tools work the same way with `streamText`. To add both tools at once, use `channel3Tools()`:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { streamText } from "ai";
import { channel3Tools } from "@channel3/agent-toolkit/ai-sdk";

const result = streamText({ model, messages, tools: channel3Tools() });
```

## Tools

| Tool | Input | Returns | Credits |
| - | - | - | - |
| `search_products` | `query` and/or `image_url` | Up to 8 in-stock products with images and every retailer's offer | 1 per search |
| `get_products` | Up to 40 product IDs or retailer URLs | Full product data, plus any inputs it couldn't resolve | Free by ID, 1 per retailer URL |

For `search_products`, the model receives a compact summary: one line per product with title, brand, best price and ID. The full structured result stays in the tool output, so your UI can render product cards from it.

Offer URLs are Channel3 buy links. Purchases through them earn [commission](/docs/commissions.md) for your account.

## Options

Use the factory functions to set the key, the result count, or a conversation ID:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { createSearchProductsTool, createGetProductsTool } from "@channel3/agent-toolkit/ai-sdk";

const options = { apiKey: process.env.CHANNEL3_API_KEY, conversationId: chatId };

const tools = {
  search_products: createSearchProductsTool({ ...options, limit: 12 }),
  get_products: createGetProductsTool(options),
};
```

| Option | Description |
| - | - |
| `apiKey` | Channel3 API key. Defaults to `CHANNEL3_API_KEY`. |
| `conversationId` | Groups one chat's calls together in your Channel3 analytics. |
| `limit` | Products per search, from 1 to 30. Defaults to 8. |
| `baseUrl` | Overrides the API base URL. |

## Other frameworks

The same tools are available for [LangChain](/docs/langchain.md). The root export, `@channel3/agent-toolkit`, has framework-free `searchProducts()` and `getProducts()` functions plus the input schemas, for wrapping the tools in any other framework.

## Beyond search

For browse, similar products, brands, price tracking and the rest of the API, call the [TypeScript SDK](/docs/sdk/keyword-search.md) from your own `tool()`.


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