LangChain
LangChain Tools (langchain-cerebrus-pulse)
Section titled “LangChain Tools (langchain-cerebrus-pulse)”langchain-cerebrus-pulse turns every Cerebrus Pulse
endpoint into a LangChain tool. The tools share one cerebrus-pulse client: give it a
wallet key and paid tools pay automatically, all under the same spend limits.
Install
Section titled “Install”pip install "langchain-cerebrus-pulse>=0.4.0" # tools; paid ones report the price instead of payingpip install "langchain-cerebrus-pulse[pay]>=0.4.0" # + automatic payment in USDC on Basepip install "langchain-cerebrus-pulse[svm]>=0.4.0" # + automatic payment in USDC on Solana tooKeep the >=0.4.0: without it pip can settle on an older release, which has no pay or svm extra.
Quick start
Section titled “Quick start”import osfrom cerebrus_pulse import CerebrusPulsefrom langchain_cerebrus_pulse import ( CerebrusListCoinsTool, CerebrusPulseTool, CerebrusScreenerTool, CerebrusLiquidationsTool, CerebrusFundingTool, CerebrusBundleTool,)
# A dedicated, low-balance Base wallet holding a little USDC. Omit wallet_key# and paid tools return the price and payee instead of data.client = CerebrusPulse( wallet_key=os.environ["CEREBRUS_WALLET_KEY"], max_payment_usd="0.10", # most one call may cost max_spend_usd="1.00", # most this client may spend in total)
tools = [ tool(client=client) for tool in ( CerebrusListCoinsTool, CerebrusPulseTool, CerebrusScreenerTool, CerebrusLiquidationsTool, CerebrusFundingTool, CerebrusBundleTool, )]With an agent
Section titled “With an agent”from langchain.agents import create_agent
agent = create_agent( "openai:gpt-4o", # any chat model that supports tool calling tools=tools, system_prompt="You answer questions about Hyperliquid markets with Cerebrus Pulse data.",)
result = agent.invoke({ "messages": [{"role": "user", "content": "Where are the modelled BTC liquidation clusters?"}]})print(result["messages"][-1].content)print(f"Spent: ${client.spent_usd}")When a paid tool cannot pay, it returns JSON the model can read:
{"error": ..., "payment_required": true, "price_usd": "...", "payment_terms": [...]}. A refusal by the spend
limits adds a reason, and nothing is signed.
Each paid tool costs what its endpoint costs; see the endpoint table.
| Tool | Endpoint |
|---|---|
CerebrusListCoinsTool | GET /coins (free) |
CerebrusPulseTool | GET /pulse/{coin} |
CerebrusScreenerTool | GET /screener |
CerebrusLiquidationsTool | GET /liquidations/{coin} |
CerebrusStressTool | GET /arb |
CerebrusCexDexTool | GET /cex-dex/{token} |
CerebrusBasisTool | GET /basis/{coin} |
CerebrusDepegTool | GET /depeg |
CerebrusSentimentTool | GET /sentiment |
CerebrusFundingTool | GET /funding/{coin} |
CerebrusOITool | GET /oi/{coin} |
CerebrusSpreadTool | GET /spread/{coin} |
CerebrusCorrelationTool | GET /correlation |
CerebrusBundleTool | GET /bundle/{coin} |
The spend limits also read CEREBRUS_MAX_PAYMENT_USD, CEREBRUS_MAX_SPEND_USD and CEREBRUS_ALLOWED_PAYTO;
see the Python client.