Skip to content

Image Generation

FOTOhub provides access to 25+ image generation models from 8 providers: Google Vertex AI, OpenAI, Microsoft MAI, BytePlus, xAI, Black Forest Labs, MiniMax, and Kling. Generate photorealistic images, illustrations, concept art, and more via a single unified endpoint.

Two Billing Modes

  • Credit-based — Fixed cost per image regardless of resolution. Most models use this mode.
  • Token-based — Cost scales with output resolution (pixel count). Used by BytePlus SeedDream models.

Endpoint

POST /v1/ai/generate/image

Authentication: Bearer token (API key)
Billing: 1–8 credits per image (credit-based) or token-based for SeedDream models

Request Parameters

ParameterTypeRequiredDefaultDescription
promptstringYesText description of the image to generate. Be specific — include subject, style, lighting, composition details for best results. Max 4096 characters.
modelstringNo"imagen-3-fast"Model identifier. See the full model list below for all 25 options. We recommend seedream-5-0-260128 for best quality.
widthintegerNo1024Output image width in pixels. Range: 256–4096. Must be divisible by 64 for most models.
heightintegerNo1024Output image height in pixels. Range: 256–4096. Must be divisible by 64 for most models.
aspect_ratiostringNo"1:1"Aspect ratio preset. Options: "1:1", "16:9", "9:16", "4:3", "3:4". Overrides width/height when set.
num_imagesintegerNo1Number of images to generate per request. Range: 1–4. Credits are charged per image.
negative_promptstringNoDescribe what to avoid in the generated image. E.g., "blurry, low quality, distorted faces". Not supported by all models.
stylestringNoStyle preset. Common options: "photorealistic", "cinematic", "anime", "digital-art", "oil-painting".
seedintegerNorandomSeed for reproducible generation. Same prompt + seed + model = same output. Range: 0–4294967295.

Resolution Tips

Use aspect_ratio instead of manual width/height for most use cases. The API automatically picks optimal dimensions for the selected model. For token-based models (BytePlus), higher resolution directly increases cost.

Response Format

Credit-Based Response (Standard Models)

json
{
  "model": "seedream-5-0-260128",
  "credits_used": 2,
  "billing": {
    "method": "credits",
    "credits_used": 2,
    "pln_charged": 0.30
  },
  "images": [
    "https://s1.fotohub.app/storage/v1/object/public/generations/img_abc123.png"
  ],
  "metadata": {
    "width": 1024,
    "height": 1024,
    "seed": 42,
    "model": "seedream-5-0-260128",
    "generation_time_ms": 3200
  }
}

Token-Based Response (BytePlus SeedDream Models)

json
{
  "model": "seedream-5-0-260128",
  "credits_used": 2,
  "billing": {
    "method": "token",
    "credits_used": 2,
    "pln_charged": 0.049,
    "cost_breakdown": {
      "output_tokens": 4096,
      "cost_usd": 0.008192,
      "cost_pln": 0.049152,
      "rate_per_1m_tokens_usd": 2.00
    }
  },
  "usage": {
    "output_tokens": 4096
  },
  "images": [
    "https://s1.fotohub.app/storage/v1/object/public/generations/img_def456.png"
  ],
  "metadata": {
    "width": 1024,
    "height": 1024,
    "seed": 8817,
    "model": "seedream-5-0-260128",
    "generation_time_ms": 2100
  }
}

Token-Based Billing (BytePlus Models)

BytePlus SeedDream models use per-token billing where cost scales with output resolution. Generating a 4K image costs 16x more than a 1K image.

Cost Scales with Resolution

Unlike credit-based models where a 4K image costs the same as a 1K image, token-based models charge proportionally to pixel count. Always check the estimated cost before generating at high resolutions.

Token Calculation Formula

output_tokens = (width × height) / 256
cost_usd = (output_tokens / 1,000,000) × rate_per_1m_usd
cost_pln = cost_usd × 4.0 (USD→PLN) × 1.5 (margin)

