Introduction to Image Inference

Learn about Runware's image generation capabilities and common parameters for all image inference tasks, including text-to-image, image-to-image, inpainting, outpainting and more.

Introduction

Image Inference is the core technology that powers Runware's image generation and manipulation features. When you're creating images from text descriptions, transforming existing images, or performing specialized editing operations, you're using our Sonic Inference Engine®.

For the core API parameters common to all Runware endpoints, please refer to our Getting Started Introduction. That guide covers the fundamental concepts that apply across all Runware APIs.

This page covers the common parameters and concepts shared across all image inference operations. Understanding these fundamentals will help you work effectively with any of our image-related APIs.

[
  {
    // Core parameters
    "taskType": "imageInference",
    "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
    "includeCost": true,

    // Image-related parameters
    "outputType": "URL",
    "outputFormat": "JPG",
    "outputQuality": 95,
    "numberResults": 2,
    "checkNSFW": true,

    // Task parameters
    "model": "runware:101@1",
    "positivePrompt": "a serene landscape with mountains and a lake",
    "width": 1024,
    "height": 1024
  }
]

Image inference features

Our API offers several core image generation approaches:

Feature Description Key Parameters
Text-to-imageGenerate images from textual descriptions.positivePrompt
Image-to-imageTransform existing images guided by text prompts.seedImage + strength
InpaintingSelectively modify specific areas of an image using a mask.seedImage + maskImage
OutpaintingExtend images beyond their original boundaries.seedImage + outpaint

These core features can be enhanced with additional technologies:

Feature Description Key Parameters
RefinerImprove or enhance previously generated images.refiner
ControlNetAdd structural guidance using reference images.controlNet
LoRAApply specialized style or subject adaptation.lora
IP-AdapterIncorporate visual reference for style and content from existing images.ipAdapters
EmbeddingsUse custom concepts and styles across generations.embeddings

All these functionalities use the imageInference task type, differentiated by the specific parameters you include.

Common image inference parameters

While each image operation has its specific parameters, several parameters are common across all image inference tasks.

outputType
"base64Data" | "dataURI" | "URL" Default: URL

Specifies the output type in which the image is returned. Supported values are: dataURI, URL, and base64Data.

  • base64Data: The image is returned as a base64-encoded string using the imageBase64Data parameter in the response object.
  • dataURI: The image is returned as a data URI string using the imageDataURI parameter in the response object.
  • URL: The image is returned as a URL string using the imageURL parameter in the response object.
outputFormat
"JPG" | "PNG" | "WEBP" Default: JPG

Specifies the format of the output image. Supported formats are: PNG, JPG and WEBP.

outputQuality
integer Min: 20 Max: 99 Default: 95

Sets the compression quality of the output image. Higher values preserve more quality but increase file size, lower values reduce file size but decrease quality.

This parameter allows you to specify a URL to which the generated image will be uploaded as binary image data using the HTTP PUT method. For example, an S3 bucket URL can be used as the upload endpoint.

When the image is ready, it will be uploaded to the specified URL.

checkNSFW
boolean Default: false

This parameter is used to enable or disable the NSFW check. When enabled, the API will check if the image contains NSFW (not safe for work) content. This check is done using a pre-trained model that detects adult content in images.

When the check is enabled, the API will return NSFWContent: true in the response object if the image is flagged as potentially sensitive content. If the image is not flagged, the API will return NSFWContent: false.

If this parameter is not used, the parameter NSFWContent will not be included in the response object.

Adds 0.1 seconds to image inference time and incurs additional costs.

The NSFW filter occasionally returns false positives and very rarely false negatives.

numberResults
integer Min: 1 Max: 20 Default: 1

The number of images to generate from the specified prompt.

If seed is set, it will be incremented by 1 (+1) for each image generated.

Here's a simple text-to-image request illustrating the common parameters:

[
  {
    "taskType": "imageInference",
    "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
    "model": "runware:101@1",
    "positivePrompt": "a serene landscape with mountains and a lake",
    "width": 1024,
    "height": 1024,
    "outputType": "URL",
    "outputFormat": "JPG",
    "outputQuality": 95,
    "numberResults": 2,
    "checkNSFW": true,
    "includeCost": true
  }
]

Common response fields

All image inference operations return a consistent set of fields:

imageUUID
string UUID v4

The unique identifier of the image.

imageURL
string

If outputType is set to URL, this parameter contains the URL of the image to be downloaded.

If outputType is set to base64Data, this parameter contains the base64-encoded image data.

imageDataURI
string

If outputType is set to dataURI, this parameter contains the data URI of the image.

seed
integer

The seed value that was used to generate this image. This value can be used to reproduce the same image when using identical parameters in another request.

NSFWContent
boolean

If checkNSFW parameter is used, NSFWContent is included informing if the image has been flagged as potentially sensitive content.

  • true indicates the image has been flagged (is a sensitive image).
  • false indicates the image has not been flagged.

The filter occasionally returns false positives and very rarely false negatives.

Here’s the response to the previous request, illustrating the common parameters:

{
  "data": [
    {
      "taskType": "imageInference",
      "imageUUID": "97ae27b6-1d52-4815-a5d6-301428d668b1",
      "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
      "NSFWContent": false,
      "cost": 0.0027,
      "seed": 3614157524222286418,
      "imageURL": "https://im.runware.ai/image/ws/2/ii/97ae27b6-1d52-4815-a5d6-301428d668b1.jpg"
    },
    {
      "taskType": "imageInference",
      "imageUUID": "a70ec6e4-8845-45b3-9993-bd02a6d7f88e",
      "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
      "NSFWContent": false,
      "cost": 0.0027,
      "seed": 3614157524222286419,
      "imageURL": "https://im.runware.ai/image/ws/2/ii/a70ec6e4-8845-45b3-9993-bd02a6d7f88e.jpg"
    }
  ]
}

Specialized guides

For detailed information about specific image inference operations, see these dedicated guides: