Home/Tools/@valyu/ai-sdk

webSearch

@valyu/ai-sdk

Search the web for current information, news, and articles. The API handles natural language - use simple, clear queries.

by Valyu

search
v1.1.0
MIT

Interactive Playground

Test @valyu/ai-sdk (webSearch) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @valyu/ai-sdk
pnpm add @valyu/ai-sdk
yarn add @valyu/ai-sdk
bun add @valyu/ai-sdk
deno add npm:@valyu/ai-sdk

2. Import the tool

import { webSearch } from '@valyu/ai-sdk';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { webSearch } from '@valyu/ai-sdk';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { webSearch },
  prompt: 'Your prompt here...',
});

console.log(result.text);

AI Agent Integration

How AI agents can use this tool

Use Case

Use for general web search and current information

Examples

  • Find latest news
  • Search for current events

Signature

(query: string, excludedSources?: string[], includedSources?: string[]) => Promise<unknown>

Tags

ai
ai-sdk
api
articles
biomedical
current
finance
handles
information
language
natural
news
patents
research
sdk
search
sec-filings
valyu
vercel
web

Parameters

Available configuration options

Auto-extracted
query
Required
Type: string

Natural language query (e.g., 'latest AI developments', 'Tesla Q4 2024 earnings')

includedSources
Optional
Type: array

Restrict search to specific domains or sources (e.g., ['nature.com', 'arxiv.org']). Cannot be used with excludedSources.

excludedSources
Optional
Type: array

Exclude specific domains or sources from results (e.g., ['reddit.com', 'quora.com']). Cannot be used with includedSources.

Schema extracted: 3/1/2026, 4:29:47 AM

README

@valyu/ai-sdk

AI SDK tools for Valyu search API, compatible with Vercel AI SDK v5 and v6.

Installation

npm install @valyu/ai-sdk

Quick Start

Get started with web search in seconds:



import { webSearch } from "@valyu/ai-sdk"; 
import { openai } from "@ai-sdk/openai";
// Available specialised search tools: financeSearch, paperSearch, 
// bioSearch, patentSearch, secSearch, economicsSearch, companyResearch

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Latest data center projects for AI inference workloads?',
  tools: {
    webSearch: webSearch(),
  },
});

console.log(text);

That's it! Get your free API key from the Valyu Platform - $10 in free credits when you sign up.

Need Specialized Search?

Beyond general web search, Valyu provides domain-specific tools for specialized research where you can plug directly into:

  • financeSearch - Stock prices, earnings, insider transactions, dividends, balance sheets, income statements, and more
  • paperSearch - Full-text search of PubMed, arXiv, bioRxiv, medRxiv, and other scholarly articles
  • bioSearch - Clinical trials, FDA drug labels, peer-reviewed biomedical research, PubMed, medRxiv, bioRxiv
  • patentSearch - USPTO full-text patent search and related intellectual property
  • secSearch - SEC filings including 10-K, 10-Q, 8-K, and regulatory disclosures
  • economicsSearch - Economic indicators from BLS, FRED, World Bank, USAspending, and more
  • companyResearch - Comprehensive company research and intelligence reports

Or create your own custom search tool using the same API!

Table of Contents

Setup

  1. Get your API key from the Valyu Platform
  2. Add it to your .env file:
VALYU_API_KEY=your-api-key-here

That's it! The package reads it automatically.

Available Tools

webSearch

Search the web for current information, news, articles, and general content.

import { generateText, stepCountIs } from "ai";
import { webSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Latest data center projects for AI inference workloads?',
  tools: {
    webSearch: webSearch(),
  },
  stopWhen: stepCountIs(3),
});

Best for: Real-time information, news, current events, general web content

financeSearch

Search financial data including stock prices, market data, earnings reports, and financial metrics.

import { generateText, stepCountIs } from "ai";
import { financeSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'What was the stock price of Apple from the beginning of 2020 to 14th feb?',
  tools: {
    financeSearch: financeSearch(),
  },
  stopWhen: stepCountIs(10),
});

Best for: Stock prices, earnings reports, financial statements, market data, economic indicators

paperSearch

Search academic research papers, scholarly articles, and textbooks across all disciplines.

