Plug ThreatRecall into LangChain as a drop-in memory retriever. Works with LangChain.js, LangChain Python, and any framework built on top of them — including CrewAI.
npm install langchain or pip install langchain)Install the ThreatRecall LangChain adapter in your project.
npm install @threatrecall/langchain-adapter
Configure the retriever with your API key and workspace URL. Drop this into any LangChain chain.
const { ThreatRecallMemoryRetriever } = require('@threatrecall/langchain-adapter');
const retriever = new ThreatRecallMemoryRetriever({
apiKey: process.env.THREATRECALL_API_KEY,
workspaceUrl: process.env.THREATRECALL_URL || 'https://app.threatrecall.ai',
topK: 5, // return top 5 results per query
minConfidence: 0.3, // skip low-confidence results
});
Wire the retriever into a LangChain agent. The agent will call ThreatRecall automatically when it needs CTI context.
const { ChatOpenAI } = require('langchain/chat_models');
const { RetrieverQAChain } = require('langchain/chains');
const { PromptTemplate } = require('langchain/prompts');
const model = new ChatOpenAI({ temperature: 0 });
const chain = RetrieverQAChain.fromLLMAndRetriever(
model,
retriever,
{
prompt: PromptTemplate.fromTemplate(
`Use ThreatRecall to answer the user's question. Context: {context}`
),
}
);
// Run a query — the agent will retrieve relevant CTI from ThreatRecall
const result = await chain.call({
query: "Show me all threat actors known to exploit CVE-2021-44228"
});
console.log(result.text);
Run a query that should return results from your ThreatRecall workspace.
# Set your API key first # Linux/macOS: export THREATRECALL_API_KEY="your_key_here" # Run your agent script node agent.js
The adapter also works with LangChain Python. If you're using CrewAI, you can pass the retriever as the memory component:
from threatrecall_langchain import ThreatRecallMemoryRetriever retriever = ThreatRecallMemoryRetriever( api_key="your_api_key", workspace_url="https://app.threatrecall.ai", top_k=5, )
For CrewAI, pass this retriever to your agent's memory parameter. See the CrewAI guide for the full example.
node_modules/@threatrecall/langchain-adapter exists. Run npm install in your project root.
THREATRECALL_API_KEY environment variable before running your script. Do not hard-code the key in your source code — use process.env.THREATRECALL_API_KEY.