| name | langchain-exa |
| description | LangChain Exa integration — semantic web search with ExaSearchRetriever (RAG), ExaSearchResults (agent tool), and ExaFindSimilarResults (find similar URLs). Unique features: use_autoprompt (LLM query rewriting), highlights (excerpts), summary (per-result LLM summaries), livecrawl (real-time), and date filtering. |
LangChain Exa Skill
Expert assistance for langchain-exa: Exa's neural/semantic web search as a LangChain retriever and agent tools.
Install: pip install -U langchain-exa
Setup: export EXA_API_KEY=your_api_key
API: https://exa.ai
Reference: references/api.md (500 KB — full API reference).
When to Use This Skill
Activate when:
- Semantic web search for RAG — using
ExaSearchRetriever to retrieve live web results as documents
- Search as an agent tool — using
ExaSearchResults for tool-calling in a ReAct agent
- Finding similar content — using
ExaFindSimilarResults to find pages similar to a URL
- Getting per-result summaries — setting
summary=True for LLM-generated page summaries
- Getting highlighted excerpts — setting
highlights=True for relevant snippets from each page
- Real-time crawling — setting
livecrawl="always" to bypass index and crawl live
- LLM query rewriting — setting
use_autoprompt=True for Exa to optimize the query
- Filtering by domain — using
include_domains or exclude_domains
- Filtering by date — using
start_published_date, end_published_date, start_crawl_date, end_crawl_date
- Choosing search type — setting
type="neural", "keyword", or "auto"
Quick Reference
ExaSearchRetriever — semantic search for RAG
from langchain_exa import ExaSearchRetriever
retriever = ExaSearchRetriever(
k=5,
use_autoprompt=True,
type="neural",
highlights=True,
summary=True,
livecrawl="always",
)
docs = retriever.invoke("How does LangGraph handle state persistence?")
for doc in docs:
print(doc.page_content[:300])
print(doc.metadata)
Filter by domain and date
from langchain_exa import ExaSearchRetriever
retriever = ExaSearchRetriever(
k=3,
include_domains=["arxiv.org", "github.com"],
start_published_date="2024-01-01",
end_published_date="2026-01-01",
use_autoprompt=True,
)
docs = retriever.invoke("LLM agent memory architectures")
ExaSearchResults — search as an agent tool
from langchain_exa import ExaSearchResults
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
search_tool = ExaSearchResults()
result = search_tool.invoke({
"query": "latest LangChain releases 2026",
"num_results": 3,
})
print(result)
agent = create_react_agent(
ChatOpenAI(model="gpt-4o-mini"),
tools=[search_tool],
)
response = agent.invoke({"messages": [("human", "What happened in AI this week?")]})
ExaFindSimilarResults — find similar URLs
from langchain_exa import ExaFindSimilarResults
find_similar = ExaFindSimilarResults()
result = find_similar.invoke({
"url": "https://blog.langchain.dev/langgraph/",
"num_results": 5,
})
print(result)
Use in a RAG chain
from langchain_exa import ExaSearchRetriever
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI
from langchain_core.runnables import RunnablePassthrough
retriever = ExaSearchRetriever(
k=3,
use_autoprompt=True,
summary=True,
)
llm = ChatOpenAI(model="gpt-4o-mini")
prompt = ChatPromptTemplate.from_template("""
Answer based on the following web search results:
{context}
Question: {question}
""")
def format_docs(docs):
return "\n\n".join(
f"**{doc.metadata.get('title', 'Untitled')}**\n{doc.page_content}"
for doc in docs
)
chain = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
answer = chain.invoke("What are the latest LangGraph features?")
print(answer)
Combine ExaSearchResults with other tools
from langchain_exa import ExaSearchResults, ExaFindSimilarResults
from langchain_community.tools import WikipediaQueryRun
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
tools = [
ExaSearchResults(),
ExaFindSimilarResults(),
WikipediaQueryRun(),
]
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools=tools)
API Reference
ExaSearchRetriever key parameters
| Param | Type | Default | Description |
|---|
k | int | 10 | Number of results to return |
type | str | "neural" | Search type: "neural", "keyword", or "auto" |
use_autoprompt | bool | False | Exa rewrites the query using its own LLM |
highlights | bool | False | Return relevant text excerpts from each page |
summary | bool | False | Return LLM-generated summary of each page |
livecrawl | str | "never" | "always", "fallback" (if not indexed), "never" |
include_domains | list[str] | None | Only return results from these domains |
exclude_domains | list[str] | None | Never return results from these domains |
start_published_date | str | None | ISO date: only pages published after this |
end_published_date | str | None | ISO date: only pages published before this |
start_crawl_date | str | None | ISO date: only pages crawled after this |
end_crawl_date | str | None | ISO date: only pages crawled before this |
exa_api_key | str | None | API key (or EXA_API_KEY env) |
Search result fields
Each result includes: url, id, title, score, published_date, author, text, highlights, highlight_scores, summary
Exa vs other search tools
| Feature | Exa | Perplexity | SerpAPI |
|---|
| Search type | Semantic + keyword | Web search | Google |
find_similar | ✅ | ❌ | ❌ |
| Per-result summaries | ✅ | ❌ | ❌ |
| Highlights/excerpts | ✅ | ❌ | Limited |
livecrawl | ✅ | Implicit | ❌ |
| Domain filtering | ✅ | ❌ | ❌ |
| Date filtering | ✅ | Limited | ❌ |
Reference Files
| File | Size | Contents |
|---|
references/api.md | 500 KB | Full API reference |
references/llms.md | 28 KB | Doc index |
references/llms-full.md | 500 KB | Complete page content |
Source: https://reference.langchain.com/python/langchain-exa
API key: https://exa.ai
GitHub: https://github.com/langchain-ai/langchain/tree/main/libs/partners/exa