# 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="inpainting-and-outpainting-uncrop">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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2F75XEfEHTfC30mz2jQbvS%2Fimage.png?alt=media&#x26;token=a5c407f0-668a-436f-ae0c-ac23b73086b3" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2F25dt967C4nHpDlDqcDac%2Fb6f15f7c-8faa-11ef-ab53-0242ac12000a-width%3D2048_height%3D1024_generated.png?alt=media&#x26;token=48d6c6c2-1908-4fc7-b71e-3c230bbafa8a" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2F0lWxYAkYyuPPiZXbu0Pr%2Fc1439bc8-6143-11f0-b25e-7667abbf5f9e-width%3D2048_height%3D1024_generated.png?alt=media&#x26;token=aeef6321-916b-410b-aa28-a6ee0cecbe53" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2F5z9QDzN1WXXg0srd7RTl%2Fff3ef5d6-510d-4bd9-a3c9-47b7b4f8ec69-width%3D1024_height%3D1024.png?alt=media&#x26;token=3cf44e68-ba55-4931-b8b7-ed751fd35468" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2FpuuFMikLJf6loUVs3X8H%2F2fcd8c20-19ae-49b8-b549-40b34271bb29-width%3D1024_height%3D1024.jpg?alt=media&#x26;token=28a3a927-59d7-4ee0-b2c9-dcfaaa7d7e9f" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2F8WGDYVnLJngOO7k1c6ca%2Fc80d3513-e741-46ef-8cd9-4e9da29db7bc-6eb17056-c680-11ee-8bc7-0242ac18000a.jpg?alt=media&#x26;token=cf27cf55-44f5-4f3e-960b-8e5932b2dc97" 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="https://2652559519-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3i5YcUkcXyIsWHIhRO2d%2Fuploads%2FZa9sTyAZ2jMeCsyC4PQg%2Fapi-example-width%3D3000-84d09a96.png?alt=media&#x26;token=2c6c267b-4a07-414a-b3ff-80fae6c5c80c" alt=""><figcaption><p>Generative upscale result</p></figcaption></figure>
