Skip to navigation

LangChain

View as MarkdownOpen in Claude

LangChain is one of the most popular frameworks for building LLM-powered applications. By connecting You.com’s search and content APIs to LangChain, you can ground your agents and RAG pipelines in real-time, accurate web data instead of relying on static training knowledge alone.

The langchain-youdotcom package provides three integration points: a search tool (YouSearchTool), a content extraction tool (YouContentsTool), and a retriever (YouRetriever). Drop them into any LangChain agent or chain to give it live web access.


Getting Started

1

Install the Package

pip install -U langchain-youdotcom
2

Set Your API Key

export YDC_API_KEY="<YDC_API_KEY>"

Get your API key at you.com/platform.


Usage

YouSearchTool wraps the You.com Web Search API as a LangChain tool, making it available to any agent that uses tools.

from langchain_youdotcom import YouSearchTool
tool = YouSearchTool()
result = tool.invoke("latest developments in quantum computing")
print(result)

To customize search parameters, pass them via api_wrapper:

from langchain_youdotcom import YouSearchAPIWrapper, YouSearchTool
tool = YouSearchTool(
api_wrapper=YouSearchAPIWrapper(
count=5,
livecrawl="web", # "web", "news", or "all"
freshness="day", # "day", "week", "month", or "year"
safesearch="moderate", # "off", "moderate", or "strict"
)
)
result = tool.invoke("AI news today")

Community Package

You.com is also available via langchain-community:

from langchain_community.retrievers import YouRetriever
from langchain_community.tools.you import YouSearchTool

The standalone langchain-youdotcom package is recommended for new projects as it stays up to date with the latest You.com API features.


Resources