import { generateText, stepCountIs } from "ai";
import { paperSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Psilocybin effects on cellular lifespan and longevity in mice?',
  tools: {
    paperSearch: paperSearch(),
  },
  stopWhen: stepCountIs(10),
});

Best for: Academic research, scientific papers, scholarly articles, arXiv papers

bioSearch

Search biomedical literature including PubMed articles, clinical trials, and FDA drug information.

import { generateText, stepCountIs } from "ai";
import { bioSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Summarise top completed Phase 3 metastatic melanoma trial comparing nivolumab+ipilimumab vs monotherapy',
  tools: {
    bioSearch: bioSearch(),
  },
  stopWhen: stepCountIs(10),
});

Best for: Medical research, clinical trials, drug information, disease studies, FDA labels

patentSearch

Search patent databases for inventions, innovations, and intellectual property.

import { generateText, stepCountIs } from "ai";
import { patentSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Find patents published in 2025 for high energy laser weapon systems',
  tools: {
    patentSearch: patentSearch({ maxNumResults: 2 }),
  },
  stopWhen: stepCountIs(10),
});

Best for: Patent information, prior art, inventions, intellectual property

secSearch

Search SEC filings including 10-K, 10-Q, 8-K, and other regulatory documents.

import { generateText, stepCountIs } from "ai";
import { secSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Summarise MD&A section of Tesla\'s latest 10-k filling',
  tools: {
    secSearch: secSearch(),
  },
  stopWhen: stepCountIs(10),
});

Best for: SEC filings, annual reports, quarterly reports, proxy statements, regulatory disclosures

economicsSearch

Search economic data including labor statistics, Federal Reserve data, World Bank indicators, and US federal spending.

import { generateText, stepCountIs } from "ai";
import { economicsSearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'What is CPI vs unemployment since 2020 in the US?',
  tools: {
    economicsSearch: economicsSearch(),
  },
  stopWhen: stepCountIs(10),
});

Best for: Labor statistics (BLS), Federal Reserve economic data (FRED), World Bank indicators, unemployment rates, GDP, inflation, government spending

companyResearch

Generate comprehensive company intelligence reports with business overview, financials, SEC filings, news, insider activity, and citations.

import { generateText, stepCountIs } from "ai";
import { companyResearch } from "@valyu/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5'),
  prompt: 'Research the company nia AI',
  tools: {
    companyResearch: companyResearch(),
  },
  stopWhen: stepCountIs(5),
});

Best for: In-depth company research, due diligence, competitive intelligence, investment research. Automatically gathers data in parallel from multiple sources and synthesizes into a structured markdown report. Supports optional section filtering (summary, leadership, products, funding, competitors, filings, financials, news, insiders).

Note: This tool automatically detects whether the company is public or private. For public companies, it returns information from SEC filings, financial statements, and other disclosures. For private companies, it pulls available data from news, funding, and other public sources.

Create Your Own Tool

Want to build a custom search tool? Use the Valyu DeepSearch API directly with the Vercel AI SDK tool() function:

import { tool } from "ai";
import { z } from "zod";

export function myCustomSearch(config = {}) {
  const apiKey = config.apiKey || process.env.VALYU_API_KEY;

  return tool({
    description: "Search for [your specific domain/use case]",
    inputSchema: z.object({
      query: z.string().describe("The search query"),
    }),
    execute: async ({ query }) => {
      const response = await fetch("https://api.valyu.ai/v1/deepsearch", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": apiKey,
        },
        body: JSON.stringify({
          query,
          max_num_results: 5,
          search_type: "all", // or "web", "proprietary"
          included_sources: ["your-custom-sources"], // optional
          // Add more parameters as needed
        }),
      });


      // Optionally filter api response

      const data = await response.json();
      return data;
    },
  });
}

Check out the Valyu API Documentation for all available parameters and data sources.

Links

License

MIT


Built with Valyu's API - Powering AI agents with state-of-the-art search capabilities.

Statistics

Downloads/month

2,297

GitHub Stars

0

Quality Score

87%

Bundle Size

NPM Keywords

valyu
search
ai-sdk
vercel
web-search
finance
research
biomedical
patents
sec-filings
ai
tools

Maintainers

yorkeccakk(harvey@valyu.network)

Frameworks

vercel-ai