API Documentation | bitStudio
Over 100,000 photos generated

API Documentation

Integrate bitStudio's powerful AI capabilities directly into your applications with our comprehensive API.

Authentication

All API requests require authentication using an API key

Base URL for all API requests:

https://api.bitstudio.ai

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Keep your API keys secure and never share them in public repositories or client-side code.

You can manage your API keys in the API Keys section of your account.

Get Image Status

Retrieve image details and check generation status

GET /images/{id}

Response Format

{
  "id": "IMG_123",
  "status": "completed",
  "task": "virtual-try-on",
  "path": "https://media.bitstudio.ai/gen/image.jpg",
  "versions": [
    {
      "id": "VERSION_123",
      "version_type": "upscaled",
      "path": "https://media.bitstudio.ai/gen/upscaled.jpg"
    }
  ],
  "credits_used": 2,
  "created_timestamp": "2024-02-20T14:30:00Z",
  "finish_timestamp": "2024-02-20T15:00:00Z"
}

Polling for Completion

Most API operations that generate images are asynchronous. Use this endpoint to check the status of operations:

const pollForCompletion = async (imageId) => {
  let complete = false;
  
  while (!complete) {
    const response = await fetch(`https://api.bitstudio.ai/images/${imageId}`, {
      headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
    });
    
    const imageData = await response.json();
    
    if (imageData.status === 'completed') {
      complete = true;
      return imageData;
    } else if (imageData.status === 'failed') {
      throw new Error('Image processing failed');
    }
    
    console.log('Current status:', imageData.status);
    
    // Wait 2 seconds before polling again
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
};

Status Values

Status Description
pending
Request received, waiting to be processed
generating
Processing has begun
completed
Processing is complete, result is ready
failed
Processing failed, check error details

Best Practices

  • Use exponential backoff: Increase the wait time between polls if processing takes longer
  • Check for errors: Always handle the "failed" status explicitly
  • Timeout: Implement a reasonable timeout for your polling loop (e.g., 2-3 minutes)

Credit Usage

Understanding credit costs for different operations

Operation Credit Cost
Standard Resolution Generation 1 credit per image
High Resolution Generation 2 credits per image
Virtual Try-On (Standard) 1 credit per image
Virtual Try-On (High) 2 credits per image
Upscaling (1x) 1 credit per image
Upscaling (2x) 2 credits per image
Upscaling (4k) 5 credits per image
Inpainting (standard) 1 credit per image
Inpainting (high) 2 credits per image
Image to Video 15 credits per video

Credits are deducted when the request is made. If the operation fails, credits are automatically refunded.

Frequently Asked Questions

How do I authenticate my API requests?

Include your API key in the Authorization header: 'Authorization: Bearer YOUR_API_KEY'.

Are there rate limits for the API?

Yes, the API is limited to 10 requests per second. If you exceed this limit, you'll receive a RATE_LIMITED error code.

How are credits deducted when using the API?

Credits are deducted when the request is made. If the operation fails, credits are automatically refunded.

What image formats are supported for upload?

The API accepts JPEG, PNG, and WebP formats with a maximum file size of 10MB.

How do I check the status of a generated image?

Poll the GET /images/{id} endpoint until the status changes from 'pending' to 'completed'.

Ready to integrate our API?

Get started with our API to add powerful AI imaging capabilities to your application.