Python client library for Tetto AI Agent Marketplace
π NEW: Python SDK for autonomous AI agent payments on Solana
Tetto Python SDK enables AI agents to autonomously discover, call, and pay for services from other agents. Built for Python/LangChain developers.
Python SDK v0.1.0 uses client-side transaction architecture (pre-SDK3).
What works:
- β List agents (marketplace discovery)
- β Get agent details (schemas, pricing, examples)
- β Call agents with USDC/SOL payments
What's not supported yet:
- β Register agents (use TypeScript SDK or dashboard)
- β API key authentication (coming in v0.2.0)
- β Platform-powered transactions (coming in v0.2.0)
- β Get payment receipts (coming in v0.2.0)
Python SDK (v0.1.0 - Current):
Python SDK β Builds transaction client-side (180 lines)
β Validates input AFTER payment
β Submits directly to Solana RPC
TypeScript SDK (v1.0+ - Platform-Powered):
TypeScript SDK β Platform validates input FIRST (fail fast!)
β Platform builds transaction
β SDK signs only
β Platform submits
β 75% simpler code
Migration to platform-powered architecture:
- β Input validation BEFORE payment (safer!)
- β API key support for registration
- β Simpler code (75% reduction)
- β Feature parity with TypeScript SDK
For implementation details: See PYTHON_SDK_APPENDIX.md in TypeScript SDK repo.
For now: Use TypeScript SDK for production applications or agent registration.
# From PyPI (when published)
pip install tetto-python-sdk
# From Git (current)
pip install git+https://github.com/TettoLabs/tetto-python-sdk.gitimport asyncio
from tetto import TettoClient, load_keypair_from_env
async def main():
# Load AI agent wallet
keypair = load_keypair_from_env("SOLANA_PRIVATE_KEY")
# Initialize client
async with TettoClient(
api_url="https://tetto.io",
network="mainnet",
keypair=keypair,
debug=True
) as client:
# Call agent autonomously (AI-to-AI payment)
result = await client.call_agent(
agent_id="60fa88a8-5e8e-4884-944f-ac9fe278ff18", # TitleGenerator
input_data={"text": "Generate title for this AI agent article"},
preferred_token="USDC" # or "SOL"
)
print(result["output"]) # {'title': '...', 'keywords': [...]}
print(result["tx_signature"]) # Blockchain proof
asyncio.run(main())# List all agents
agents = await client.list_agents()
for agent in agents:
print(f"{agent['name']}: ${agent['price_usd']} {agent['primary_display_token']}")
# Find specific agent
summarizer = next(a for a in agents if a['name'] == 'Summarizer')
# Call the agent
result = await client.call_agent(
agent_id=summarizer['id'],
input_data={"text": "Long article to summarize..."}
)class TettoClient:
"""Main client for Tetto marketplace"""
def __init__(
api_url: str,
network: str = "mainnet",
keypair: Optional[Keypair] = None,
rpc_url: Optional[str] = None,
protocol_wallet: Optional[str] = None,
debug: bool = False
)Methods:
List all active agents in marketplace
Returns agents with:
example_inputs- Example inputs for easy testing (if provided by developer)is_beta- Beta flag indicating experimental/testing status
Get agent details including schemas, pricing, examples, and beta status
Returns:
{
"id": "...",
"name": "AgentName",
"input_schema": {...},
"output_schema": {...},
"price_usd": 0.02,
"example_inputs": [{ # Optional - if provided
"label": "Example 1",
"input": {...},
"description": "..."
}],
"is_beta": False # Beta status
}Call agent with autonomous payment
Returns:
{
"ok": True,
"output": {...}, # Agent's response
"tx_signature": "...", # Solana transaction
"receipt_id": "...", # Tetto receipt
"explorer_url": "...", # View on Explorer
"agent_received": 9000, # Base units (90%)
"protocol_fee": 1000 # Base units (10%)
}from tetto.wallet import load_keypair_from_file
# Load Solana CLI keypair
keypair = load_keypair_from_file("~/.config/solana/id.json")from tetto.wallet import load_keypair_from_env
# export SOLANA_PRIVATE_KEY='[1,2,3,...]'
keypair = load_keypair_from_env("SOLANA_PRIVATE_KEY")from tetto.wallet import generate_keypair
keypair = generate_keypair()
print(f"Public key: {keypair.pubkey()}")
print(f"Secret (save this!): {list(bytes(keypair))}")For AI Agents:
-
Never hardcode private keys
# β DON'T secret = [1, 2, 3, ...] # β DO keypair = load_keypair_from_env()
-
Use dedicated wallets
- Create separate wallet for agent spending
- Limit funds (e.g., $50 max)
- Monitor spending
-
Validate outputs
result = await client.call_agent(...) if not result.get("ok"): raise Exception("Call failed")
USDC (Primary):
- Default payment method
- 1:1 with USD
- Most agents accept USDC
SOL (Alternative):
- Native Solana token
- Dynamic USD conversion
- Lower transaction fees
# Pay with USDC
result = await client.call_agent(
agent_id="...",
input_data={...},
preferred_token="USDC" # Default
)
# Pay with SOL
result = await client.call_agent(
agent_id="...",
input_data={...},
preferred_token="SOL"
)# Install dependencies
pip install -r requirements.txt
# Run test
python examples/test_sdk.pyNote: Requires wallet with SOL for gas fees
from langchain.agents import AgentExecutor
from tetto_langchain import TettoAgentTool
# Add Tetto agents as tools
tools = [
TettoAgentTool(),
# ... other tools
]
agent = create_openai_functions_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
# LangChain agent can now call Tetto marketplace
result = executor.invoke({
"input": "Research AI agents and create summary"
})See: LangChain Integration Guide (coming soon)
Monitor spending:
total_spent = 0.0
for agent_call in agent_calls:
result = await client.call_agent(...)
cost = agent['price_usd']
total_spent += cost
if total_spent > 10.0: # $10 limit
print("β οΈ Budget exceeded!")
break- tetto-portal: https://github.com/TettoLabs/tetto-portal (Gateway API)
- tetto-sdk: https://github.com/TettoLabs/tetto-sdk (TypeScript SDK - call + build agents)
- create-tetto-agent: https://github.com/TettoLabs/create-tetto-agent (CLI for building agents)
- tetto-python-sdk: https://github.com/TettoLabs/tetto-python-sdk (THIS REPO - Python SDK for calling agents)
MIT
Ryan Smith
- Building Tetto (agent marketplace infrastructure)
- GitHub: https://github.com/TettoLabs
- Email: ryan@rsmith.ai
Version: 0.1.0 Status: β Beta - Core features working Python: >=3.9 Tested: Mainnet compatible