Valyu Logo

Tutorial

How to Integrate Web Search into Your AI (Complete 2025 Guide)

Integrate WebSearch Placeholder

TL;DR

  • Valyu’s Search API gives you live access to the web no scraping, no APIs to manage, no search engine TOS risks
  • In 3 lines of code, you can retrieve structured, real-time content and plug it directly into your LLM or agent context
  • Valyu is fully compatible with LangChain, Vercel AI SDK, or LlamaIndex

Why Web Search Matters for AI

LLMs and agent frameworks struggle with recency. Web search adds:

  • Fresh context - breaking news, market shifts, live developments
  • Dynamic grounding - reduce hallucinations, improve factual accuracy
  • Verifiable citations - retrieve source-backed evidence in real time

Common Use Cases

  • “What happened at OpenAI’s developer day yesterday?”
  • “Summarize today’s interest rate news in Europe.”
  • “Check latest funding rounds for generative AI startups.”

The Problem With Traditional Web Access

Most devs struggle to add live search because:

  • Bing API is deprecated (Azure AI Agents cost $35+ / 1K queries)
  • Google SERP scraping is brittle
  • HTML responses are unstructured
  • SEO spam dominates results

The Fast Way: Use Valyu’s Web Search API

Valyu gives you clean, fast, LLM-friendly results with zero scraping. Every result is structured JSON, ranked semantically, and filtered for relevance.

3-Line Integration

1import { Valyu } from 'valyu-js';
2
3const valyu = new Valyu({ apiKey: 'your-valyu-api-key' });
4
5const response = await valyu.search(
6 "latest news on NVIDIA AI chip production"
7);
8
9console.log(response);

Get your API key
View integration docs

Benchmarks:

SimpleQA evaluation: Valyu achieved 94% accuracy, Parallel 93%, Exa 91%, and Google 38% on straightforward factual questions.

SimpleQA evaluation: Valyu achieved 94% accuracy, Parallel 93%, Exa 91%, and Google 38% on straightforward factual questions.

FreshQA evaluation: Valyu achieved 79% accuracy, Parallel 52%, Google 39%, and Exa 24% on queries requiring up-to-date information retrieval.

FreshQA evaluation: Valyu achieved 79% accuracy, Parallel 52%, Google 39%, and Exa 24% on queries requiring up-to-date information retrieval.

Valyu is optimised for AI-native apps not for browsing, but to give your AI the context it needs.
For details on how we evaluate performance, see our Web Search Benchmark blog or browse the public benchmarks on GitHub.

Advanced Usage: Filter by Domain + Recency

Use filters to target trusted sources and fresh pages:

1const response = await valyu.search(
2 "latest US tariff news",
3 {
4 start_date="2025-06-01",
5 included_sources: ["reuters.com", "bloomberg.com", "ft.com"],
6 relevance_threshold: 0.6,
7 max_num_results: 10
8 }
9);

Live Demo

Search the live web in natural language. Filter by recency, domain, or relevance, and stream structured results directly into your AI app or RAG stack.

Best Practices for LLM-Compatible Web Search

  • Use max_num_results: 3-5 to reduce token costs
  • Deduplicate URLs before inserting into vector DBs
  • Add date_range to target current events
  • Use summarization (yours or Valyu’s) before context injection

FAQ

Q: Does Valyu scrape Google or Bing?
A: No, Valyu runs its own crawlers and ranking engine built specifically for AI workflows.

Q: How fast is your web index?
A: New pages are indexed within minutes of appearing online.

Q: Can I restrict search to specific domains?
A: Yes, use included_sources or excluded_sources in the query config.

Q: Can Valyu summarize web search results?
A: Yes, you can use Valyu’s summarization endpoint or apply your own LLM summarizer to the structured output.\

Build Live-Aware AI Agents in Minutes

Add real-time web intelligence to your AI app in 3 lines.

Get your API key
Explore Web Search docs
Integrate with LangChain