Getting Started

This guide walks you through making your first image generation request with ViralAPI.

Prerequisites

Step 1: Create a Task

Send a POST request to create an image generation task:

curl -X POST https://viralapi.ai/v1/task/create \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gemini-2.5-flash-image",
    "task_type": "image",
    "input": {
      "prompt": "A serene mountain landscape at sunset with vibrant colors",
      "aspect_ratio": "16:9"
    }
  }'

Response:

Step 2: Poll for Results

Use the task_id to check the task status:

Response (completed):

Step 3: Download the Image

When status is completed, the results array contains the generated image URLs. Download them before they expire (24-hour validity).

Using NanoBanana Pro

For higher quality output, switch to the Pro model:

The Pro model additionally supports image_size parameter (1K, 2K, 4K).

Image Editing

To edit an existing image, add image_urls to the input:

The presence of image_urls switches the operation from text-to-image to image editing. Up to 10 images are supported.

Next Steps

Last updated