Skip to content

Latest commit

 

History

History
170 lines (115 loc) · 3.94 KB

File metadata and controls

170 lines (115 loc) · 3.94 KB
SERPHouse logo

@SERPHouse/ai-sdk

AI tool calling utilities for web search, news, and short videos — powered by SERPHouse.

Drop-in Vercel AI SDK tool() definitions for Google web search, news, and short-video search.


TypeScript 5+ Vercel AI SDK MIT License


Install

npm install @serphouse/ai-sdk

Requires Node.js >= 18 with ai and zod as peer dependencies.


Quick Start

1. Get your API key from the SERPHouse Dashboard and set it:

export SERPHOUSE_API_KEY="your_key_here"

2. Import and use with any AI SDK model:

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { search, news } from "@serphouse/ai-sdk";

const { text } = await generateText({
  model: openai("gpt-4o"),
  tools: { search: search(), news: news() },
  prompt: "What are the latest AI news?",
});

The LLM decides when to call each tool. No manual API wiring needed.


Tools

Tool Description API Endpoint
search(options?) Google web search /web-search-lite
news(options?) Google News search /google-news
shortVideo(options?) Google Short Videos search /google-short-videos-api

Each returns a typed Vercel AI SDK tool object with a Zod input schema and execute handler.

Input Schema

Field Type Default Description
q string Search query (required)
domain string "google.com" Google domain
lang string "en" Language code
loc string "New York,New York,United States" Location (City,State,Country)
page number Page number
date_range string "y" Time filter: h, d, w, m, y, or YYYY-MM-DD,YYYY-MM-DD
device "desktop" | "mobile" "desktop" Device type
gl string "US" Country GL code — search only

Authentication

The library resolves the API key in this order:

  1. apiKey option passed to the tool factory
  2. SERPHOUSE_API_KEY environment variable
// Env var (default)
const tool = search();

// Explicit key (overrides env)
const tool = search({ apiKey: "sk-..." });

API

search(options?)

import { search } from "serptool";
const tool = search();

Google web search — organic results, ads, related searches.

news(options?)

import { news } from "@serphouse/ai-sdk";
const tool = news();

Google News search — headlines, sources, publish dates.

shortVideo(options?)

import { shortVideo } from "@serphouse/ai-sdk";
const tool = shortVideo();

Google Short Videos search.

ToolOptions

type ToolOptions = { apiKey?: string };

Examples

Anthropic

import { generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { search } from "@serphouse/ai-sdk";

const { text } = await generateText({
  model: anthropic("claude-sonnet-4-20250514"),
  tools: { search: search() },
  prompt: "Search for the latest tech news.",
});

Google Gemini

import { generateText } from "ai";
import { google } from "@ai-sdk/google";
import { search } from "@serphouse/ai-sdk";

const { text } = await generateText({
  model: google("gemini-2.0-flash"),
  tools: { search: search() },
  prompt: "Search for AI startups.",
});

License

MIT