LangChain integration
`langchain-brime` — 3 BaseTools and 1 BaseRetriever, drop-in for any chain or agent.
Drop Brime into LangChain agents and RAG chains. Three BaseTools and one BaseRetriever, all with sync + async parity. Backed by the official brime Python SDK — single HTTP client, single error tree.
pip install langchain-brimeQuickstart — agent with tools
from langchain.agents import create_agent
from langchain_brime import BrimeSearch, BrimeExtract, BrimeResearch
agent = create_agent(
model="anthropic:claude-3-5-haiku-latest",
tools=[BrimeSearch(), BrimeExtract(), BrimeResearch()],
system_prompt="You are a research assistant.",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What were the biggest 2025 climate-tech deals? Cite sources."}]}
)
print(result["messages"][-1].content)The LLM picks which tool to call (brime_search for quick lookups, brime_research for synthesis, etc.) based on the question.
Quickstart — retriever in a RAG chain
from langchain_brime import BrimeRetriever
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain.chat_models import init_chat_model
retriever = BrimeRetriever(k=5)
llm = init_chat_model("anthropic:claude-3-5-haiku-latest")
prompt = ChatPromptTemplate.from_template(
"Context:\n{context}\n\nQuestion: {question}\n\nAnswer with citations."
)
chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
)
print(chain.invoke("How are global EV sales tracking in 2025?").content)BrimeRetriever returns LangChain Document objects with page_content (the ranked chunk) and metadata (url, title, score, published_date, source: "brime").
Async
Every tool has _arun; the retriever has _aget_relevant_documents:
import asyncio
from langchain_brime import BrimeSearch
tool = BrimeSearch()
result = asyncio.run(tool.ainvoke({"query": "python async io"}))Reference
BrimeSearch — BaseTool
| Field | Default | Notes |
|---|---|---|
query | (required) | Natural-language query |
max_results | 5 | 1–20 |
topic | "general" | general / news / finance |
time_range | None | day / week / month / year |
The legacy depth field is still accepted but ignored — search runs a single tuned instant tier.
BrimeExtract — BaseTool
| Field | Default | Notes |
|---|---|---|
urls | (req.) | List of URLs (1–10) |
include_metadata | False | Extra metadata fields per result |
BrimeResearch — BaseTool
| Field | Default | Notes |
|---|---|---|
query | (req.) | Research question |
topic | "general" | Recency hint |
max_results | 5 | 1–20 sources per round |
Research runs a single tuned multi-round flow (~30–90 s wall-clock). The legacy depth, max_rounds, wait, deep_poll_timeout fields are still accepted but ignored.
BrimeRetriever — BaseRetriever
| Field | Default | Notes |
|---|---|---|
k | 5 | Max documents (1–20) |
topic | "general" | Recency hint |
time_range | None | Recency window |
domains | None | Domain allow-list |
exclude_domains | None | Domain deny-list |
include_answer | False | LLM answer is wasted when only retrieving |
Authentication
BrimeSearch(api_key="sk-brime-...") or set BRIME_API_KEY:
export BRIME_API_KEY="sk-brime-..."BrimeSearch() # picks up env var
BrimeSearch(api_key="...") # explicit
BrimeSearch(base_url="https://...") # staging overrideCompatibility
- Python 3.9+
langchain-core>=0.3,<2.0(works with both 0.3.x and 1.x)- Backed by
brime>=0.2.0 - Passes the official
langchain-testsToolsUnitTestscompliance suite (3 tools × 6 tests = 18 PASS)