Skip to main content

Overview

All generation requests follow the same basic lifecycle: Job lifecycle diagram

Job States

queued Job is waiting in the queue to be processed backlogged Job is waiting behind your current concurrency limit scheduled Job has been accepted and scheduled for processing processing Job is actively being processed by a worker sampling Job is generating output samples intermediate-complete Job has an intermediate result and may continue processing completed Job finished successfully, result available in result.urls failed Job failed due to an error, details in result.error cancelled Job was cancelled by the user or system

Failures & Cancellation

Jobs can fail for several reasons:
  • API errors from the generation service
  • Invalid parameters or unsupported configurations
  • Content moderation (NSFW filtering)
  • Automatic timeout detection (3 minutes for hosted tools, 2 hours for external providers)
To cancel a job: Send a DELETE request to /jobs/{id}. Note: Jobs can only be canceled while they have a status of queued or processing.
Important: Failed and cancelled jobs are not billed. You only pay for completed jobs.

Checking Job Status

Poll for job status using a GET request to /jobs/{id}. Recommended practices:
  • Poll every 2-5 seconds while job is pending (backlogged, queued, scheduled, processing, sampling, or intermediate-complete)
  • Use exponential backoff for longer-running jobs
  • Stop polling when status is completed, failed, or cancelled
  • Some jobs may include preview images in responses during processing
Example polling implementation:
// npm install @krea-ai/sdk
import { Krea } from "@krea-ai/sdk";

const krea = new Krea({ apiKey: process.env.KREA_API_KEY });

async function waitForJob(jobId) {
  const job = await krea.jobs.wait(jobId, { intervalMs: 2000 });
  return job.result;
}

Next Steps

Webhooks

Receive notifications when jobs complete

Rate Limits

Understand API limits by plan tier

Model APIs

Explore all available endpoints and parameters

API Keys & Billing

Create and manage your API keys