Skip to content

New AI assistant answers: ChatGPT, Gemini, Copilot and AI Mode by API

SerpKite
Get API key

TypeScript · @serpkite/ai-sdk

Vercel AI SDK + SerpKite

@serpkite/ai-sdk is the official SerpKite tool package for the Vercel AI SDK. serpkiteTools() hands any model 21 tools (search, news, maps, place details, reviews, scholar, webpage, extract, crawl, cited answers, research and more) that return Markdown it can read directly.

Overview

What Vercel AI SDK is, and where SerpKite fits

The Vercel AI SDK is a TypeScript toolkit for building AI apps with any model provider. Tools are objects with a description, an input schema and an execute function, passed to generateText, streamText or an Agent.

@serpkite/ai-sdk builds those tools for every SerpKite endpoint on top of the official serpkite SDK, so retries, timeouts and typed errors come with it. Each input schema lists only the fields its endpoint accepts, so the model can't send a parameter the API rejects.

The client is created on the first tool call, so tools defined at module scope don't need SERPKITE_API_KEY during next build.

Setup

Set it up in 4 steps

  1. 1

    Get an API key

    Sign up (no card), create a key in the dashboard and export it as SERPKITE_API_KEY. New accounts get 2,500 free credits, then 1,000 every month.

    export SERPKITE_API_KEY=skt_live_…
  2. 2

    Install

    The tool package, the AI SDK, a model provider and zod (3.25+ or 4).

    npm install @serpkite/ai-sdk ai @ai-sdk/openai zod
  3. 3

    Pick the tools

    serpkiteTools({ only: [...] }) returns a tool set. A short list helps the model choose; search and webpage cover most research agents.

  4. 4

    Let the model loop

    stopWhen: stepCountIs(5) lets the model search, read the results and answer in one call.

Code

Complete example

import { openai } from "@ai-sdk/openai";
import { serpkiteTools } from "@serpkite/ai-sdk";
import { generateText, stepCountIs } from "ai";

const { text, steps } = await generateText({
  model: openai("gpt-5-mini"),
  tools: serpkiteTools({ only: ["search", "news", "webpage"] }),
  stopWhen: stepCountIs(5),
  prompt: "What did the latest Node.js LTS release change? Cite sources.",
});

console.log(text);
console.log(steps.flatMap((s) => s.toolCalls.map((c) => c.toolName))); // e.g. ["search", "webpage"]

21 tools

Every endpoint as a tool

  • Search: search, news, images, videos, shopping, scholar, patents, autocomplete.

  • Places: maps, places, place (one listing with hours, country, time zone and photos) and reviews (pass the place_id from a maps result).

  • Pages and sites: webpage (one URL as Markdown), extract (up to 20 URLs, optionally only the passages relevant to a query), map (a site's URLs), rank (a domain's position for a keyword), and crawl + crawl_result for async site crawls.

  • AI: answer (a cited answer written by Claude from live results), research + research_result (an async report with citations). search and news take include_answer, and extract takes summary.

  • Each tool also has its own factory (serpkiteSearch(), serpkiteExtract(), …) if you want to name it yourself. Failed and empty results cost nothing; a thrown SerpKiteError reaches the model as a tool error, so the run continues.

Options

Pin what the model shouldn't choose

defaults apply under the model's input and fixed over it. Use fixed for fields the model never sees: engine: "auto" (fall back to other search engines when Google is unavailable), max_age (accept cached results at half the credits), include_domains, fields.

format picks the response shape for the search, place and page tools: markdown (default, fewest tokens), compact or json (the full typed response).

TypeScript
import { SerpKite } from "serpkite";
import { serpkiteTools } from "@serpkite/ai-sdk";

const tools = serpkiteTools({
  exclude: ["crawl", "crawl_result"],
  format: "compact",
  client: new SerpKite({ timeoutMs: 30_000, maxRetries: 1 }), // or apiKey, baseUrl, fetch…
});

AI assistants

Ask ChatGPT, Gemini and other AI assistants

The serpkite SDK asks ChatGPT, Gemini, Copilot Search, Google AI Mode and Brave's AI answer as a logged-out visitor (sk.chatgpt, sk.gemini, sk.copilot, sk.aiMode, sk.braveAi) and returns the answer as Markdown with the sources it cited. Define the tool with tool() from ai, next to the serpkiteTools() set. Give the agent a second opinion, or have it check what assistants say about your brand: track adds mentions of the brands and domains you list. See AI assistants.

ChatGPT 4, Gemini 3, Copilot Search 3, Google AI Mode 2 and Brave AI 2 credits per answer; failed, refused and empty answers are free. Brave answers in 1–10 s, ChatGPT in 10–30 s and Gemini in 5–30 s, so allow at least 120 seconds per call.

TypeScript
import { serpkiteTools } from "@serpkite/ai-sdk";
import { tool } from "ai";
import { SerpKite } from "serpkite";
import { z } from "zod";

const sk = new SerpKite(); // reads SERPKITE_API_KEY

export const tools = {
  ...serpkiteTools({ only: ["search", "webpage"] }),
  askChatGPT: tool({
    description:
      "Ask ChatGPT (logged out, searching the web). Returns its answer as Markdown with the sources it cited. Takes 10–30 s.",
    inputSchema: z.object({ prompt: z.string().describe("The question to ask ChatGPT") }),
    execute: ({ prompt }, { abortSignal }) =>
      sk.chatgpt({ prompt, format: "markdown" }, { signal: abortSignal }),
  }),
};

FAQ

Vercel AI SDK and SerpKite: common questions

Start building

Give your Vercel AI SDK project Google search

2,500 free credits, then 1,000 every month. No credit card.