Resolution to Token Examples

ResolutionOutput TokensCost (USD) @ $2/1MCost (PLN)
1024 × 10244,096$0.00820.049 PLN
1536 × 15369,216$0.01840.111 PLN
2048 × 204816,384$0.03280.197 PLN
3072 × 307236,864$0.07370.442 PLN
4096 × 409665,536$0.13110.786 PLN

Token-Based Model Rates

ModelRate (USD/1M tokens)Credits (min)
seedream-5-0-260128$2.002
seedream-4-5-251128$2.503
seedream-4-0-250828$2.002
dola-seedream-5-0-pro-260628$3.503
seededit-3-0-i2i-250628$2.503

All Models — Complete Pricing

Google Vertex AI (Imagen)

Model IDNamePrice (PLN)CreditsNotes
imagen-3-fastImagen 3 Fast0.121512px fast
imagen-3-standardImagen 3 Standard0.2421K
imagen-4-fastImagen 4 Fast0.182
imagen-4-standardImagen 4 Standard0.453High quality
imagen-4-ultraImagen 4 Ultra0.9054K

OpenAI

Model IDNamePrice (PLN)CreditsNotes
dall-e-3DALL-E 30.242
dall-e-3-hdDALL-E 3 HD0.484
gpt-image-1GPT Image 10.604
gpt-image-2GPT Image 21.6010Recommended — highest fidelity

Microsoft MAI

Model IDNamePrice (PLN)CreditsNotes
mai-image-2.5MAI-Image 2.50.603High quality, prompt rewriting
mai-image-2.5-flashMAI-Image 2.5 Flash0.201Fast, budget-friendly

Size constraints: min 768px per dimension, max ~1024x1024 (1,056,768 total pixels). Supported aspect ratios: 1:1, 16:9, 9:16, 4:3, 3:4.

BytePlus SeedDream (Token-Based)

Model IDName~PLN @1KCreditsNotes
seedream-4-0-250828SeedDream 4.00.182token-based
seedream-5-0-260128SeedDream 5.0 Lite0.212Recommended, best value
seedream-4-5-251128SeedDream 4.50.243token-based
dola-seedream-5-0-pro-260628SeedDream 5.0 Pro (Dola)0.273token-based
seededit-3-0-i2i-250628SeedEdit 3.0 (img2img)0.243token-based

xAI (Grok Imagine)

Model IDNamePrice (PLN)CreditsNotes
grok-imagine-imageGrok Imagine0.1211K, single-image edit
grok-imagine-image-qualityGrok Imagine Quality0.3632K, multi-image combine (up to 3 refs), virtual try-on

xAI Grok Image — Capabilities

Featuregrok-imagine-imagegrok-imagine-image-quality
Text-to-ImageYesYes
Single Image EditYesYes
Multi-Image Combine (up to 3)Yes
Virtual Try-OnYes
Max Resolution1K2K
Max num_images per request1010
Aspect Ratios77

Supported Aspect Ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9

xAI Grok Models

Grok Imagine Quality is ideal for e-commerce: multi-image product listings, virtual try-on, and high-quality edits at 2K resolution. The basic model is a fast, budget-friendly option for social media and quick prototypes at 1K.

Black Forest Labs — FLUX (via Azure AI)

4 active FLUX models routed through Azure AI. Maximum resolution: 1440px per side.

Model IDNamePrice (PLN)CreditsNotes
flux-1.1-proFLUX 1.1 Pro0.242high quality, creative
flux-kontext-proFLUX Kontext Pro0.242context-aware editing, style transfer
flux-2-proFLUX.2 Pro0.242balanced, versatile
flux-2-flexFLUX.2 Flex0.242steps/guidance control

FLUX via Azure

All FLUX models are served via Azure AI infrastructure for reliable, low-latency inference. Maximum dimension is 1440px per side. Models previously available (Klein, Ultra, Raw, Max, Fill) have been discontinued.

