Skip to content
CrawlerData
Menu
Integration · AI frameworks

Google Search and AI Overview tools for the Vercel AI SDK

crawlerdata-ai-sdk adds Google Search to any AI SDK model as a tool. The model gets the top results and, when Google shows one, the AI Overview with the pages it cites. News, Images, Local and Autocomplete tools are included.

Code on this page tested 2026-10-13

Use cases

What you can do

  • Let a model look things up on Google while it answers: current facts, recent events, anything it is unsure about.
  • Read Google's AI Overview and the pages it cites, for a country and device you choose.
  • Add Google News, Images, Local and Autocomplete with the same key, one tool each or all at once with crawlerdataTools().
Before you start

Prerequisites

  • The Vercel AI SDK (ai) v5, v6 or v7 and zod. We tested the package against ai 5.0.278, 6.0.311 and 7.0.147.
  • Node.js 18 or newer.
  • A CrawlerData API key in the CRAWLERDATA_API_KEY environment variable.

No key yet? Sign up for 50 free credits, then create a key under API Access.

Setup

Step by step

  1. Install the package

    crawlerdata-ai-sdk has ai and zod as peer dependencies and no other runtime dependencies. Create an API key in the dashboard and export it as CRAWLERDATA_API_KEY.

    install.sh
    npm install crawlerdata-ai-sdk ai zod
    
    # Create a key at https://app.crawlerdata.com, then:
    export CRAWLERDATA_API_KEY=YOUR_API_KEY
  2. Add the tool to generateText

    crawlerdataSearch() returns an AI SDK tool. The model decides when to call it, and the tool returns the top results, the AI Overview text with its cited sources when Google shows one, and related questions. crawlerdataTools() adds the other four tools. Options are apiKey, country, language, maxResults and timeoutMs.

    The model id below uses the AI Gateway; any AI SDK model works.

    usage.mjs
    import { generateText, isStepCount } from 'ai';
    import { crawlerdataSearch, crawlerdataTools } from 'crawlerdata-ai-sdk';
    
    // One tool: Google Search with Google's AI Overview and its sources.
    const { text } = await generateText({
      model: 'openai/gpt-5-mini', // any AI SDK model; this id uses the AI Gateway
      prompt: 'Does Google show an AI Overview for "what is a sitemap"? Which sources does it cite?',
      tools: { crawlerdataSearch: crawlerdataSearch() }, // reads CRAWLERDATA_API_KEY
      stopWhen: isStepCount(3),
    });
    console.log(text);
    
    // All five tools (search, news, images, local, autocomplete), with a default country.
    const result = await generateText({
      model: 'openai/gpt-5-mini',
      prompt: 'What is in the news about Nvidia in the UK today? Give me three headlines with sources.',
      tools: crawlerdataTools({ country: 'gb', maxResults: 5 }),
      stopWhen: isStepCount(4),
    });
    console.log(result.text);
  3. Check what the model receives

    A tool is an ordinary function, so you can call its execute method directly. This is the quickest way to check your key and to see the exact, trimmed result the model gets, which keeps token use low: at most maxResults rows (default 8) and only the fields a model needs.

    check.mjs
    // Call a tool directly, without a model, to check your key and see exactly what the model would receive.
    import { crawlerdataSearch, crawlerdataAutocomplete } from 'crawlerdata-ai-sdk';
    
    const search = crawlerdataSearch({ maxResults: 3 }); // reads CRAWLERDATA_API_KEY
    const out = await search.execute({ query: 'what is a sitemap' }, { toolCallId: 'check', messages: [] });
    
    console.log('AI Overview:', out.ai_overview ? out.ai_overview.text.slice(0, 120) + '...' : 'none for this search');
    console.log('Cited:', out.ai_overview?.sources.map((s) => s.link));
    for (const r of out.organic_results) console.log(r.position, r.title, r.link);
    
    const suggest = crawlerdataAutocomplete({ maxResults: 3 });
    console.log((await suggest.execute({ query: 'running sho' }, { toolCallId: 'check', messages: [] })).suggestions);
Tested 2026-10-13

How we tested it

  • Ran check.mjs with Node 24 and ai 7 against the live API: crawlerdataSearch returned 3 organic results and the AI Overview text with its 4 cited sources, and crawlerdataAutocomplete returned 3 suggestions. 2 credits.
  • The package test suite (11 tests) passes, including a generateText run on AI SDK 7 where a mock model calls crawlerdataSearch and answers from its result, and mocked 401 and 402 errors that become readable messages.
  • Smoke-tested the built package against ai 5.0.278, 6.0.311 and 7.0.147: the tool builds and its execute method returns the result.
  • We did not run usage.mjs with a hosted language model for this page. The model side is the AI SDK itself; the tools are the part we test.
Credits

What it costs

Every call costs 1 credit, except Google Shopping sellers, which costs 1 credit per 10 sellers returned (rounded up, minimum 1). Failed jobs cost 0 credits, and the live, fast and regular queues all cost the same.

Each tool call is one request, so one credit. If a model calls a tool several times in a step you pay for each call: lower isStepCount, or set maxResults.

See credit pack prices →

Troubleshooting

If something goes wrong

401 INVALID_API_KEY
The key is missing, mistyped or revoked. Send it as "Authorization: Bearer YOUR_API_KEY" (with the word Bearer and one space) and check the key is active under API Access in the dashboard.
402 INSUFFICIENT_CREDITS
Your balance is too low for the request. Buy a credit pack in the dashboard. Requests that fail for other reasons are not charged, so a 402 never costs credits.
429 RATE_LIMITED
Each API key allows 100 requests per minute and 20 per second. Wait until the time in the X-RateLimit-Reset header (a Unix timestamp) and retry, or spread requests out.
Timeouts on live requests
A live request returns when the result is ready. Search requests usually take a few seconds; a Google Shopping sellers request collects every seller for the product, so allow more time. Set the client timeout to about 200 seconds, or use the fast queue and poll the job.
CrawlerData API key missing
The tool found no key. Set CRAWLERDATA_API_KEY or pass { apiKey } to the tool.
Tool errors during generateText
The tool throws a readable message and the AI SDK hands it to the model as a tool error. Run check.mjs to see the underlying error yourself.

Request and response schemas: OpenAPI 3.1 document. Still stuck? Email contact@crawlerdata.com.

FAQ

Questions

Which AI SDK versions does it work with?

v5, v6 and v7. The package only uses the tool() helper and zod schemas, and we ran it against 5.0.278, 6.0.311 and 7.0.147.

Does the model get the AI Overview?

Yes, when Google shows one for the search. crawlerdataSearch returns it as ai_overview with its text and the pages it cites, or null when Google shows none.

Can I limit how much data the model receives?

Yes. maxResults (default 8) caps the rows per call, and each tool returns only the fields a model needs, not the full API response.

Can I use it in the browser?

No. The tool uses your API key, which would be visible to every visitor. Run generateText on your server or in an edge function.

Is there an MCP alternative?

Yes. The AI SDK can use an MCP server as a tool source, and CrawlerData has a remote MCP server. The tools in this package are simpler to configure and return a smaller result.

Try it with 50 free credits

Sign up with your work email and verify it, then create an API key. Failed requests are never charged.

Get 50 free credits