> For the complete documentation index, see [llms.txt](https://documentation.deep-image.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.deep-image.ai/image-processing/image-generation.md).

# Image generation

## Background/generate parameters

Let's see all the parameters of background generate section that can be used in image generation API. They will be described in detail down below.

<table><thead><tr><th width="270">Field name</th><th>Description</th></tr></thead><tbody><tr><td>model_type</td><td><p>This parameter chooses model which will be used for image generation, realistic is the default one:</p><ul><li>gemini-3-pro-image-preview</li><li>see-dream-4.5</li><li>qwen</li><li>flux2-klein9b</li><li>z-image-turbo</li><li>realistic</li><li>fantasy</li><li>premium</li><li>google-gemini-image-flash</li></ul></td></tr><tr><td>description</td><td>Generation prompt. By default "high quality, highly detailed, 8K" phrase is added to it.</td></tr><tr><td>sample_num</td><td>Works like generator random seed.</td></tr><tr><td>adapter_type</td><td><p>This parameter controls how generator will use the input image.</p><ul><li><strong>generate_background -</strong> (default value) background is generated around the main object found in the input image</li><li><strong>face</strong> - generator will use first found face of the input image to create an avatar</li><li><strong>control</strong> - (also known as "image to image") generator will generate image based on image and image edges, it's useful for adding details to existing photos, f.e. adding furniture to empty room</li><li><strong>control2</strong> - generator will generate image based only on image edges, it's useful for generating images from drawings</li><li><strong>upscale</strong> - used for specifying prompts for generative upscale</li><li><strong>inpainting</strong> - described in <a href="/pages/9u6p1oSHO6k6sYsvsLvj">separated chapter</a> </li></ul></td></tr><tr><td>face_id</td><td>true/false - Works only when adapter_type is face. Selects different face generation algorithm when just face details are used (skips for example hair style from original photo).</td></tr><tr><td>controlnet_conditioning_scale</td><td>Float value from 0 to 1 describes how much edges will be preserved. Default value is 0.5</td></tr></tbody></table>

Let's check some examples.

## Based on text only

Image can be generated based on text prompt in given resolution.

```json
{
    "width": 2048,
    "height": 1024,
    "background": {
        "generate": {
            "description": "woman in a futuristic suit holding a gun in her hand, looking at the camera, cyberpunk art, neo-figurative, anime"
        }
    }
}
```

And the result:

<figure><img src="/files/Q8hfuoOSjrbWmxYE5IaH" alt=""><figcaption></figcaption></figure>

Now, the same prompt but with **fantasy** model:

```json
{
    "width": 2048,
    "height": 1024,
    "background": {
        "generate": {
            "description": "woman in a futuristic suit holding a gun in her hand, looking at the camera, cyberpunk art, neo-figurative, anime",
            "model_type": "fantasy"
        }
    }
}
```

<figure><img src="/files/xlPT2d9QOLGg5UyfINqx" alt=""><figcaption></figcaption></figure>

Now, the same prompt but with **premium** model:

```json
{
    "width": 2048,
    "height": 1024,
    "background": {
        "generate": {
            "description": "woman in a futuristic suit holding a gun in her hand, looking at the camera, cyberpunk art, neo-figurative, anime",
            "model_type": "premium"
        }
    }
}
```

<figure><img src="/files/mjuoGGSLegd1DgCBM8VH" alt=""><figcaption></figcaption></figure>

## Based on image

Images can be generated based on face details or image canny edges.

Let's check some examples.

```json
{
    "url": "https://deep-image.ai/api-example.png",
    "width": 1024,
    "height": 1024,
    "background": {
        "generate": {
            "description": "item on the beach",
            "adapter_type": "generate_background"
        }
    }
}
```

And the result

<figure><img src="/files/HzkeMNaCShSolieHcHps" alt="" width="563"><figcaption></figcaption></figure>

```json
{
    "url": "https://deep-image.ai/api-example3.jpg",
    "width": 1024,
    "height": 1024,
    "background": {
        "generate": {
            "description": "model on the beach",
            "adapter_type": "face"
        }
    }
}
```

And the result

<figure><img src="/files/yeBLrUffrn5rfsqZ9mj8" alt="" width="563"><figcaption></figcaption></figure>

```json
{
    "url": "https://deep-image.ai/api-example3.jpg",
    "background": {
        "generate": {
            "description": "model in the room",
            "adapter_type": "control"
        }
    }
}
```

And the result

<figure><img src="/files/I2nqo7dGst4wg9lxKWWq" alt=""><figcaption></figcaption></figure>

## Generative upscaling

Let's try to use generative upscaling. This algorithm can do some real magic :slight\_smile:. It also modifies image slightly because it's based on diffusion algorithm so do not use it when you really want to preserve exact image colors and original image details.

```json
{
    "url": "https://deep-image.ai/api-example.png",
    "width": 3000,
    "generative_upscale": true
}
```

{% tabs %}
{% tab title="Curl" %}

```
curl --request POST \
     --url https://deep-image.ai/rest_api/process_result \
     --header 'content-type: application/json' \
     --header 'x-api-key: API_KEY' \
     --data '{
         "url": "https://deep-image.ai/api-example.png",
         "width": 3000,
         "generative_upscale": true
      }'
```

{% endtab %}

{% tab title="Python client" %}

```python
import os

import deep_image_ai_client

configuration = deep_image_ai_client.Configuration(
    host="https://deep-image.ai"
)

configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

with deep_image_ai_client.ApiClient(configuration) as api_client:
    api_instance = deep_image_ai_client.DefaultApi(api_client)
    process_payload = {"url": "https://deep-image.ai/api-example.jpg", "width": 3000, generative_upscale: True}
    api_response = api_instance.rest_api_process_result_post(process_payload)

```

{% endtab %}
{% endtabs %}

And the result:

<figure><img src="/files/sF1XWGQYkdYOF3OsN9cE" alt=""><figcaption><p>Generative upscale result</p></figcaption></figure>
