LangChain
News search for LangChain agents, in Python and JavaScript.
With langchain-exa
typesearch speaks Exa’s API, and LangChain’s Exa integration lets you set the base URL. Point it at typesearch, use a typesearch key, and every Exa tool and retriever searches our news index:
pip install langchain-exaA search tool
import os
from langchain_exa import ExaSearchResults
search = ExaSearchResults(
exa_api_key=os.environ["TYPESEARCH_API_KEY"],
exa_base_url="https://api.typesearch.ai/compat/exa",
)
search.invoke({"query": "EU AI Act enforcement", "num_results": 5})In an agent
from langchain.agents import create_agent
agent = create_agent(
model="anthropic:claude-sonnet-4-5",
tools=[search],
system_prompt="Answer with recent news. Cite the source and link of every fact.",
)
agent.invoke({"messages": [{"role": "user", "content": "What changed in EU AI Act enforcement this week?"}]})A retriever
from langchain_exa import ExaSearchRetriever
retriever = ExaSearchRetriever(
exa_api_key=os.environ["TYPESEARCH_API_KEY"],
exa_base_url="https://api.typesearch.ai/compat/exa",
k=5,
type="fast",
)
docs = retriever.invoke("EU AI Act enforcement")ExaFindSimilarResults works the same way, with our similar endpoint behind it.
What to know
- Modes.
typemaps to our modes:fast,auto,neuralandkeywordrun asfast,deepasdeep. - Page text costs extra. The Exa tools ask for the text of each result by default. On typesearch that’s a
short excerpt, never the full page, billed per page ($0.20 per 1,000 pages) on top of the search
($1.40 per 1,000 in
fast). - What isn’t supported is accepted and reported in the
X-Compat-Warningsheader instead of failing: see Migrate from Exa for every parameter. - Tone, essentials and structured answers are in the native API: see the API reference.