MiniMax (Temporarily Unavailable)

Model IDNamePrice (PLN)CreditsNotes
minimax-image-01MiniMax Image 010.0211budget — currently unavailable

Kling (Temporarily Unavailable)

Model IDNamePrice (PLN)CreditsNotes
kling-v2-1Kling V2.10.242currently unavailable
kling-v3Kling V30.605currently unavailable
kling-v3-omniKling V3 Omni0.908currently unavailable

Temporarily Unavailable

Kling and MiniMax models are temporarily unavailable due to provider issues. They will be restored when provider accounts are replenished.

Code Examples

Basic Image Generation

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "A serene mountain landscape at golden hour, with mist rolling through valleys",
        "model": "seedream-5-0-260128",
        "aspect_ratio": "16:9"
    }
)

data = response.json()
print(f"Image URL: {data['images'][0]}")
print(f"Credits used: {data['credits_used']}")
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "A serene mountain landscape at golden hour, with mist rolling through valleys",
    model: "seedream-5-0-260128",
    aspect_ratio: "16:9"
  })
});

const data = await response.json();
console.log("Image URL:", data.images[0]);
console.log("Credits used:", data.credits_used);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A serene mountain landscape at golden hour, with mist rolling through valleys",
    "model": "seedream-5-0-260128",
    "aspect_ratio": "16:9"
  }'

Token-Based Model (SeedDream)

python
import requests

# SeedDream models use token-based billing — cost scales with resolution
response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Professional product photography of a luxury watch on marble surface",
        "model": "seedream-5-0-260128",
        "width": 2048,
        "height": 2048
    }
)

data = response.json()
print(f"Image URL: {data['images'][0]}")
print(f"Output tokens: {data['usage']['output_tokens']}")
print(f"Cost (PLN): {data['billing']['cost_breakdown']['cost_pln']}")
# At 2048x2048: 16,384 tokens → ~0.197 PLN
typescript
// SeedDream models use token-based billing — cost scales with resolution
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Professional product photography of a luxury watch on marble surface",
    model: "seedream-5-0-260128",
    width: 2048,
    height: 2048
  })
});

const data = await response.json();
console.log("Image URL:", data.images[0]);
console.log("Output tokens:", data.usage.output_tokens);
console.log("Cost (PLN):", data.billing.cost_breakdown.cost_pln);
// At 2048x2048: 16,384 tokens → ~0.197 PLN
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Professional product photography of a luxury watch on marble surface",
    "model": "seedream-5-0-260128",
    "width": 2048,
    "height": 2048
  }'

High-Resolution 4K Generation

python
import requests

# Imagen 4 Ultra and FLUX Pro Ultra support native 4K output
response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Ultra detailed architectural visualization of a modern glass house, surrounded by nature, photorealistic 8K quality",
        "model": "imagen-4-ultra",
        "width": 4096,
        "height": 2304,
        "aspect_ratio": "16:9"
    }
)

data = response.json()
print(f"4K Image: {data['images'][0]}")
print(f"Credits: {data['credits_used']}")  # 5 credits for ultra
typescript
// Imagen 4 Ultra and FLUX Pro Ultra support native 4K output
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Ultra detailed architectural visualization of a modern glass house, surrounded by nature, photorealistic 8K quality",
    model: "imagen-4-ultra",
    width: 4096,
    height: 2304,
    aspect_ratio: "16:9"
  })
});

const data = await response.json();
console.log("4K Image:", data.images[0]);
console.log("Credits:", data.credits_used); // 5 credits for ultra
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Ultra detailed architectural visualization of a modern glass house, surrounded by nature, photorealistic 8K quality",
    "model": "imagen-4-ultra",
    "width": 4096,
    "height": 2304,
    "aspect_ratio": "16:9"
  }'

Generate Multiple Variations

python
import requests

