ParallelSearchRetriever()LangChain retriever that returns Parallel Search results as Documents.
Drops in to any RAG pipeline that expects a BaseRetriever. Each
Document.page_content is the joined excerpt list from one Parallel
result; metadata carries url, title, publish_date, search_id,
the original excerpts list, and the query that produced it.
Setup:
Install langchain-parallel and set environment variable
PARALLEL_API_KEY.
Key init args:
api_key: Optional[SecretStr]
Parallel API key. Reads PARALLEL_API_KEY if not provided.
base_url: str
Defaults to "https://api.parallel.ai".
max_results: int
Maximum results returned per query. 1-40 (default 5).
mode: Optional[Literal["basic", "advanced"]]
Search mode; defaults to the API default ("advanced").
objective: Optional[str]
Objective forwarded to the Search API on every call. Useful
when the same retriever is used for a focused research task
and the LangChain query is just one of several keyword forms.
excerpts: Optional[ExcerptSettings]
Per-result excerpt-size cap.
max_chars_total: Optional[int]
Cap on total excerpt characters across all results.
source_policy: Optional[SourcePolicy | dict]
Domain include/exclude lists and freshness floor.
fetch_policy: Optional[FetchPolicy]
Cache vs live-fetch policy.
location: Optional[str]
ISO 3166-1 alpha-2 country code for geo-targeting.
client_model: Optional[str]
Identifier of the calling LLM (e.g. "claude-opus-4-7").
Instantiation and use:
from langchain_parallel import ParallelSearchRetriever
retriever = ParallelSearchRetriever(max_results=5, mode="advanced")
docs = retriever.invoke("What's new in renewable energy this month?")
for doc in docs:
print(doc.metadata["title"], doc.metadata["url"])