OpenCommerce is a payment network designed for AI agents, enabling them to pay for services in real-time. This guide demonstrates how to integrate OpenCommerce with CrewAI for orchestrating payments between agents and services.
- Pay-as-you-go Services: Agents can access and pay for AI services in real-time
- Built-in Account Management: Automatic account creation and balance management
- Service Directory: Centralized directory of available AI services
- Blockchain-based Payments: Secure transactions using USDC on Base network
pip install opencommerce-sdk crewai
Create a .env
file in your project root:
OPENAI_API_KEY=your_api_key_here
Then load it in your Python code:
from dotenv import load_dotenv
load_dotenv()
from opencommerce_sdk import OpenCommerceAccountToolkit
# Initialize the SDK
sdk = OpenCommerceAccountToolkit(network="testnet")
print("✅ SDK initialized successfully")
# Get the account address
address = sdk.get_account_address()
print(f"My account address: {address}")
class TavilySearchTool(BaseTool):
name: str = "Tavily Search"
description: str = "Search the internet for information using Tavily"
def _run(self, query: str) -> str:
return self.sdk.use_service('tavily_search', {'query': query})
class GPTResearchTool(BaseTool):
name: str = "GPT Research"
description: str = "Conduct detailed analysis using GPT Researcher"
def _run(self, query: str) -> str:
return self.sdk.use_service('gpt_researcher', {'query': query})
market_research_agent = Agent(
role="Market Research Specialist",
goal="Gather comprehensive market data",
tools=[TavilySearchTool(sdk)],
verbose=True
)
tech_analysis_agent = Agent(
role="Technology Analyst",
goal="Analyze technological developments",
tools=[GPTResearchTool(sdk)],
verbose=True
)
- Agent Request: Agent requests a service (e.g., Tavily search or GPT research)
- Service Directory: OpenCommerce gets service details and pricing
- Payment: SDK handles USDC payment on Base network
- Service Execution: After payment confirmation, service is executed
- Results: Service results are returned to the agent
The included example demonstrates a market research workflow where:
- Market Research Agent uses Tavily Search for data gathering
- Technology Analyst uses GPT Researcher for analysis
- Each service call is automatically paid for using USDC
For the complete example implementation, see the full code in this repository.
For more detailed information about the OpenCommerce SDK, including:
- Complete API documentation
- Additional code examples
- Service directory details
- Contribution guidelines
Visit the OpenCommerce SDK GitHub Repository.
Currently, OpenCommerce SDK only supports testnet operations for development and testing purposes.
- Visit the Circle USDC Faucet
- Select Base Sepolia network
- Request test USDC tokens
To check your balance:
# Get current balance
balance = sdk.get_balance()
print(f"Current balance: {balance} USDC")