Ferret + LangChain Integration
Ferret ships LangChain-compatible tools that wrap the REST API. They turn Ferret into a drop-in search/research backend for any LangChain agent.
Tools
| Tool | Description | Endpoint |
|---|---|---|
FerretSearchTool | Multi-engine web search | GET /search |
FerretResearchTool | Deep research with aggregation + summary | POST /research |
FerretExtractTool | Extract raw content from a URL | GET /extract |
FerretCrawlTool | Crawl a URL for raw content | GET /crawl/v1 |
All tools return Tavily-compatible payloads, so existing LangChain agents built against Tavily can be migrated by swapping the tool import.
Quick start
from langchain_ferret import FerretSearchTool, FerretResearchTool
# Search
search = FerretSearchTool()
results = search.run("latest AI news")
print(results)
# Research
research = FerretResearchTool()
answer = research.run("Impact of quantum computing on cryptography")
print(answer)
Usage with a LangChain agent
from langchain.agents import initialize_agent, AgentType
from langchain_ferret import FerretSearchTool, FerretExtractTool
from langchain_openai import ChatOpenAI
tools = [FerretSearchTool(), FerretExtractTool()]
llm = ChatOpenAI(model="gpt-4")
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)
agent.run("Search for latest AI news and extract the content from the top result")
Extract and crawl
from langchain_ferret import FerretExtractTool, FerretCrawlTool
extract = FerretExtractTool()
content = extract.run("https://example.com/article")
crawl = FerretCrawlTool()
site = crawl.run("https://example.com")
Business endpoints as tools
The 17 business endpoints can be wrapped in custom tools. The /llm variants return markdown prompts ready for direct LLM injection:
import requests
from langchain.tools import BaseTool
class FerretSEOAuditTool(BaseTool):
name: str = "ferret_seo_audit"
description: str = "Run a technical SEO audit of a site. Input: domain."
def _run(self, site: str) -> str:
# The /llm variant returns an LLM-ready markdown prompt (~800 tokens)
r = requests.get(
"http://localhost:9093/seo/audit/llm",
params={"q": site},
timeout=60,
)
return r.text
async def _arun(self, site: str) -> str:
return self._run(site)
Requirements
pip install langchain requests
# Optional, for OpenAI-based agents:
pip install langchain-openai
Make sure Ferret is running on http://localhost:9093:
systemctl --user start ferret.service # REST API on :9093
See also
- API Reference — full endpoint list
- Business endpoints — the 17 cross-cutting analyses
- MCP Server — use Ferret directly from Claude Code / Cursor without LangChain