Inter-Agent Transfer Protocol (IATP) - Enable AI Agents to utilize other AI Agents as tools
Project description
IATP-D402: Inter-Agent Transfer Protocol with Payment Support
IATP-D402 enables AI agents and APIs to charge for their services using the D402 payment protocol (HTTP 402 Payment Required). Build payment-enabled:
- ๐ APIs and web servers
- ๐ง MCP (Model Context Protocol) servers
- ๐ค A2A utility agents
- ๐ค CrewAI tools and agents
๐ Quick Start
Installation
pip install traia-iatp
Add D402 to Your FastAPI Server (5 lines)
from fastapi import FastAPI
from traia_iatp.d402.servers.fastapi import D402FastAPIMiddleware
from traia_iatp.d402.price_builder import D402PriceBuilder
app = FastAPI()
# Add D402 (5 lines)
price_builder = D402PriceBuilder(network="sepolia")
d402 = D402FastAPIMiddleware(server_address="0x...", facilitator_url="https://test-facilitator.d402.net")
price = price_builder.create_price(0.01) # $0.01 USD
d402.register_endpoint("/api/analyze", price_wei=price.amount, token_address=price.asset.address, network="sepolia", description="Analysis")
d402.add_to_app(app)
# Your endpoint (unchanged!)
@app.post("/api/analyze")
async def analyze(request: Request):
return {"result": "done"}
Call D402-Protected Servers (2 lines)
from traia_iatp.d402.clients.httpx import d402HttpxClient
from eth_account import Account
async with d402HttpxClient(
operator_account=Account.from_key("0x..."),
wallet_address="0x...",
max_value=100000,
base_url="http://localhost:8000"
) as client:
# Payment automatic!
response = await client.post("/api/analyze", json={"text": "test"})
๐ Documentation
Full documentation: docs.d402.net
Quick Links
- Complete Examples - Step-by-step integration examples (0-6)
- Server Integration - Add D402 to existing servers
- Client Integration - Call D402-protected APIs
- MCP Servers - Build payment-enabled MCP servers
- Utility Agents - Build A2A utility agents
- CrewAI Integration - Use D402 tools in CrewAI
Complete Integration Examples
The examples section provides complete, working code for:
- Wallet Creation & Funding - Setup wallets, get testnet USDC
- Existing Server โ D402 - Add payments to your API (before/after)
- Calling D402 Servers - Build payment-enabled client
- API โ MCP Server - Convert REST to MCP tools
- CrewAI + MCP - Use MCP server in crews
- MCP โ Utility Agent - Wrap MCP as A2A agent
- CrewAI + Utility Agent - Use agents in crews
๐ Key Features
D402 Payment Protocol
- โ HTTP 402 Payment Required - Standard payment protocol
- โ EIP-712 Signatures - Secure payment authorization
- โ On-Chain Settlement - Smart contract-based settlements
- โ Hosted Facilitators - No infrastructure setup required
Server Integration
- โ
FastAPI -
D402FastAPIMiddleware - โ
Starlette -
D402PaymentMiddleware - โ
Any ASGI Framework -
D402ASGIWrapper(Flask, Django, Quart, etc.) - โ 5-line integration - Minimal code changes
Client Integration
- โ
HTTPX (Async) -
d402HttpxClientwith automatic payment - โ Requests (Sync) - Wrapper for synchronous apps
- โ 2-line integration - Just make requests normally
MCP & A2A
- โ MCP Servers - Payment-enabled tool servers
- โ Utility Agents - A2A protocol with D402
- โ CrewAI Integration - A2AToolkit for paid tools
- โ Template Generation - Auto-generate server code
๐ง What's in the Package
Core Components (IN pip package)
src/traia_iatp/
โโโ d402/ # D402 payment protocol
โ โโโ servers/ # Server middleware (FastAPI, Starlette, MCP)
โ โโโ clients/ # Client libraries (HTTPX, base client)
โ โโโ asgi_wrapper.py # Universal ASGI wrapper
โ โโโ price_builder.py # USD-based pricing
โ โโโ facilitator.py # Facilitator client
โ
โโโ mcp/ # MCP server templates & tools
โโโ server/ # Utility agent templates
โโโ client/ # A2A client & CrewAI tools
โโโ contracts/ # Smart contract integration
โโโ registry/ # Agent discovery & search
Examples (NOT in pip package)
examples/ # Integration examples
โโโ servers/ # FastAPI, Starlette, ASGI examples
โโโ clients/ # HTTPX, Requests examples
Documentation (NOT in pip package)
docs/ # GitBook documentation
โโโ getting-started/ # Installation, quick start
โโโ examples/ # Complete integration examples (0-6)
โโโ wallet-setup/ # Wallet creation & CLI
โโโ d402-servers/ # Server integration guides
โโโ d402-clients/ # Client integration guides
โโโ mcp-servers/ # MCP server guides
โโโ utility-agents/ # Utility agent guides
โโโ crewai-integration/ # CrewAI guides
๐ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โ (API / MCP Server / Utility Agent / CrewAI Crew) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ IATP-D402 Framework โ
โ โข Server Middleware โข Client Libraries โข Templates โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ D402 Payment Protocol โ
โ โข HTTP 402 โข EIP-712 Signing โข Facilitator Service โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Smart Contracts (On-Chain) โ
โ โข IATPWallet โข Settlement โข Tokens โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Facilitators (No Setup Required)
You don't need to run your own facilitator!
- All Testnets:
https://test-facilitator.d402.net(currently: Sepolia) - All Mainnets:
https://facilitator.d402.net(currently: Arbitrum)
See Facilitator URLs for details.
๐ Wallet Creation
# Create IATP wallet (owner creates their own wallet)
traia-iatp create-iatp-wallet \
--owner-key 0x... \
--create-operator \
--wallet-name "My Server" \
--wallet-type MCP_SERVER \
--network sepolia
See Creating Wallets for complete guide.
๐ฆ Use Cases
1. Monetize Your API
# Add payment to any endpoint
d402.register_endpoint("/api/analyze", price_usd=0.01)
2. Build Payment-Enabled MCP Servers
@mcp.tool()
@require_payment_for_tool(price=price_builder.create_price(0.01))
def analyze(text: str) -> dict:
return analyze_sentiment(text)
3. Use Paid Tools in CrewAI
toolkit = A2AToolkit.create_from_endpoint(
endpoint="http://localhost:9001",
payment_private_key="0x...",
wallet_address="0x...",
max_payment_usd=1.0
)
agent = Agent(role="Analyst", tools=toolkit.tools)
๐ CLI Commands
# Create IATP wallet
traia-iatp create-iatp-wallet --owner-key 0x... --create-operator
# Create utility agency from MCP server
traia-iatp create-agency --name "My Agent" --mcp-name "Trading MCP"
# List available agencies
traia-iatp list-agencies
# Search for tools
traia-iatp find-tools --query "sentiment analysis"
๐ Links
- Documentation: docs.d402.net
- PyPI: pypi.org/project/traia-iatp
- GitHub: github.com/Traia-IO/IATP
- Examples: docs/examples/
๐ License
MIT License - see LICENSE file for details.
๐ค Support
- ๐ Documentation: docs.d402.net
- ๐ Issues: GitHub Issues
- ๐ฌ Website: traia.io
- ๐ง Email: support@traia.io
Made with โค๏ธ by the Traia Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traia_iatp-0.1.108.tar.gz.
File metadata
- Download URL: traia_iatp-0.1.108.tar.gz
- Upload date:
- Size: 268.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add6f93cc43c684596ce91fc46ce449fb498a80396866a8dc7e5927d86468117
|
|
| MD5 |
9d67f2dcb5a8dadb6b2942063edfca99
|
|
| BLAKE2b-256 |
8dcebde5e308101b554f1db514ab464a5661d10423a5856973632bad187c925d
|
File details
Details for the file traia_iatp-0.1.108-py3-none-any.whl.
File metadata
- Download URL: traia_iatp-0.1.108-py3-none-any.whl
- Upload date:
- Size: 320.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0ed58344f6ee96faf7f6e846c63c5ffe4f3b852222791dd8560cfe20808705d
|
|
| MD5 |
95143905abeee9ca6c47367a3bf4b461
|
|
| BLAKE2b-256 |
1abe5664033b51c502d89e2126f6ad005f0a87c7a10b5f54f0e92dae13c9a967
|