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 (Python) agent.
import osfrom langchain_valyu import ValyuSearchTool# Set your API keyos.environ["VALYU_API_KEY"] = "your-api-key-here"# Initialize the search tooltool = ValyuSearchTool()# Perform a searchsearch_results = tool._run( query="What are agentic search-enhanced large reasoning models?", search_type="all", # "all", "web", or "proprietary" max_num_results=5, relevance_threshold=0.5, max_price=30.0)print("Search Results:", search_results.results)
results = tool._run( query="quantum computing breakthroughs 2024", max_num_results=10, # 1-20 (up to 100 with a special API key) relevance_threshold=0.6, # 0.0-1.0 max_price=30.0, # max cost per 1k retrievals (CPM) start_date="2024-01-01", # YYYY-MM-DD end_date="2024-12-31", included_sources=["valyu/valyu-arxiv", "valyu/valyu-pubmed"], excluded_sources=["example.com"], response_length="medium", # "short", "medium", "large", "max", or int country_code="US", # 2-letter ISO code fast_mode=False, # faster but shorter results)
ValyuContentsTool takes a single required urls argument (max 10 per request).
Steer the agent with a system message
Bind a SystemMessage to guide tool selection. Use search_type="all" for broad coverage (web + proprietary), or "web" for current events only; raise relevance_threshold (0.6+) for precise results; cite sources; and use natural-language queries, not operators.See the Prompting Guide for full guidelines.