# Generate 4 variations in a single request
response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Minimalist logo design for a tech startup, clean vector style",
        "model": "flux-2-max",
        "num_images": 4,
        "aspect_ratio": "1:1"
    }
)

data = response.json()
# Credits charged: 4 images x 4 credits = 16 credits total
for i, url in enumerate(data["images"]):
    print(f"Variation {i+1}: {url}")
print(f"Total credits: {data['credits_used']}")
typescript
// Generate 4 variations in a single request
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Minimalist logo design for a tech startup, clean vector style",
    model: "flux-2-max",
    num_images: 4,
    aspect_ratio: "1:1"
  })
});

const data = await response.json();
// Credits charged: 4 images x 4 credits = 16 credits total
data.images.forEach((url: string, i: number) => {
  console.log(`Variation ${i + 1}: ${url}`);
});
console.log("Total credits:", data.credits_used);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Minimalist logo design for a tech startup, clean vector style",
    "model": "flux-2-max",
    "num_images": 4,
    "aspect_ratio": "1:1"
  }'

Negative Prompt & Style Preset

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Portrait of a woman in Renaissance style, oil painting, dramatic lighting, rich colors",
        "model": "flux-kontext-max",
        "negative_prompt": "blurry, low quality, distorted, deformed, watermark, text overlay, cartoon",
        "style": "oil-painting",
        "aspect_ratio": "3:4",
        "seed": 42  # Use seed for reproducible results
    }
)

data = response.json()
print(f"Image: {data['images'][0]}")
print(f"Seed used: {data['metadata']['seed']}")  # 42 — same result every time
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Portrait of a woman in Renaissance style, oil painting, dramatic lighting, rich colors",
    model: "flux-kontext-max",
    negative_prompt: "blurry, low quality, distorted, deformed, watermark, text overlay, cartoon",
    style: "oil-painting",
    aspect_ratio: "3:4",
    seed: 42 // Use seed for reproducible results
  })
});

const data = await response.json();
console.log("Image:", data.images[0]);
console.log("Seed used:", data.metadata.seed); // 42 — same result every time
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Portrait of a woman in Renaissance style, oil painting, dramatic lighting, rich colors",
    "model": "flux-kontext-max",
    "negative_prompt": "blurry, low quality, distorted, deformed, watermark, text overlay, cartoon",
    "style": "oil-painting",
    "aspect_ratio": "3:4",
    "seed": 42
  }'

xAI Grok Imagine — Advanced Use Cases

Grok Imagine models support generation, editing, multi-image combine, and virtual try-on through a unified API.

Product Launch (Text-to-Image, 2K)

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Premium product photography of a luxury perfume bottle on marble surface, "
                  "dramatic studio lighting, soft shadows, bokeh background, commercial quality",
        "model": "grok-imagine-image-quality",
        "aspect_ratio": "2:3",
        "num_images": 1
    }
)

data = response.json()
print(f"2K product shot: {data['images'][0]}")
# 3 credits, 2K resolution, portrait 2:3 aspect
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Premium product photography of a luxury perfume bottle on marble surface, " +
            "dramatic studio lighting, soft shadows, bokeh background, commercial quality",
    model: "grok-imagine-image-quality",
    aspect_ratio: "2:3",
    num_images: 1
  })
});

const data = await response.json();
console.log("2K product shot:", data.images[0]);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Premium product photography of a luxury perfume bottle on marble surface, dramatic studio lighting, soft shadows, bokeh background, commercial quality",
    "model": "grok-imagine-image-quality",
    "aspect_ratio": "2:3",
    "num_images": 1
  }'

Social Media Post (Text-to-Image, 1K)

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Trendy flat-lay coffee shop photo, latte art, notebook and laptop, "
                  "warm tones, Instagram aesthetic, overhead shot",
        "model": "grok-imagine-image",
        "aspect_ratio": "1:1",
        "num_images": 4
    }
)

