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

# Vercel AI SDK

> Use Geekflare in the Vercel AI SDK with the @geekflare/ai-sdk package, with tools for search, web scraping, screenshots, and website diagnostics.

The `@geekflare/ai-sdk` package gives the [Vercel AI SDK](https://ai-sdk.dev) Geekflare as a set of tools: web and Google SERP search, page scraping to Markdown or structured JSON, screenshots, and website diagnostics. It works with AI SDK 5, 6, and 7, requires `zod` 3.25+ or 4 and Node 18+, supports both ESM and CJS, and has no dependencies beyond the `ai` and `zod` peers.

## Install

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

```bash pnpm theme={null}
pnpm add @geekflare/ai-sdk
```

```bash yarn theme={null}
yarn add @geekflare/ai-sdk
```

```bash bun theme={null}
bun add @geekflare/ai-sdk
```

## Set the API key

Get an API key at [dash.geekflare.com](https://dash.geekflare.com) and set it as an environment variable:

```bash theme={null}
export GEEKFLARE_API_KEY="YOUR_API_KEY"
```

Replace `YOUR_API_KEY` with your Geekflare API key. You can also pass the key to any tool with the `apiKey` option.

## Quick start

Add `geekflareSearch()` to `generateText` so the model can search the web:

```ts theme={null}
import { generateText, isStepCount } from "ai";
import { geekflareSearch } from "@geekflare/ai-sdk";

const { text } = await generateText({
  model: "openai/gpt-5-mini",
  prompt: "What are the latest developments in AI agents? Cite sources.",
  tools: {
    geekflareSearch: geekflareSearch(),
  },
  stopWhen: isStepCount(3),
});

console.log(text);
```

## All tools

`geekflareTools()` returns all four tools, keyed by name:

```ts theme={null}
import { generateText, isStepCount } from "ai";
import { geekflareTools } from "@geekflare/ai-sdk";

const { text } = await generateText({
  model: "openai/gpt-5-mini",
  prompt: "Is the TLS setup on example.com healthy, and what does its homepage say?",
  tools: geekflareTools(),
  stopWhen: isStepCount(5),
});
```

| Factory | What the model can do | Model inputs |
| :- | :- | :- |
| `geekflareSearch()` | Web, news, or image search. `serp: true` returns the full Google results page (organic results, AI Overview, People Also Ask) by country or city. | `query`, `serp`, `source`, `limit`, `location`, `city`, `time` |
| `geekflareScrape()` | Get page content as Markdown (default), text, HTML, or JSON. Use `template: "product"` or `"contact"` for structured data. | `url`, `template` |
| `geekflareScreenshot()` | Capture a screenshot and get a hosted image URL. | `url`, `fullPage` |
| `geekflareWebsiteCheck()` | Run one check: `site_status`, `dns_records`, `dnssec`, `tls_scan`, `redirect_check`, `broken_links`, `load_time`, `mixed_content`, or `lighthouse`. | `url`, `check` |
| `geekflareTools()` | All four tools above, keyed by name. | |

## Options

Every tool accepts these options:

| Option | Description |
| :- | :- |
| `apiKey` | Your Geekflare API key. Defaults to the `GEEKFLARE_API_KEY` environment variable. |
| `baseUrl` | Override the API base URL. |
| `timeoutMs` | Request timeout in milliseconds. Default `180000`. |

Some tools also take defaults that apply when the model doesn't set them:

| Tool | Default options |
| :- | :- |
| `geekflareSearch()` | `limit`, `location`, `city`, `includeDomains`, `excludeDomains` |
| `geekflareScrape()` | `format` |
| `geekflareScreenshot()` | `device`, `type` |

## Errors

API errors (such as an invalid key, no credits, or an unreachable site) throw `GeekflareAPIError` with the message from the API. The AI SDK returns it to the model as a tool error, so the model can read the message and respond.

## Notes

* Each call spends credits from your Geekflare account. See [Credit Consumption](/api-credit-mapping) and [pricing](https://geekflare.com/pricing/).
* Geekflare works with public pages only.

## Links

> **[npm](https://www.npmjs.com/package/@geekflare/ai-sdk)**
>
> `@geekflare/ai-sdk` on npm.

> **[GitHub](https://github.com/geekflare/geekflare-ai-sdk)**
>
> Source code (MIT license).

> **[LangChain](/integrations/langchain)**
>
> Use Geekflare tools in LangChain agents.

> **[LlamaIndex](/integrations/llamaindex)**
>
> Use Geekflare tools in LlamaIndex agents.

> **[MCP Server](/mcp/overview)**
>
> Connect Geekflare to AI clients through MCP.


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