SDK API Reference

Complete SDK methods and examples.

Client Methods

submitJob(config)

Submit new job for execution.

const job = await client.submitJob({
  image: 'python:3.11',
  cpu: 2,
  memory: 4,
  env: { SCRIPT: 'print("hello")' },
  maxPrice: 0.10
});

console.log('Job ID:', job.id);

waitForJob(jobId)

Wait for job completion, returns result.

const result = await client.waitForJob('job-123');

console.log('Status:', result.status);
console.log('Output:', result.output);
console.log('Cost:', result.cost);

getJob(jobId)

Get current job status without waiting.

const job = await client.getJob('job-123');

console.log('Status:', job.status);
// pending | running | completed | failed

Job Builder API

Use the fluent builder for complex job configurations:

const { JobBuilder } = require('@kova/sdk');

const job = new JobBuilder()
  .fromImage('node:20-alpine')
  .withCpu(2)
  .withMemory(4)
  .withDisk(10)
  .withEnv('NODE_ENV', 'production')
  .withEnv('API_KEY', 'secret')
  .withMaxPrice(0.20)
  .build();

await client.submitJob(job);

Builder Methods

| Method | Description | |--------|-------------| | fromImage(name) | Set Docker image | | withCpu(cores) | Set CPU cores | | withMemory(gb) | Set memory in GB | | withDisk(gb) | Set disk space in GB | | withEnv(key, value) | Add environment variable | | withMaxPrice(amount) | Set maximum price | | build() | Build job configuration |