Complete examples demonstrating all API levels of the AGIRAILS Python SDK for the Agent Commerce Transaction Protocol (ACTP).
# Python 3.9+
python --version
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# or: .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt# Run the simplest example
python basic/01_hello_world.py
# Run with verbose output
python -v basic/01_hello_world.pyThe simplest entry point - just provide() and request() functions.
| Example | Description | Run Command |
|---|---|---|
| 01_hello_world.py | Simplest possible service | python basic/01_hello_world.py |
| 02_echo_service.py | Provider events and statistics | python basic/02_echo_service.py |
| 03_translation_service.py | Real-world service with progress | python basic/03_translation_service.py |
Agent class with full lifecycle management, pricing, filtering, and events.
| Example | Description | Run Command |
|---|---|---|
| 01_agent_lifecycle.py | Start, pause, resume, stop | python standard/01_agent_lifecycle.py |
| 02_pricing_strategy.py | Cost + margin pricing | python standard/02_pricing_strategy.py |
| 03_job_filtering.py | Budget filters, custom filters | python standard/03_job_filtering.py |
| 04_events_and_stats.py | Event system, real-time stats | python standard/04_events_and_stats.py |
| 05_multi_service_agent.py | Single agent, multiple services | python standard/05_multi_service_agent.py |
Full protocol control via ACTPClient with three adapters.
| Example | Description | Run Command |
|---|---|---|
| 01_transaction_lifecycle.py | Complete state machine | python advanced/01_transaction_lifecycle.py |
| 02_dispute_flow.py | Dispute scenarios | python advanced/02_dispute_flow.py |
| 03_batch_operations.py | Parallel transactions | python advanced/03_batch_operations.py |
| 04_event_monitoring.py | Real-time state watching | python advanced/04_event_monitoring.py |
| 05_eas_attestations.py | Ethereum Attestation Service | python advanced/05_eas_attestations.py |
| 06_direct_protocol.py | Direct runtime access | python advanced/06_direct_protocol.py |
Reusable patterns for production SDK usage.
| Example | Description | Run Command |
|---|---|---|
| provider_discovery.py | Discover and select providers | python patterns/provider_discovery.py |
| retry_logic.py | Exponential backoff, circuit breaker | python patterns/retry_logic.py |
| concurrent_requests.py | Semaphore, rate limiting | python patterns/concurrent_requests.py |
Real-world business scenarios.
| Example | Description | Run Command |
|---|---|---|
| 01_ai_to_ai_payment.py | AI agent paying another | python usecases/01_ai_to_ai_payment.py |
| 02_translation_service.py | Per-word pricing model | python usecases/02_translation_service.py |
| 03_code_review_agent.py | Security review service | python usecases/03_code_review_agent.py |
Integration with external systems.
| Example | Description | Run Command |
|---|---|---|
| langchain_tool.py | LangChain tool wrapper | python integrations/langchain_tool.py |
| n8n_webhook.py | n8n webhook integration | python integrations/n8n_webhook.py |
Real blockchain transactions on Base Sepolia.
| Example | Description | Run Command |
|---|---|---|
| mint_usdc.py | Mint test USDC tokens | python testnet/mint_usdc.py |
| 01_real_transaction.py | Create real transaction | python testnet/01_real_transaction.py |
Level 0 (Basic API)
├── provide() - Register a service
├── request() - Request a service
└── Simplest entry point
Level 1 (Standard API)
├── Agent class
├── Lifecycle: start, pause, resume, stop
├── Features: pricing, filtering, events, stats
└── Production-ready agents
ACTPClient (Advanced API)
├── client.basic - One-call solutions
├── client.standard - Step-by-step control
├── client.advanced - Direct runtime access
└── Full protocol control
All examples run in mock mode by default - no blockchain needed.
from agirails import ACTPClient
client = await ACTPClient.create(mode="mock")For real blockchain transactions, configure environment:
cp .env.example .env
# Edit .env with your credentialsfrom agirails import ACTPClient
client = await ACTPClient.create(
mode="testnet",
private_key=os.environ["PRIVATE_KEY"],
rpc_url=os.environ["BASE_SEPOLIA_RPC"],
)python/
├── basic/ # Level 0 API examples
├── standard/ # Level 1 API examples
├── advanced/ # ACTPClient examples
├── patterns/ # Reusable patterns
├── usecases/ # Real-world scenarios
├── integrations/ # External integrations
├── testnet/ # Blockchain examples
├── src/utils/ # Helper functions
├── requirements.txt # Dependencies
└── README.md # This file