Skip to main content

Image to Image

Use image-to-image generation for tasks like upscaling, style transfer, image enhancement, and image variation.

Image to Image

Use image-to-image generation for tasks like upscaling, style transfer, image enhancement, and image variation.

Step 1: Upload or Reference an Image

First, you need to provide the source image. You can either:
  • Upload an image file as base64
  • Provide a publicly accessible image URL
import requests
import base64

API_BASE = "https://api.krea.ai/"
API_TOKEN = "YOUR_API_TOKEN"

# Option 1: Using base64 encoded image
with open("input_image.jpg", "rb") as image_file:
    encoded_image = base64.b64encode(image_file.read()).decode('utf-8')

# Option 2: Using image URL
image_url = "https://example.com/input-image.jpg"
Replace with your API TokenTo replace the YOUR_API_TOKEN placeholder in the above examples, you’ll need to generate an API token in krea.ai/settings/api-tokens. Follow the instructions on the API Keys & Billing page if you need help.

Step 2: Generate Image

Make a POST request to the appropriate endpoint with your image and parameters.
curl -X POST https://api.krea.ai/generate/image/google/nano-banana-pro\
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/input-image.jpg",
    "prompt": "enhance details and clarity",
    "scale": 2,
    "steps": 20
  }'
Example Response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued",
  "created_at": "2025-01-15T10:30:00.000Z"
}

Step 3: Poll for Results

Image generation is asynchronous. You’ll receive a job ID immediately, then poll for results until the image is ready. Poll /jobs/{job_id} every 2 seconds until the job completes.
curl -X GET https://api.krea.ai/jobs/YOUR_JOB_ID \
  -H "Authorization: Bearer YOUR_API_TOKEN"
Example Completed Response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "created_at": "2025-01-15T10:30:00.000Z",
  "completed_at": "2025-01-15T10:30:35.000Z",
  "result": {
    "urls": [
      "https://krea.ai/generations/your-enhanced-image.png"
    ]
  }
}
Webhooks available!Set up webhooks to receive notifications when jobs complete. See the Webhooks guide to get started.

Common Parameters

For a list of detailed parameters for all models, see the Model APIs page.
ParameterTypeDescription
image_urlstringURL of the input image
promptstringDescription of desired transformation
scalenumberUpscaling factor (1-4)
stepsnumberGeneration steps (more steps = higher quality)
strengthnumberHow much to transform the image (0.0-1.0)