Welcome to tPay, the heart of t54 labs' comprehensive financial infrastructure designed exclusively for AI Agents. Like a masterful dance between technology and trust, we've crafted the most Agent-Native foundation that understands and speaks the language of your digital companions.
At t54 labs, we believe in creating more than just a payment system – we're building a symphony of security and intelligence. Our masterpiece begins with a sophisticated KYA (Know Your Agent) framework, harmoniously orchestrated with our Agent-designed modules: tRadar and tAudit. Together, they compose a secure, reliable, and trustworthy financial infrastructure that your Agents will love to work with.
The tPay Python SDK is your elegant gateway to this world of possibilities. Like a skilled matchmaker, it seamlessly introduces your existing Agents to the world of financial transactions, requiring just a few lines of code to begin the journey. No need to disrupt your current workflow or modify your Agent's core logic – we believe in smooth, non-intrusive relationships.
Built for the modern AI ecosystem, our SDK supports both synchronous and asynchronous operations, ensuring optimal performance whether you're building a single agent or orchestrating a fleet of thousands. With our async-first architecture, your agents can handle financial operations with unprecedented efficiency and scale.
But that's not all – we're not just about transactions; we're about understanding. Our SDK provides a complete data trail of your Agent's thoughts and behaviors, all leading to meaningful financial actions. Our network of financial Agents, like a council of wise advisors, offers intelligent insights and comprehensive behavioral analytics to guide your Agent's financial journey.
Let t54's network of financial experts be your Agent's trusted companion in the world of finance. Together, we'll create a future where AI Agents handle financial transactions with grace, security, and intelligence.
-
Payment Processing
- Create payments between agents
- Support for multiple currencies (USDT, etc.)
- Multiple settlement networks (Solana, etc.)
- Transaction tracking and verification
-
Balance Management
- Query agent balances
- Real-time balance updates
- Multi-currency balance support
-
Agent Management
- Agent creation and management
- User-Agent association
- Agent status tracking
-
Agent Integration
- Compatible with any OpenAI-compatible agent library
- Seamless integration without modifying existing agent code
- Flexible tool creation and management
- Context-aware conversation handling
-
Asynchronous API Support ⚡
- Full async/await support for all operations
- High-performance concurrent execution
- Non-blocking I/O operations
- Compatible with asyncio ecosystem
- Parallel agent creation and management
- Concurrent balance queries and payments
-
Audit Module (tAudit)
- Enhance Agent KYA (Know Your Agent) level
- Improve security and protection for financial transactions
- Automated compliance verification
- Risk assessment and monitoring
-
Compliance and Security (tRadar)
- Complete Agent behavior and decision-making data trail
- End-to-end transaction lifecycle tracking
- Validator Agent Network collaboration
- Transaction verification and risk control
- Developer analytics and insights
- Agent optimization and debugging support
-
Error Handling
- Comprehensive error management
- Detailed error messages
- Error recovery mechanisms
# Basic installation
pip install tpay
# With async support (recommended for high-performance applications)
pip install tpay[async]- Python 3.8 or higher
- Operating System: Windows, macOS, or Linux
The SDK has the following main dependencies:
requests>=2.25.1: For synchronous HTTP requestspython-dotenv>=0.19.0: For environment variable managementpydantic>=2.0.0: For data validation and settings management (optional)
For Async Support (optional):
httpx>=0.24.0: For asynchronous HTTP requests
For OpenAI Integration (optional):
openai>=1.0.0: For OpenAI API integration
Additional dependencies will be automatically installed when you install the SDK.
First, initialize the tPay SDK in your application:
from tpay import tpay_initialize
# Initialize the SDK with your credentials
tpay_initialize(
api_key="your_api_key",
api_secret="your_api_secret",
project_id="your_project_id",
timeout=1000 # Optional: timeout in milliseconds
)The SDK provides seamless integration with any OpenAI-compatible agent library. You can integrate our tools with your existing agent without modifying its core code in just few lines of code. Here's how:
- Create Tools
from tpay import *
# Create payment tool
payment_tool = tpay_toolkit_payment()
# Create balance tool
balance_tool = tpay_toolkit_balance()- Add Tools to Your Agent
Simply add the tools to your existing agent's tool list:
# Example with OpenAI's client
from openai import OpenAI
# Initialize your own tool list for your agent
tools = [...]
# Then add our tool defintions to the tool list
tools.extend(get_all_tool_definitions())
client = OpenAI(
api_key="your_openai_api_key",
model="gpt-4-turbo-preview",
tools=tools, # Make sure you have added our tools to your existing tools
tool_choice="auto"
)- Handle Tool Execution
Implement a tool execution handler that works with your agent:
def execute_tool(tool_name, tool_args):
if tool_name == "create_payment":
return payment_tool(**tool_args)
elif tool_name == "get_agent_balance":
return balance_tool(**tool_args)
return NoneThat's it! Your agent can now use tPay's payment and balance management capabilities.
For high-performance applications, you can use the asynchronous API:
import asyncio
import tpay
async def main():
# Initialize SDK (same as sync)
tpay.tpay_initialize(
api_key="your_api_key",
api_secret="your_api_secret",
project_id="your_project_id"
)
# Create agents asynchronously
agent_data = await tpay.async_create_agent(
name="Async Agent",
description="High-performance agent"
)
# Use AsyncTPayAgent for non-blocking operations
async_agent = tpay.AsyncTPayAgent()
# Concurrent operations for better performance
results = await asyncio.gather(
async_agent.create_payment(...),
async_agent.get_agent_balance("agent_id"),
tpay.async_get_agent_asset_balance("agent_id", "solana", "USDC")
)
# Run async code
asyncio.run(main())The SDK provides detailed error handling:
from tpay.exceptions import TPayError
try:
# Your code here
pass
except TPayError as e:
print(f"Error: {e.message}")
print(f"Code: {e.code}")-
API Key Management
- Store API keys securely
- Use environment variables
- Rotate keys regularly
-
Error Handling
- Always implement proper error handling
- Log errors appropriately
- Implement retry mechanisms for transient failures
-
Transaction Management
- Verify transaction status
- Implement idempotency
- Handle edge cases
-
Security
- Validate all inputs
- Implement rate limiting
- Use secure communication channels
For comprehensive documentation including deployment guides, async examples, and advanced usage patterns, please refer to:
📖 Complete Export Guide - Detailed documentation covering:
- Installation and deployment methods
- Synchronous and asynchronous API usage
- Complete code examples
- Best practices and troubleshooting
- Agent creation and management
- Balance queries and payment processing
tpay_initialize()- Initialize the SDKcreate_agent()- Create new agentsget_agent_asset_balance()- Query asset balancesTPayAgentclass - Full agent management
async_create_agent()- Create agents asynchronouslyasync_get_agent_asset_balance()- Query balances asynchronouslyAsyncTPayAgentclass - Full async agent managementasync_make_request()- Core async HTTP requests
For detailed API documentation and examples, see the Export Guide.
We welcome contributions! Please see our contributing guidelines for more information.