LangChain — Python Tools
Connect any LangChain agent to DPX by wrapping the oracle REST endpoints with the @tool decorator. No SDK or API key required — all pricing endpoints are public.
Installation
Section titled “Installation”pip install langchain langchain-openai httpxDefine the tools
Section titled “Define the tools”import httpxfrom langchain_core.tools import tool
STABILITY_URL = "https://stability.untitledfinancial.com"ESG_URL = "https://esg.untitledfinancial.com"
@tooldef dpx_get_quote(amount_usd: float, has_fx: bool = False, esg_score: int = 75) -> dict: """Get a binding DPX fee quote for a settlement. Returns core, FX, ESG, and license components plus a quoteId valid for 300 seconds.""" r = httpx.get(f"{STABILITY_URL}/quote", params={ "amountUsd": amount_usd, "hasFx": str(has_fx).lower(), "esgScore": esg_score }) return r.json()
@tooldef dpx_get_reliability() -> dict: """Check current peg stability and oracle health before a large settlement. Returns stability score, peg deviation, and confidence level.""" return httpx.get(f"{STABILITY_URL}/reliability").json()
@tooldef dpx_get_esg_score() -> dict: """Get live Environmental, Social, and Governance scores from the DPX ESG Oracle. Returns E, S, G sub-scores and the current ESG fee component.""" return httpx.get(f"{ESG_URL}/esg-score").json()
@tooldef dpx_get_manifest() -> dict: """Get the DPX protocol manifest — contract addresses, fee configuration, and supported capabilities.""" return httpx.get(f"{STABILITY_URL}/manifest").json()
@tooldef dpx_verify_fees() -> dict: """Verify that the current fee quote matches on-chain enforcement via the deployed smart contracts.""" return httpx.get(f"{STABILITY_URL}/verify-fees").json()
dpx_tools = [ dpx_get_quote, dpx_get_reliability, dpx_get_esg_score, dpx_get_manifest, dpx_verify_fees,]Wire into an agent
Section titled “Wire into an agent”from langchain_openai import ChatOpenAIfrom langchain.agents import create_tool_calling_agent, AgentExecutorfrom langchain_core.prompts import ChatPromptTemplate
llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_messages([ ("system", "You are a treasury intelligence assistant with access to DPX settlement pricing tools."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"),])
agent = create_tool_calling_agent(llm, dpx_tools, prompt)executor = AgentExecutor(agent=agent, tools=dpx_tools, verbose=True)
result = executor.invoke({ "input": "Price a $2M cross-border settlement with ESG score 75 and check if stability is healthy enough to proceed."})print(result["output"])Available tools
Section titled “Available tools”| Tool | Description |
|---|---|
dpx_get_quote | Full fee breakdown — core, FX, ESG, license + quoteId |
dpx_get_reliability | Stability score, peg deviation, oracle confidence |
dpx_get_esg_score | Live E, S, G scores and current ESG fee |
dpx_get_manifest | Contract addresses and protocol capabilities |
dpx_verify_fees | On-chain fee verification |
MCP adapter (recommended for Claude)
Section titled “MCP adapter (recommended for Claude)”For LangChain agents that need to call Claude or run alongside Claude Desktop, use the MCP integration instead — it gives schema updates automatically and works natively with all MCP-compatible hosts.
Environment
Section titled “Environment”STABILITY_ORACLE_URL=https://stability.untitledfinancial.comESG_ORACLE_URL=https://esg.untitledfinancial.comBoth endpoints are public. No API key required for pricing and monitoring.