Python SDK for the SERPHouse search API — with first-class integrations for LangChain and LlamaIndex.
Drop live Google, Bing, and Yahoo search data into your AI agents. No boilerplate, no custom API clients — just import, configure, and let your agent search the web.
- Why SERPHouse AI SDK
- Installation
- Quick Start
- API Key
- Tools Reference
- Advanced Usage
- Development
- Contributing
- License
| Zero boilerplate | Two lines to add web search, news, or video results to any LangChain or LlamaIndex agent |
| Framework-native | Functions return standard StructuredTool / FunctionTool objects — no wrappers, no adapters |
| Live SERP data | Every call hits the SERPHouse API in real time. No cached or stale results. |
| Production-ready | Built on requests and pydantic with typed schemas, configurable timeouts, and clear error handling |
pip install serphouse-ai-sdkWith framework extras:
pip install serphouse-ai-sdk[langchain]
pip install serphouse-ai-sdk[llamaindex]
pip install serphouse-ai-sdk[all] # both frameworksSet the SERPHOUSE_API_KEY environment variable (or pass it per tool).
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)from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from serphouse.llamaindex import search, news, short_video
agent = FunctionAgent(
llm=OpenAI(model="gpt-4"),
tools=[search(), news(), short_video()],
)
response = agent.run("Latest AI news from OpenAI")
print(response)Get your key at serphouse.com and choose one of:
| Method | Example |
|---|---|
| Environment variable (recommended) | export SERPHOUSE_API_KEY=your_key_here |
| Per-tool options dict | search({"api_key": "your_key_here"}) |
| SERPHouseClient | SERPHouseClient(api_key="your_key_here") |
| Tool | Framework | Endpoint | Description |
|---|---|---|---|
search() |
LangChain, LlamaIndex | /web-search-lite |
General web search |
news() |
LangChain, LlamaIndex | /google-news |
Google News search |
short_video() |
LangChain, LlamaIndex | /google-short-videos-api |
Google Short Videos (Shorts) |
All tools accept the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
q |
str |
— | Search query (required) |
domain |
str |
google.com |
Search domain |
lang |
str |
en |
Search language code |
loc |
str |
New York,New York,United States |
Location (City,State,Country) |
device |
str |
desktop |
desktop or mobile |
page |
int |
— | Page number |
date_range |
str |
y |
h (hour), d (24h), w (week), m (month), y (year), or YYYY-MM-DD,YYYY-MM-DD |
gl |
str |
US |
Country code (ISO 3166-1 alpha-2, search only) |
video_quality |
str |
high |
Video quality (short_video only) |
from serphouse.langchain import search
tool = search({"api_key": "your-key"})Use the raw client directly for custom integrations:
from serphouse import SERPHouseClient
client = SERPHouseClient(api_key="your-key")
result = client.post("/web-search-lite", {"q": "python sdk"})
print(result)# Clone and enter the repo
git clone https://github.com/serphouse/ai-sdk.git
cd ai-sdk
# Create a virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in editable mode with all dev dependencies
pip install -e ".[test]"
# Run tests
pytest tests -v
# Run only unit tests (skip OpenAI integration tests)
pytest tests -v -k "not Integration"
# Run integration tests (requires OPENAI_API_KEY)
OPENAI_API_KEY=sk-... pytest tests -v -k "Integration"Contributions are welcome. Please keep changes focused and match existing code style.
git checkout -b feature/your-feature
pip install -e ".[test]"
# make changes
pytest tests -v
git commit -m "Add your feature"
git push origin feature/your-featureThen open a Pull Request. Update this README if you change setup or configuration.
MIT License — Copyright SERPHouse.