data = response.json()
# 4 variations at 1 credit each = 4 credits total
for i, url in enumerate(data["images"]):
    print(f"Variation {i+1}: {url}")
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Trendy flat-lay coffee shop photo, latte art, notebook and laptop, warm tones, Instagram aesthetic",
    "model": "grok-imagine-image",
    "aspect_ratio": "1:1",
    "num_images": 4
  }'

Product Display Edit (Single Reference Image)

Edit an existing product photo — change background, lighting, or context while preserving the product.

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Place this product in a modern minimalist kitchen, marble countertop, "
                  "soft natural window light, lifestyle photography",
        "model": "grok-imagine-image-quality",
        "aspect_ratio": "3:4",
        "image_url": "https://your-storage.com/product-photo.jpg"
    }
)

data = response.json()
print(f"Edited product: {data['images'][0]}")
# 3 credits — single image edit mode
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Place this product in a modern minimalist kitchen, marble countertop, " +
            "soft natural window light, lifestyle photography",
    model: "grok-imagine-image-quality",
    aspect_ratio: "3:4",
    image_url: "https://your-storage.com/product-photo.jpg"
  })
});

const data = await response.json();
console.log("Edited product:", data.images[0]);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Place this product in a modern minimalist kitchen, marble countertop, soft natural window light",
    "model": "grok-imagine-image-quality",
    "aspect_ratio": "3:4",
    "image_url": "https://your-storage.com/product-photo.jpg"
  }'

Combined Product Listing (Multi-Image, up to 3 References)

Combine multiple product images into a single cohesive composition. Only available with grok-imagine-image-quality.

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Arrange all products in an elegant flat-lay composition, "
                  "clean white background, consistent lighting, e-commerce catalog style",
        "model": "grok-imagine-image-quality",
        "aspect_ratio": "1:1",
        "image_urls": [
            "https://your-storage.com/product-1.jpg",
            "https://your-storage.com/product-2.jpg",
            "https://your-storage.com/product-3.jpg"
        ]
    }
)

data = response.json()
print(f"Combined listing: {data['images'][0]}")
# 3 credits — multi-image combine mode (max 3 reference images)
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Arrange all products in an elegant flat-lay composition, " +
            "clean white background, consistent lighting, e-commerce catalog style",
    model: "grok-imagine-image-quality",
    aspect_ratio: "1:1",
    image_urls: [
      "https://your-storage.com/product-1.jpg",
      "https://your-storage.com/product-2.jpg",
      "https://your-storage.com/product-3.jpg"
    ]
  })
});

const data = await response.json();
console.log("Combined listing:", data.images[0]);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Arrange all products in an elegant flat-lay composition, clean white background, consistent lighting",
    "model": "grok-imagine-image-quality",
    "aspect_ratio": "1:1",
    "image_urls": [
      "https://your-storage.com/product-1.jpg",
      "https://your-storage.com/product-2.jpg",
      "https://your-storage.com/product-3.jpg"
    ]
  }'

Multi-Image Limits

  • Maximum 3 reference images per request
  • Only available with grok-imagine-image-quality model
  • All images must be publicly accessible URLs or FOTOhub storage URLs
  • Higher resolution images produce better combine results

Virtual Try-On (2 References — Person + Garment)

Show a person wearing a specific garment or accessory. Provide the person photo and the product image.

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/generate/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Virtual try-on: person wearing the garment from second image, "
                  "natural fit, correct proportions, photorealistic, keep person's face and body",
        "model": "grok-imagine-image-quality",
        "aspect_ratio": "3:4",
        "image_urls": [
            "https://your-storage.com/model-photo.jpg",     # Person
            "https://your-storage.com/dress-product.jpg"    # Garment
        ]
    }
)

data = response.json()
print(f"Try-on result: {data['images'][0]}")
# 3 credits — virtual try-on mode via multi-image
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/generate/image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Virtual try-on: person wearing the garment from second image, " +
            "natural fit, correct proportions, photorealistic",
    model: "grok-imagine-image-quality",
    aspect_ratio: "3:4",
    image_urls: [
      "https://your-storage.com/model-photo.jpg",
      "https://your-storage.com/dress-product.jpg"
    ]
  })
});

