Usage Examples

Example 1: Agent Running Scheduled Tasks

// Agent code
const pact = new PactClient({ apiKey });

// Deploy Serverless function
const func = await pact.compute.deployFunction({
  name: 'daily-report',
  runtime: 'python3.11',
  code: reportGenerator,
  schedule: '0 9 * * *', // 9am daily
  paymentToken: 'USDC'
});

// Auto-billed execution, no manual intervention

Example 2: Agent Training Model

// Rent GPU instance
const gpu = await pact.compute.rentGPU({
  type: 'A100',
  duration: 4, // hours
  paymentToken: 'USDC', // Price stable
  image: 'pytorch/pytorch:2.0'
});

// Upload data and start training
await gpu.uploadData('s3://my-dataset');
await gpu.execute('python train.py');

Example 3: Agent Hosting Web Service

Last updated