brime

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-brime

GitHub →

Quickstart — 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

FieldDefaultNotes
query(required)Natural-language query
max_results51–20
topic"general"general / news / finance
time_rangeNoneday / week / month / year

The legacy depth field is still accepted but ignored — search runs a single tuned instant tier.

BrimeExtract — BaseTool

FieldDefaultNotes
urls(req.)List of URLs (1–10)
include_metadataFalseExtra metadata fields per result

BrimeResearch — BaseTool

FieldDefaultNotes
query(req.)Research question
topic"general"Recency hint
max_results51–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

FieldDefaultNotes
k5Max documents (1–20)
topic"general"Recency hint
time_rangeNoneRecency window
domainsNoneDomain allow-list
exclude_domainsNoneDomain deny-list
include_answerFalseLLM 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 override

Compatibility

  • 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-tests ToolsUnitTests compliance suite (3 tools × 6 tests = 18 PASS)