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

> ## Agent Instructions
> Every page is listed in https://docs.keenable.ai/llms.txt. To pick a product for a job, read https://docs.keenable.ai/choose.md
> Setup steps for agents, covering the SDKs, the MCP server and the CLI: https://docs.keenable.ai/skill.md
> Keenable search and fetch work without an API key. To add them to code, use the official SDK for the project's language: https://docs.keenable.ai/sdks.md
> Without a key, call POST https://api.keenable.ai/v1/search/public or GET https://api.keenable.ai/v1/fetch/public with an X-Keenable-Title header that names your app.
> With a key, send it in the X-API-Key header and read it from the KEENABLE_API_KEY environment variable. Never ask a user to paste a key into chat. Every access method: https://docs.keenable.ai/auth.md
> To get an API key without the console, use device login: https://docs.keenable.ai/authentication.md#device-login
> MCP server: https://api.keenable.ai/mcp (no key, or X-API-Key; keyless Codex uses https://api.keenable.ai/mcp-public), or https://api.keenable.ai/mcp-oauth for OAuth sign-in. These docs are an MCP server at https://docs.keenable.ai/mcp and the OpenAPI spec is at https://docs.keenable.ai/api-reference/openapi.json
> Keenable searches and fetches public web pages. If a question needs no web information, skip the call.
> On 402 with an API key (code insufficient_credits), stop and ask a human to add credits; don't retry. On 429, wait the number of seconds in Retry-After, then retry. Before you ship, follow https://docs.keenable.ai/production.md
> Every error, with its cause and fix, is in https://docs.keenable.ai/errors.md and moving from another search API is covered in https://docs.keenable.ai/migrate.md
> Before you compare Keenable with another search API, read https://docs.keenable.ai/guides/evaluate-search-apis.md

# Vercel AI SDK web search tools

> Keyless web search and page fetch for the Vercel AI SDK (`@keenable/ai-sdk`), plus Vercel Connect to keep the API key out of environment variables.

*Vercel AI SDK tools and Vercel Connect*

Give any AI SDK call web search and page fetch, and keep your Keenable API key out of environment variables. Use these two pieces together or on their own:

* **`@keenable/ai-sdk`** gives any `generateText` or `streamText` call web search and page fetch as AI SDK tools. It works without a key, so the first snippet below runs as-is.
* **Vercel Connect** lists Keenable in its catalog. Connect keeps your API key at the team level and hands it to your code at runtime with `getToken`, so the key never sits in an environment variable.

→ [@keenable/ai-sdk on npm](https://www.npmjs.com/package/@keenable/ai-sdk) · [Keenable on Vercel Connect](https://vercel.com/connect/keenable)

## Vercel AI SDK tools

### Install

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
npm install @keenable/ai-sdk ai zod
```

`ai` and `zod` are peer dependencies, already present in an AI SDK project. The package works with `ai` v5, v6 and v7, and with zod v3 and v4. The examples use `@ai-sdk/openai`, but any model provider works.

### Add the tools

Pass `keenableTools()` to `generateText`:

```typescript theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs } from "ai";
import { keenableTools } from "@keenable/ai-sdk";

const { text } = await generateText({
  model: openai("gpt-5.6-sol"),
  tools: keenableTools(),
  stopWhen: stepCountIs(6),
  prompt: "What changed in the latest Bun release? Cite the pages you used.",
});
```

`stopWhen` lets the model search, read the results and then answer. Without it, `generateText` stops after the first step and returns only the tool call. The model sees the tools as `keenable_search` and `keenable_fetch`. To add only one tool, import `keenableSearch` or `keenableFetch` instead of the pair.

> [!NOTE]
>
> Set `KEENABLE_API_KEY` to remove the hourly request cap. If you don't set a key, calls run on the shared keyless tier, which allows 1,000 requests per hour per IP address. See [Rate limits](https://docs.keenable.ai/rate-limits.md).

Or pass the key directly: `keenableTools({ apiKey: "keen_<your_key>" })`. On Vercel, [keep the key in Vercel Connect](#keep-the-key-in-vercel-connect) instead of an environment variable.

## Keep the key in Vercel Connect

You don't need Connect, or a key, to start. A key lifts the [request limits](https://docs.keenable.ai/rate-limits.md), and Connect is where a Vercel project keeps it.

### Get a key

Create an API key in the [Keenable console](https://app.keenable.ai/console).

### Create the connector

In the Vercel dashboard, open **Connect** for your project, select **Create Connector** and choose Keenable. A connector created from the project page is linked to that project. Or, from a directory linked to the project:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
vercel connect create keenable --name keenable
vercel connect attach keenable/keenable
```

The CLI asks for the connection method and the key. Choose **API key**. An API key works for both the REST API and the MCP server, and it needs no signed-in user, so backends and cron jobs can use it.

### Fetch the key at runtime

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
npm install @vercel/connect
```

Fetch the key with `getToken` and pass it to `keenableTools`:

```typescript theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
import { getToken } from "@vercel/connect";
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs } from "ai";
import { keenableTools } from "@keenable/ai-sdk";

export async function answer(prompt: string) {
  const apiKey = await getToken("keenable/keenable", {
    subject: { type: "app" },
  });

  const { text } = await generateText({
    model: openai("gpt-5.6-sol"),
    tools: keenableTools({ apiKey }),
    stopWhen: stepCountIs(6),
    prompt,
  });
  return text;
}
```

`keenable/keenable` is the connector's UID: the service, then the name you gave it. On Vercel, `getToken` authenticates with the deployment's OIDC token. Locally, run `vercel env pull` first. Call `getToken` per request rather than once at startup. The SDK caches the key in process.

Without the AI SDK package, send the same value to the [REST API](https://docs.keenable.ai/api-reference.md) as `X-API-Key` or `Authorization: Bearer`:

```typescript theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
const res = await fetch("https://api.keenable.ai/v1/search", {
  method: "POST",
  headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify({ query: "latest Bun release" }),
});
```

### OAuth for MCP

The connector also offers OAuth for the [MCP server](https://docs.keenable.ai/mcp-server.md). With Connect's OAuth method, each user signs in to Keenable once and Connect stores their token. Their calls then run on their own Keenable account with no key to copy, as in the [ChatGPT](https://docs.keenable.ai/integrations/chatgpt.md) install. The OAuth method issues user tokens only (`subject: { type: "user", id }`), so use the API key method for anything that runs without a signed-in user.

## Billing

Connect stores the credential and nothing else. Keenable bills the calls to the organization that owns the key, at 100,000 free requests a month, then \$4 per 1,000. See [Pricing](https://docs.keenable.ai/pricing.md). Vercel doesn't charge for them.

## Related pages

> [card] [Mastra](https://docs.keenable.ai/integrations/mastra.md)
>
> Give Mastra agents web search and page fetch with the @keenable/mastra package: the keenable-search and keenable-fetch tools.

> [card] [OpenRouter](https://docs.keenable.ai/integrations/openrouter.md)
>
> Web search and page fetch for any OpenRouter model, as tools it calls itself: from Python, the AI SDK, or the Agent SDK over MCP. No Keenable key needed.

> [card] [Agno](https://docs.keenable.ai/integrations/agno.md)
>
> Give Agno agents web search and page reading with KeenableTools, a toolkit built into Agno, with no API key required.

> [card] [npcpy](https://docs.keenable.ai/integrations/npcpy.md)
>
> Search the web from npcpy with the keenable provider for search\_web, or call search\_keenable directly. No API key needed, in npcpy 2.1.28 and later.


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