Fast Image Generation API

Generate stunning AI images at lightning speed. Create multiple variations with a single API call.

Get Started

Getting Started

Start generating images with a simple POST request

Code Examples

curl -X POST https://opaiimageapi.brubslabs.com/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a beautiful sunset over mountains",
    "count": 3,
    "size": "1024x1024"
  }'
const response = await fetch('https://opaiimageapi.brubslabs.com/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: 'a majestic lion in the savanna',
    count: 5,
    size: '1024x1024'
  })
});

const data = await response.json();

// Save images to files
data.images.forEach((base64Data, index) => {
  const link = document.createElement('a');
  link.href = `data:image/png;base64,${base64Data}`;
  link.download = `image_${index + 1}.png`;
  link.click();
});
import requests
import base64

response = requests.post(
    'https://opaiimageapi.brubslabs.com/generate',
    json={
        'prompt': 'a futuristic city skyline at night',
        'count': 4,
        'size': '1792x1024'
    }
)

data = response.json()

# Save each image
for i, image_data in enumerate(data['images']):
    with open(f'image_{i+1}.png', 'wb') as f:
        f.write(base64.b64decode(image_data))
        
print(f"Generated {data['count']} images")
const fs = require('fs');
const fetch = require('node-fetch');

async function generateImages() {
  const response = await fetch('https://opaiimageapi.brubslabs.com/generate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      prompt: 'an astronaut riding a horse on mars',
      count: 3,
      size: '1024x1024'
    })
  });

  const data = await response.json();
  
  // Save images
  data.images.forEach((base64Data, index) => {
    const buffer = Buffer.from(base64Data, 'base64');
    fs.writeFileSync(`image_${index + 1}.png`, buffer);
  });
  
  console.log(`Saved ${data.count} images`);
}

generateImages();

Response Format

All successful requests return a consistent JSON structure

Success Response

{
  "images": [
    "iVBORw0KGgoAAAANSUhEUgAA...",
    "iVBORw0KGgoAAAANSUhEUgAA...",
    "iVBORw0KGgoAAAANSUhEUgAA..."
  ],
  "prompt": "a beautiful sunset over mountains",
  "count": 3,
  "size": "1024x1024"
}

Error Response

{
  "error": "Prompt is required"
}

API Reference

Complete parameter documentation and specifications

Endpoint

POST https://opaiimageapi.brubslabs.com/generate

Parameters

Parameter Type Required Description
prompt string ✓ Text description of the image to generate
count integer ✗ Number of variations (1-10, default: 1)
size string ✗ Image dimensions. Options: "1024x1024", "1792x1024", "1024x1792"

Response Fields

Field Type Description
images array Array of base64 encoded PNG images
prompt string The original prompt used
count integer Number of images generated
size string Dimensions of generated images
warning string Present if some generations failed