@cryptyx/langchain-tools
v0.1.1
Published
LangChain tool wrappers for the CRYPTYX x402 API. Drop-in DynamicStructuredTool instances that any LangChain agent can bind — signals, factor scores, institutional trigger evaluation, natural-language query. Payment plumbing handled via @cryptyx/x402-clie
Maintainers
Readme
@cryptyx/langchain-tools
LangChain DynamicStructuredTool wrappers over the CRYPTYX x402 API. Bind institutional-grade crypto conviction to any LangChain agent in three lines.
npm install @cryptyx/langchain-tools @cryptyx/x402-client @cryptyx/tool-schemas @langchain/coreQuickstart
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { Cryptyx } from '@cryptyx/x402-client';
import { cryptyxTools } from '@cryptyx/langchain-tools';
const cx = new Cryptyx({
wallet: process.env.WALLET_PRIVATE_KEY!,
network: 'base',
maxSpend: 2.0,
onPay: (r) => console.log(`Paid $${r.priceUsd} → ${r.route}`),
});
const tools = cryptyxTools(cx); // 15 LangChain tools ready
const prompt = ChatPromptTemplate.fromMessages([
['system', 'You are a crypto quant analyst. Use CRYPTYX tools to ground every claim in institutional evidence. Never recommend a trade without walk-forward-validated Sharpe > 0.3.'],
['placeholder', '{chat_history}'],
['human', '{input}'],
['placeholder', '{agent_scratchpad}'],
]);
const llm = new ChatOpenAI({ model: 'gpt-4o' });
const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });
const result = await executor.invoke({
input: 'What is the strongest institutional-grade trigger firing on BTC or ETH right now, and should I act on it?',
});
console.log(result.output);Tool coverage
15 tools covering the canonical agent workflow. See @cryptyx/tool-schemas for the full catalog.
Narrow toolbelts
Bind only the tools you need:
import { cryptyxTool } from '@cryptyx/langchain-tools';
const tools = [
cryptyxTool(cx, 'get_agent_context'),
cryptyxTool(cx, 'get_trigger_preset'),
cryptyxTool(cx, 'get_asset_thesis'),
].filter(Boolean);License
MIT.