const data = await response.json();
console.log("Try-on result:", data.images[0]);
bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/image \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Virtual try-on: person wearing the garment from second image, natural fit, photorealistic",
    "model": "grok-imagine-image-quality",
    "aspect_ratio": "3:4",
    "image_urls": [
      "https://your-storage.com/model-photo.jpg",
      "https://your-storage.com/dress-product.jpg"
    ]
  }'

Virtual Try-On Best Practices

  1. Person image first — full-body or half-body shot, clear pose, neutral background
  2. Garment image second — flat-lay or mannequin shot showing full garment
  3. Use 3:4 or 2:3 aspect ratio for best full-body results
  4. Include "keep person's face" in prompt to preserve identity
  5. Works with clothing, accessories, eyewear, hats, shoes

Image Editing

Modify existing images with AI-powered editing operations including inpainting, outpainting, background replacement, object removal, and upscaling.

Endpoint

POST /v1/ai/edit/image

Billing: 2 credits per edit (fixed, regardless of mode or resolution)

Parameters

ParameterTypeRequiredDescription
image_urlstringYesURL of the source image. Must be publicly accessible or a FOTOhub storage URL.
promptstringYesDescription of the desired edit.
modestringYes"inpaint", "outpaint", "bgswap", "remove", or "upscale"
mask_urlstringNoMask image URL (white = edit area). Required for "inpaint" mode.

Editing Examples

python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/edit/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "image_url": "https://s1.fotohub.app/storage/v1/object/public/uploads/photo.jpg",
        "prompt": "Professional studio background with soft gradient lighting",
        "mode": "bgswap"
    }
)

data = response.json()
print(f"Edited image: {data['images'][0]}")
python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/edit/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "image_url": "https://s1.fotohub.app/storage/v1/object/public/uploads/room.jpg",
        "prompt": "A modern minimalist sofa with clean lines",
        "mode": "inpaint",
        "mask_url": "https://s1.fotohub.app/storage/v1/object/public/uploads/room_mask.png"
    }
)

data = response.json()
print(f"Edited image: {data['images'][0]}")
python
import requests

response = requests.post(
    "https://apis.fotohub.app/v1/ai/edit/image",
    headers={
        "Authorization": "Bearer fh_live_your_api_key",
        "Content-Type": "application/json"
    },
    json={
        "image_url": "https://s1.fotohub.app/storage/v1/object/public/uploads/low_res.jpg",
        "prompt": "Enhance resolution, preserve details, sharpen edges",
        "mode": "upscale"
    }
)

data = response.json()
print(f"Upscaled image: {data['images'][0]}")

Error Responses

StatusCodeDescription
400invalid_modelThe specified model does not exist or is not available for image generation.
400invalid_dimensionsWidth or height is out of range (256–4096) or not divisible by 64.
400invalid_promptPrompt is empty, exceeds maximum length (4096 chars), or contains blocked content.
401unauthorizedMissing or invalid API key. Ensure the Authorization header uses format: Bearer fh_live_*
402insufficient_creditsAccount does not have enough credits. Purchase more or upgrade your plan.
429rate_limit_exceededToo many requests. Default: 20 req/min for image generation. Check Retry-After header.
500generation_failedUpstream provider error. No credits are charged on failure.

Error Response Example

json
{
  "error": {
    "code": "insufficient_credits",
    "message": "Insufficient credits. Required: 3, available: 1. Please top up your account.",
    "status": 402,
    "details": {
      "required_credits": 3,
      "available_credits": 1,
      "model": "imagen-4-standard"
    }
  }
}

No Charge on Failure

If a generation fails due to a provider error (500), your credits are not deducted. You will only be charged for successful generations that return image URLs.