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.

1from langchain_youdotcom import YouSearchTool
2
3tool = YouSearchTool()
4result = tool.invoke("latest developments in quantum computing")
5print(result)

To customize search parameters, pass them via api_wrapper:

1from langchain_youdotcom import YouSearchAPIWrapper, YouSearchTool
2
3tool = YouSearchTool(
4 api_wrapper=YouSearchAPIWrapper(
5 count=5,
6 livecrawl="web", # "web", "news", or "all"
7 freshness="day", # "day", "week", "month", or "year"
8 safesearch="moderate", # "off", "moderate", or "strict"
9 )
10)
11result = tool.invoke("AI news today")

Community Package

You.com is also available via langchain-community:

1from langchain_community.retrievers import YouRetriever
2from 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