Image Generation

The image API is task-based. Fetch the model list, estimate credits first, then create the generation task with optional reference assets.

Recommended Flow

  1. Call GET /v1i/models to discover supported model parameters.
  2. Call POST /v1i/task/price to estimate credits for the exact request.
  3. Call POST /v1i/task/generate-image with multipart form data.
  4. Poll GET /v1/task/:task_id or use receive_url.

List Models

http
GET https://api.cheapaiapi.com/v1i/models

Use this endpoint to discover model IDs, supported aspect ratios, resolutions, and whether reference images are accepted.

Estimate Credits

bash
curl -X POST "https://api.cheapaiapi.com/v1i/task/price" \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": "bytedance-seedream-4.5",
    "generations_count": 1,
    "model_parameters": {
      "aspect_ratio": "16:9",
      "resolution": "2K"
    },
    "assets": 2
  }'
json
{
  "success": true,
  "credits": 1188
}

Create Task

bash
curl -X POST "https://api.cheapaiapi.com/v1i/task/generate-image" \
  -H "Authorization: Bearer sk_your_api_key" \
  -F 'prompt=Merge @img2 into @img1 while keeping the original outfit' \
  -F 'model_id=bytedance-seedream-4.5' \
  -F 'generations_count=1' \
  -F 'model_parameters={"aspect_ratio":"1:1","resolution":"2K"}' \
  -F 'assets=@image1.png' \
  -F 'assets=@image2.png'

Reference Assets

Reference images are sent as repeated assets fields in multipart form data.

Inside the prompt, refer to uploaded files using @img1, @img2, and so on.

The number of @img references should match the number of uploaded assets.

Request Fields

promptstringrequiredImage prompt. Can include @img references for uploaded assets.
model_idstringrequiredModel ID from the image models endpoint.
generations_countintegerHow many images to generate for the request.
model_parametersobjectModel-specific settings such as aspect ratio or resolution.
assetsfile[]Optional source images. Send multiple assets fields when needed.
receive_urlstringOptional webhook URL for task completion.

Task Result

json
{
  "id": "abc123",
  "type": "imagen2",
  "status": "done",
  "progress": 100,
  "credit_cost": 1188,
  "metadata": {
    "result_images": [
      {
        "id": "img_001",
        "imageUrl": "https://...",
        "previewUrl": "https://...",
        "mimeType": "image/png",
        "width": 1920,
        "height": 1080
      }
    ]
  }
}

Tips For Good UX

  • Always show the price-check result before the final submit action.
  • Preview selected model parameters so users know exactly what they are paying for.
  • When assets are attached, surface the @img1 mapping clearly in the UI.
  • After submission, switch the user immediately into task-tracking state instead of waiting synchronously.