Generation Status

Check the status of your image generation requests and track progress in real-time.

GET /api/v1/generate/{generation_id}/

Check the status of a specific image generation request by its ID.

Authentication Required
Include your authentication bearer or API key in the Authorization header

URL Parameters

Required
generation_id
UUID of the image generation request

Example Request

curl -X GET ulazai.com/api/v1/generate/b08cb00c-6578-4c3b-9056-cd1c0bb733cb/ \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

Response Examples

200 OK Generation in progress
{
  "id": "b08cb00c-6578-4c3b-9056-cd1c0bb733cb",
  "status": "GENERATING",
  "progress": "0.47",
  "created_at": "2024-07-06T15:10:00Z",
  "updated_at": "2024-07-06T15:12:30Z",
  "parameters": {
    "prompt": "een olifant met het lichaam van een aap",
    "size": "3:2",
    "model": "FLUX_MAX"
  },
  "credits_used": 24,
  "estimated_completion": "2024-07-06T15:15:00Z"
}
200 OK Generation completed successfully
{
  "id": "b08cb00c-6578-4c3b-9056-cd1c0bb733cb",
  "status": "COMPLETED",
  "progress": "1.0",
  "created_at": "2024-07-06T15:10:00Z",
  "updated_at": "2024-07-06T15:14:35Z",
  "completed_at": "2024-07-06T15:14:35Z",
  "parameters": {
    "prompt": "een olifant met het lichaam van een aap",
    "size": "3:2",
    "model": "FLUX_MAX"
  },
  "credits_used": 24,
  "image_url": "https://example.com/generated-images/b08cb00c-6578-4c3b-9056-cd1c0bb733cb.png",
  "download_url": "ulazai.com/api/v1/generate/b08cb00c-6578-4c3b-9056-cd1c0bb733cb/download/"
}
200 OK Generation failed
{
  "id": "b08cb00c-6578-4c3b-9056-cd1c0bb733cb",
  "status": "FAILED",
  "progress": "0.0",
  "created_at": "2024-07-06T15:10:00Z",
  "updated_at": "2024-07-06T15:12:45Z",
  "failed_at": "2024-07-06T15:12:45Z",
  "parameters": {
    "prompt": "inappropriate content example",
    "size": "3:2",
    "model": "FLUX_MAX"
  },
  "credits_used": 0,
  "error": {
    "code": "CONTENT_FILTER",
    "message": "Content violates our usage policies"
  },
  "credits_refunded": 24
}

Status Values

PENDING
Request Queued
Your request is waiting to be processed
GENERATING
Processing
AI is currently generating your image
COMPLETED
Success
Image generated successfully and ready for download
FAILED
Error
Generation failed due to content policy or technical issues
EXPIRED
Expired
Generation link has expired (after 24 hours)
GET /api/v1/generate/{generation_id}/download/

Download the generated image file directly. Only available for completed generations.

Example Request

curl -X GET ulazai.com/api/v1/generate/b08cb00c-6578-4c3b-9056-cd1c0bb733cb/download/ \
  -H "Authorization: Token YOUR_TOKEN_HERE" \
  -o generated-image.png

Response

200 OK Binary image data (PNG format)
Content-Type: image/png
Content-Disposition: attachment; filename="generated-image.png"
Content-Length: [file size in bytes]

Polling Best Practices

Recommended Polling Intervals
• Start with 5-second intervals for the first minute
• Increase to 10-second intervals after 1 minute
• Use 30-second intervals after 5 minutes
• Maximum generation time is typically 10-15 minutes
Progress Tracking
• Progress values range from 0.0 to 1.0
• Use progress to show completion percentage to users
• Progress may not increase linearly
• Some steps may take longer than others
Rate Limiting
• Avoid polling more frequently than every 3 seconds
• Implement exponential backoff for failed requests
• Stop polling after 20 minutes (consider failed)
• Cache responses to avoid unnecessary API calls

JavaScript Polling Example

async function pollGenerationStatus(generationId, bearer) {
  const maxAttempts = 120; // 10 minutes max
  let attempts = 0;
  let interval = 5000; // Start with 5 seconds
  
  while (attempts < maxAttempts) {
    try {
      const response = await fetch(`/api/v1/generate/${generationId}/`, {
        headers: {
          'Authorization': `Bearer ${bearer}`
        }
      });
      
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}`);
      }
      
      const data = await response.json();
      
      // Update UI with progress
      updateProgress(data.progress);
      
      // Check if completed
      if (data.status === 'COMPLETED') {
        displayImage(data.image_url);
        return data;
      }
      
      // Check if failed
      if (data.status === 'FAILED') {
        displayError(data.error);
        return data;
      }
      
      // Increase interval gradually
      attempts++;
      if (attempts > 12) interval = 10000; // 10 seconds after 1 minute
      if (attempts > 30) interval = 30000; // 30 seconds after 5 minutes
      
      await new Promise(resolve => setTimeout(resolve, interval));
      
    } catch (error) {
      console.error('Polling error:', error);
      attempts++;
      await new Promise(resolve => setTimeout(resolve, interval));
    }
  }
  
  throw new Error('Generation timed out');
}

function updateProgress(progress) {
  const percentage = Math.round(progress * 100);
  document.getElementById('progress').textContent = `${percentage}%`;
  document.getElementById('progress-bar').style.width = `${percentage}%`;
}

function displayImage(imageUrl) {
  const img = document.getElementById('generated-image');
  img.src = imageUrl;
  img.style.display = 'block';
}

function displayError(error) {
  const errorDiv = document.getElementById('error-message');
  errorDiv.textContent = error.message;
  errorDiv.style.display = 'block';
}

Error Codes

401
Unauthorized
Missing or invalid authentication bearer
403
Forbidden
Generation belongs to another user
404
Not Found
Generation ID not found or has expired
429
Too Many Requests
Rate limit exceeded - slow down your polling

Related Endpoints

Generate Image

Start a new generation

View Generation API →

Demo Generation

Try without authentication

View Demo API →