LangChain Integration
Use SERPHouse AI SDK with LangChain for live web search in AI agents.
The SERPHouse AI SDK is a Python SDK for the SERPHouse search API, built to plug live web search data directly into AI agents. It provides first-class, framework-native integrations for both LangChain and LlamaIndex.
Installation
Quick setup with a single pip command.
pip install serphouse-ai-sdk[langchain]For all frameworks:
pip install serphouse-ai-sdk[all]API Key Setup
Set your SERPHOUSE_API_KEY environment variable before using the SDK.
export SERPHOUSE_API_KEY=your_key_hereAvailable Tools
| Tool | Description | Endpoint |
|---|---|---|
search() | Google Web Search | /web-search-lite |
news() | Google News Search | /google-news |
short_video() | Google Short Videos Search | /google-short-videos-api |
Usage Example
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from serphouse.langchain import search, news, short_video
agent = create_agent(
model=ChatOpenAI(model="gpt-4"),
tools=[search(), news(), short_video()],
)
response = agent.invoke({
"messages": [{"role": "user", "content": "Latest AI news from OpenAI"}]
})
print(response["messages"][-1].content)Works with OpenAI, Anthropic Claude, and Google Gemini models.
Related Links
Last updated on
How is this guide?