Skip to main content

Overview

Best for: building Valyu into your product / agents. Use Valyu as a search and content tool inside LangChain (TypeScript) agents.
Viewing the TypeScript integration. For the Python version of this guide, see the Python LangChain integration.
Valyu integrates seamlessly with LangChain as a search tool, allowing you to enhance your AI agents and RAG applications with real-time web search and proprietary data sources. The integration provides LLM-ready context from multiple sources including web pages, academic journals, financial data, and more. The package includes two main tools:
  • ValyuSearchTool: Search operations with comprehensive parameter control
  • ValyuContentsTool: Extract clean content from specific URLs

Paste into your AI assistant to wire Valyu into a LangChain (TypeScript) agent.

Open in Cursor

Integration details

Installation

Install the official LangChain Valyu package and the Valyu SDK:
Configure credentials by setting the following environment variable:
Or set it programmatically:
For agent examples, you’ll also need:

Free Credits

Get your API key with $10 free credits ($20 with a work email) from the Valyu Platform.

Basic Usage

Using ValyuContentsTool for Content Extraction

Extract clean, structured content from specific URLs:

Using with LangChain Agents

The most powerful way to use Valyu is within LangChain agents, where the AI can dynamically decide when and how to search:
npm

Advanced configuration

tool.invoke() accepts:
  • query (required) - natural-language query string
  • search_type - "all", "web", or "proprietary" (use "all" when passing included_sources URLs)
  • max_num_results - 1-20 (up to 100 with a special API key)
  • relevance_threshold - 0.0-1.0
  • max_price - max cost per 1k retrievals (CPM)
  • start_date / end_date - YYYY-MM-DD
  • included_sources / excluded_sources - arrays of URLs, domains, or dataset ids
  • response_length - "short", "medium", "large", "max", or a character count
  • country_code - 2-letter ISO code (e.g. "US", "GB")
  • fast_mode - faster but shorter results
The tool returns a JSON string - parse it with JSON.parse().
Invoke with a required urls array (max 10 per request). Constructor options: summary (boolean/string/object), extract_effort ("normal", "high", "auto"), response_length ("short", "medium", "large", "max", or a number).
Bind a SystemMessage: use search_type="all" for broad coverage (web + proprietary), or "web" for current events only; raise relevance_threshold (0.6+) for precision; cite sources; use natural-language queries, not operators. See the Prompting Guide.

Additional Resources

LangChain Valyu Tool

Official LangChain Python integration documentation

API Reference

Complete Valyu API documentation

LangGraph Agents

Build advanced agent workflows

Get API Key

Sign up for $10 free credits ($20 with a work email)