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

# Vercel AI SDK

> Give a Vercel AI SDK model Octen search APIs and Extract.

For AI agents: [docs.octen.ai/integrations/vercel-ai-sdk.md](https://docs.octen.ai/integrations/vercel-ai-sdk.md)

The `@octen.ai/ai-sdk-tools` package provides the ready-made [Vercel AI SDK](https://ai-sdk.dev) tools listed in [Tools](#tools).

> [card] [Get API Key](https://octen.ai/platform/api-keys)
>
> Create a key from the API Platform.

> [card] [npm](https://www.npmjs.com/package/@octen.ai/ai-sdk-tools)
>
> The `@octen.ai/ai-sdk-tools` package.

## Install

Requires Node.js 22+.

```bash theme={null}
npm install @octen.ai/ai-sdk-tools ai zod @ai-sdk/openai
```

## Quick Start

Set your Octen and OpenAI API keys:

```bash theme={null}
export OCTEN_API_KEY="your-api-key"
export OPENAI_API_KEY="your-openai-api-key"
```

Run a model that answers with Octen Web Search and News Search:

```typescript theme={null}
import { generateText, isStepCount } from "ai";
import { openai } from "@ai-sdk/openai";
import { octenNewsSearch, octenWebSearch } from "@octen.ai/ai-sdk-tools";

const { text } = await generateText({
  model: openai("gpt-5.4"),
  tools: {
    webSearch: octenWebSearch(),
    newsSearch: octenNewsSearch(),
  },
  stopWhen: isStepCount(5),
  prompt: "What changed in the latest Node.js LTS release? Cite your sources.",
});
console.log(text);
```

`stopWhen: isStepCount(5)` lets the model search, read the results, and answer within five steps. Without it, `generateText` stops after the search and `text` is empty.

The example uses `ai` 7. On `ai` 5 or 6, use `stepCountIs` in place of `isStepCount`, and install `@ai-sdk/openai@ai-v5` or `@ai-sdk/openai@ai-v6` to match.

## Tools

| Tool | Octen API | Parameters the model sets |
| - | - | - |
| `octenWebSearch()` | [Web Search](https://docs.octen.ai/api-reference/search.md) | `query`, `time_range` |
| `octenWebSearchPremier()` | [Web Search Premier](https://docs.octen.ai/api-reference/search-premier.md) | `query`, `time_range` |
| `octenBroadSearch()` | [Broad Search](https://docs.octen.ai/api-reference/broad-search.md) | `query` |
| `octenNewsSearch()` | [News Search](https://docs.octen.ai/api-reference/news-search.md) | `query`, `time_range` |
| `octenBusinessSearch()` | [Business Search](https://docs.octen.ai/api-reference/business-search.md) | `query` |
| `octenPulseSearch()` | [Pulse Search](https://docs.octen.ai/api-reference/pulse-search.md) | `query` |
| `octenPlaceSearch()` | [Place Search](https://docs.octen.ai/api-reference/place-search.md) | `query` |
| `octenImageSearch()` | [Image Search](https://docs.octen.ai/api-reference/image-search.md) | `query` or `image_url`, `include_domains`, `exclude_domains` |
| `octenDesignSearch()` | [Design Search](https://docs.octen.ai/api-reference/design-search.md) | `query`, `group_id` |
| `octenExtract()` | [Extract](https://docs.octen.ai/api-reference/extract.md) | `urls`, `query` |

Each tool reads `OCTEN_API_KEY` unless you pass `apiKey`. For the search tools, set any parameter other than `query` in `defaults`, with its API reference name: `octenWebSearch({ defaults: { count: 10, result_type: "dynamic" } })`. A parameter you set in `defaults` is no longer offered to the model. Image Search, Design Search, and Extract take named options instead of `defaults`; see the [package README](https://www.npmjs.com/package/@octen.ai/ai-sdk-tools).

## Use Auto Search

Skip the tool loop and let Octen run the searches server-side with [Auto Search](https://docs.octen.ai/capabilities/auto-search.md). Point the model at the Octen base URL and enable the built-in `octen_search` tool. Your Octen API key is the only key you need.

Install the provider for OpenAI-compatible APIs:

```bash theme={null}
npm install @ai-sdk/openai-compatible
```

Run the model:

```typescript theme={null}
import { generateText } from "ai";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const octen = createOpenAICompatible({
  name: "octen",
  baseURL: "https://api.octen.ai/v1",
  apiKey: process.env.OCTEN_API_KEY,
  transformRequestBody: (body) => ({ ...body, tools: [{ type: "octen_search" }] }),
});

const { text } = await generateText({
  model: octen("openai/gpt-5.4"),
  prompt: "What happened in AI this week?",
});
console.log(text);
```

***

Last modified on November 24, 2026


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