Skip to main content

Official LangChain integrations for the Modexia AgentPay ecosystem.

Project description

🔗 LangChain x Modexia AgentPay

The official, enterprise-grade LangChain integration for Modexia's autonomous crypto infrastructure.

PyPI version Python versions License: MIT


Welcome to langchain-modexia, the premium provider package for AI Developers building intelligent, financially autonomous agents in Python.

This package provides native LangChain tools allowing your agents to instantly hold USDC, execute cross-chain transfers, open zero-gas micro-payment channels, and automatically negotiate HTTP paywalls without needing to handle private keys directly in the LLM context.


⚡ Installation

Install the package directly via pip. This will also automatically install the core cryptographic engine (modexiaagentpay) under the hood.

pip install langchain-modexia

🛠️ Quick Start (LangGraph / Agents)

For the absolute smoothest developer experience, we provide the ModexiaToolkit. This automatically injects the entire suite of 8+ crypto capabilities seamlessly into standard LangGraph or AgentExecutor workflows.

1. Synchronous Agents (Standard)

import os
from langchain_modexia import ModexiaToolkit
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent

# Use the API key generated from https://modexia.software
os.environ["MODEXIA_API_KEY"] = "mx_test_your_key_here_..."

# Initialize the toolkit securely
toolkit = ModexiaToolkit.from_api_key(os.environ["MODEXIA_API_KEY"])
tools = toolkit.get_tools()

# Attach tools to your favorite LLM
llm = ChatAnthropic(model="claude-3-5-sonnet-20240620")
agent_executor = create_react_agent(llm, tools)

# The Agent is ready to execute Modexia payments!
response = agent_executor.invoke({
    "messages": [("user", "Check my wallet balance and send 5 USDC to 0x123abc...")]
})
print(response["messages"][-1].content)

2. High-Concurrency Asynchronous Swarms (Async)

If you are running multi-agent swarms (e.g. ainvoke), Modexia flawlessly supports fully non-blocking I/O. Just pass async_mode=True when creating the toolkit!

import asyncio

async def main():
    # Setting async_mode=True automatically provisions the AsyncModexiaClient
    # and routes LangChain 'ainvoke' to non-blocking HTTPx calls.
    toolkit = ModexiaToolkit.from_api_key(os.environ["MODEXIA_API_KEY"], async_mode=True)
    tools = toolkit.get_tools()
    
    agent_executor = create_react_agent(llm, tools)
    
    res = await agent_executor.ainvoke({
       "messages": [("user", "Transfer 1.5 USDC to Alice on Arbitrum using CCTP")]
    })

asyncio.run(main())

🧰 Native Tools Injected

The ModexiaToolkit automatically handles schema validation for the LLM using strict Pydantic models. The following tools are injected:

  • modexia_get_balance: Checks the Agent's current usable USDC balance.
  • modexia_transfer: Sends a standard on-chain Modexia transaction to any EVM compatible address.
  • modexia_cross_chain_transfer: Routes and burns USDC natively across any blockchain using Squid Router CCTP abstraction.
  • modexia_get_history: Retrieves recent financial history for LLM context injection.
  • modexia_smart_fetch: Allows the agent to hit an external URL and automatically pay HTTP 402 Payment Required L402 invoices to acquire premium data!
  • modexia_open_channel: Opens an ongoing high-frequency payment vault.
  • modexia_consume_channel: Executes an instant, gas-free cryptographically signed micro-payment inside an open channel (perfect for sub-cent API usage).
  • modexia_settle_channel: Closes the vault and distributes funds.

🌐 JavaScript & Non-Python Environments

Are you building your LangChain App in TypeScript/Node.js, or using Claude Desktop?

Because Python agents get a dedicated native package (langchain-modexia), we recommend non-Python systems use our Model Context Protocol (MCP) server instead!

Simply install modexia-mcp and connect to it using @langchain/mcp-adapters to unlock identical functionality in JavaScript with zero custom code!


🤝 Contributing

Found a bug or want to add a feature? Open a Pull Request! This package acts as a thin LangChain abstraction over the core Modexia AgentPay Python SDK.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_modexia-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_modexia-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_modexia-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_modexia-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for langchain_modexia-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4fb44b7608a376419edbb69fb5c44ea943ed08a19c3aff5e79e369f0fdfcdb9
MD5 83c1b731248c1cfb20f3a5049ed8d148
BLAKE2b-256 efffe7ad880057a673cde83d84e3114287601c8804d6c1a2b4e3d6e151e9cc1c

See more details on using hashes here.

File details

Details for the file langchain_modexia-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_modexia-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5db872b0a14c71a4bba191001fd90d4ff871f95d81e57ce12190aec02e02c87f
MD5 ac93b1f27c2ad27888b209e354387b4b
BLAKE2b-256 8fa06b4e783ca3899abc49aa98a7c7952562754f5b7af91aca8ba65620d61093

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page