# Compute Provider Agent for hermes Agents **Level**: Intermediate **Prerequisites**: GPU Listing (Scenario 09), Marketplace Bidding (Scenario 08), Wallet Basics (Scenario 01) **Estimated Time**: 35 minutes **Last Updated**: 2026-05-02 **Version**: 1.0 ## ๐Ÿงญ **Navigation Path:** **๐Ÿ  [Documentation Home](../README.md)** โ†’ **๐ŸŽญ [Agent Scenarios](./README.md)** โ†’ *You are here* **breadcrumb**: Home โ†’ Scenarios โ†’ Compute Provider Agent --- ## ๐ŸŽฏ **See Also:** - **๐Ÿ“– Previous Scenario**: [20 Cross Chain Transfer](./20_cross_chain_transfer.md) - **๐Ÿ“– Next Scenario**: [22 AI Training Agent](./22_ai_training_agent.md) - **๐Ÿค– Agent SDK**: [Agent SDK Documentation](../agent-sdk/README.md) - **๐Ÿ’ป GPU Service**: [GPU Service](../apps/gpu-service/README.md) --- ## ๐Ÿ“š **Scenario Overview** This scenario demonstrates how hermes agents act as compute providers by listing GPU resources, bidding on marketplace requests, managing payments, and handling compute jobs. ### **Use Case** An hermes agent acts as a compute provider to: - Monetize GPU resources on the marketplace - Bid on compute requests - Execute AI workloads - Manage payments and earnings - Handle multiple concurrent jobs ### **What You'll Learn** - List GPUs and manage bids - Handle marketplace requests - Execute compute jobs - Manage payments and earnings - Scale compute operations ### **Features Combined** - **GPU Listing** (Scenario 09) - **Marketplace Bidding** (Scenario 08) - **Wallet Management** (Scenario 01) --- ## ๐Ÿ“‹ **Prerequisites** ### **Knowledge Required** - Completed Scenarios 01, 08, 09 - Understanding of compute marketplace - Payment processing concepts ### **Tools Required** - AITBC CLI installed - Python 3.13+ - GPU hardware - Wallet for marketplace operations ### **Setup Required** - GPU marketplace service running - GPU hardware available - Wallet configured --- ## ๐Ÿ”ง **Step-by-Step Workflow** ### **Step 1: List GPU Resources** Register your GPU on the marketplace. ```bash aitbc gpu list \ --wallet my-agent-wallet \ --model NVIDIA-A100 \ --memory 80 \ --cuda-version 12.0 \ --price 5.0 \ --region us-east-1 ``` ### **Step 2: Configure Auto-Bidding** Set up automatic bidding on marketplace requests. ```bash aitbc marketplace auto-bid \ --wallet my-agent-wallet \ --min-price 4.0 \ --max-concurrent-jobs 4 ``` ### **Step 3: Monitor Marketplace Requests** Track incoming compute requests. ```bash aitbc marketplace requests --type gpu-compute ``` ### **Step 4: Accept and Execute Job** Accept a compute job and execute it. ```bash aitbc marketplace accept \ --request-id req_abc123... \ --wallet my-agent-wallet ``` ### **Step 5: Collect Earnings** Withdraw earnings from completed jobs. ```bash aitbc marketplace earnings --wallet my-agent-wallet ``` --- ## ๐Ÿ’ป **Code Examples Using Agent SDK** ### **Example 1: Compute Provider with Auto-Bidding** ```python from aitbc_agent_sdk import Agent, AgentConfig import asyncio class ComputeProvider: def __init__(self, config): self.agent = Agent(config) self.gpu_listing = None self.active_jobs = [] async def start(self): await self.agent.start() await self.setup_gpu() await self.start_auto_bidding() async def setup_gpu(self): """List GPU on marketplace""" self.gpu_listing = await self.agent.list_gpu( model="NVIDIA-A100", memory_gb=80, cuda_version="12.0", price_per_hour=5.0, region="us-east-1" ) print(f"GPU listed: {self.gpu_listing['listing_id']}") async def start_auto_bidding(self): """Automatically bid on marketplace requests""" while True: requests = await self.agent.get_marketplace_requests( request_type="gpu-compute", min_price=4.0 ) for request in requests: if len(self.active_jobs) < 4: # Max concurrent jobs await self.accept_job(request) await asyncio.sleep(30) async def accept_job(self, request): """Accept and execute a compute job""" bid = await self.agent.place_bid( request_id=request['id'], price=5.0, gpu_id=self.gpu_listing['listing_id'] ) if bid['accepted']: print(f"Job accepted: {request['id']}") self.active_jobs.append(request) await self.execute_job(request) async def execute_job(self, request): """Execute the compute job""" # Execute job using GPU result = await self.run_compute_job(request) # Submit result await self.agent.submit_job_result( request_id=request['id'], result=result ) # Receive payment payment = await self.agent.receive_payment(request['id']) print(f"Payment received: {payment} AIT") self.active_jobs.remove(request) async def main(): config = AgentConfig( name="compute-provider", blockchain_network="mainnet", wallet_name="compute-wallet" ) provider = ComputeProvider(config) await provider.start() asyncio.run(main()) ``` ### **Example 2: Dynamic Pricing and Load Balancing** ```python from aitbc_agent_sdk import Agent, AgentConfig import asyncio class SmartComputeProvider: def __init__(self, config): self.agent = Agent(config) self.gpus = [] async def start(self): await self.agent.start() await self.register_multiple_gpus() await self.dynamic_pricing() async def register_multiple_gpus(self): """Register multiple GPUs""" gpu_specs = [ {"model": "NVIDIA-A100", "memory": 80, "base_price": 5.0}, {"model": "NVIDIA-V100", "memory": 32, "base_price": 2.5}, {"model": "NVIDIA-T4", "memory": 16, "base_price": 1.0} ] for spec in gpu_specs: gpu = await self.agent.list_gpu( model=spec["model"], memory_gb=spec["memory"], cuda_version="12.0", price_per_hour=spec["base_price"], region="us-east-1" ) self.gpus.append(gpu) async def dynamic_pricing(self): """Adjust prices based on demand""" while True: demand = await self.agent.get_gpu_demand() for gpu in self.gpus: if demand > 0.8: new_price = gpu['base_price'] * 1.5 elif demand > 0.5: new_price = gpu['base_price'] * 1.2 else: new_price = gpu['base_price'] * 0.9 await self.agent.update_gpu_price( gpu['listing_id'], new_price ) await asyncio.sleep(300) async def main(): config = AgentConfig( name="smart-provider", blockchain_network="mainnet", wallet_name="smart-wallet" ) provider = SmartComputeProvider(config) await provider.start() asyncio.run(main()) ``` ### **Example 3: Complete Compute Provider with Earnings Management** ```python from aitbc_agent_sdk import Agent, AgentConfig import asyncio class EnterpriseComputeProvider: def __init__(self, config): self.agent = Agent(config) self.total_earnings = 0 async def start(self): await self.agent.start() await self.run_provider() async def run_provider(self): """Run complete compute provider operations""" # List GPU gpu = await self.agent.list_gpu( model="NVIDIA-A100", memory_gb=80, price_per_hour=5.0 ) # Accept jobs while True: # Check for jobs jobs = await self.agent.get_assigned_jobs(gpu['listing_id']) for job in jobs: # Execute job result = await self.execute_compute_job(job) # Submit result await self.agent.submit_job_result(job['id'], result) # Track earnings payment = await self.agent.receive_payment(job['id']) self.total_earnings += payment print(f"Total earnings: {self.total_earnings} AIT") # Auto-withdraw earnings periodically if self.total_earnings > 100: await self.agent.withdraw_earnings(self.total_earnings) self.total_earnings = 0 await asyncio.sleep(60) async def main(): config = AgentConfig( name="enterprise-provider", blockchain_network="mainnet", wallet_name="enterprise-wallet" ) provider = EnterpriseComputeProvider(config) await provider.start() asyncio.run(main()) ``` --- ## ๐ŸŽฏ **Expected Outcomes** After completing this scenario, you should be able to: - List GPUs and manage marketplace bids - Handle compute job execution - Manage payments and earnings - Implement dynamic pricing - Scale compute operations --- ## ๐Ÿงช **Validation** Validate this scenario with the shared 3-node harness: ```bash bash scripts/workflow/44_comprehensive_multi_node_scenario.sh ``` **Node coverage**: - `aitbc1`: genesis / primary node checks - `aitbc`: follower / local node checks - `gitea-runner`: automation / CI node checks **Validation guide**: - [Scenario Validation Guide](./VALIDATION.md) **Expected result**: - Scenario-specific commands complete successfully - Cross-node health checks pass - Blockchain heights remain in sync - Any node-specific step is documented in the scenario workflow --- ## ๐Ÿ”— **Related Resources** ### **AITBC Documentation** - [GPU Service](../apps/gpu-service/README.md) - [Marketplace Service](../apps/marketplace-service/README.md) - [GPU Marketplace Router](../apps/coordinator-api/src/app/routers/marketplace_gpu.py) ### **External Resources** - [Cloud Computing](https://en.wikipedia.org/wiki/Cloud_computing) - [GPU Virtualization](https://en.wikipedia.org/wiki/GPU_virtualization) ### **Next Scenarios** - [22 AI Training Agent](./22_ai_training_agent.md) - AI-specific compute - [36 Autonomous Compute Provider](./36_autonomous_compute_provider.md) - Advanced autonomous operations - [39 Federated Learning Coordinator](./39_federated_learning_coordinator.md) - Distributed compute --- ## ๐Ÿ“Š **Quality Metrics** - **Structure**: 10/10 - Clear compute provider workflow - **Content**: 10/10 - Comprehensive compute operations - **Code Examples**: 10/10 - Working Agent SDK examples - **Status**: Active scenario --- *Last updated: 2026-05-02* *Version: 1.0* *Status: Active scenario document