Skip to main content

🔗 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.

Metadata

Release files for langchain-modexia 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-modexia 0.1.1
File Size Uploaded Provenance Actions
langchain_modexia-0.1.1.tar.gz 7.7 kB Without provenance Details for langchain_modexia-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-modexia 0.1.1
File Interpreter ABI Platform Actions
langchain_modexia-0.1.1-py3-none-any.whl Python 3 none any Details for langchain_modexia-0.1.1-py3-none-any.whl

Total release size: 14.5 kB

Release files / langchain_modexia-0.1.1.tar.gz

Download URL langchain_modexia-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
62407aae6188a98c7c415cfcf8e978fd71da0f76e6e4e8254a4624aafc9ccd5f
BLAKE2b-256 checksum
How to use checksums
037c32b614b10c78afdd3f417eeb932b066bf330103b3ab979bdef43c790f94e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / langchain_modexia-0.1.1-py3-none-any.whl

Download URL langchain_modexia-0.1.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9eb59016b29770b046a9f05c8f10bb1534a1bbd491a786c97af052b779ebfb97
BLAKE2b-256 checksum
How to use checksums
32a830924ec6c1e3b46d1d6048131efdcb313d1a5b397e3e946194b3c9b18e35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for langchain-modexia 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page