# Generate Image

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/ml/general/generate_image:
    post:
      summary: Generate Image
      deprecated: false
      description: >-
        Generates an image based on text prompt.


        ## Body Parameters


        | **Parameter**  | **Type** | **Required?**            |
        **Description**                                                                                                            
        |

        |----------------|----------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------|

        | prompt         | String   | yes                      | Image
        generation
        prompt.                                                                                                   
        |

        | model_type     | String   | no (default "small")     | Model type, one
        of: "small", "medium", "large". Larger models have higher quality,
        longer generation time, and higher cost. |

        | aspect_ratio   | String   | no (default "1:1")       | Image aspect
        ratio, one of: "1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "16:9",
        "9:16".                                |

        | image_size     | String   | no (default "thumbnail") | Image size, one
        of: "thumbnail" (256 px), "small" (512 px), "medium" (1024 px), "large"
        (1440 px).                          |

        | creativity     | Integer  | no (default 2)           | Variability and
        creativity of image generation. Only used in "medium" and "large"
        models.                                   |

        | photorealistic | Boolean  | no (default false)       | If true,
        generate photorealistic images. Only used in "large"
        model.                                                        |

        | random_seed    | Integer  | no (default null)        | If set, it
        results in deterministic
        generation.                                                                             

        **Warning:** for model size "small", image size must be "thumbnail" or
        "medium"'


        ## Example


        ```shell

        curl -X POST \
            "https://api.mpc.placewise.com/v1/ml/general/generate_image"  \
            -H 'Content-Type: application/json' \
            -H 'Authorization: Bearer B7t9U9tsoWsGhrv2ouUoSqpM' \
            -H 'x-product-name: default' \
            -H 'x-user-agent: CURL manual test' \
            -d \
                '{ 
                "prompt": "Minimalistic cheesecake cartoon image",
                "model_type": "small",
                "aspect_ratio": "1:1",
                "image_size": "thumbnail",
                "creativity": 2,
                "photorealistic": False,
                "random_seed": 1,
                }'
        ```


        > When successful, returns:

        ```

        {
            'image_generation_task': {
                'id': 1
            }
        }

        ```
      tags:
        - API Reference/ML API
      parameters:
        - name: Content-Type
          in: header
          description: '[Details](doc-341635)'
          required: true
          example: application/json
          schema:
            type: string
            default: application/json
            const: application/json
        - name: X-User-Agent
          in: header
          description: Arbitrary identifier of your client. [Details](doc-341635)
          required: true
          example: '{{X_USER_AGENT}}'
          schema:
            type: string
            default: '{{X_USER_AGENT}}'
        - name: X-Product-Name
          in: header
          description: API Product for API context. [Details](doc-341635)
          required: true
          example: '{{PRODUCT_NAME}}'
          schema:
            type: string
            default: '{{PRODUCT_NAME}}'
        - name: X-Loyalty-Club-Slug
          in: header
          description: LoyaltyClub for API context. [Details](doc-342138)
          required: false
          example: '{{LOYALTY_CLUB_SLUG}}'
          schema:
            type: string
            default: '{{LOYALTY_CLUB_SLUG}}'
        - name: Authorization
          in: header
          description: '[Member](doc-342129) or [User](doc-342130) Authorization.'
          required: false
          example: Bearer {{_OAUTH_TOKEN}}
          schema:
            type: string
            default: Bearer {{_OAUTH_TOKEN}}
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                prompt:
                  description: Image generation prompt.
                  example: Minimalistic cheesecake cartoon image
                  type: string
                model_type:
                  description: >-
                    Model type, one of: "small", "medium", "large". Larger
                    models have higher quality, longer generation time, and
                    higher cost.
                  example: small
                  type: string
                aspect_ratio:
                  description: >-
                    Image aspect ratio, one of: "1:1", "2:3", "3:2", "3:4",
                    "4:3", "4:5", "5:4", "16:9", "9:16".
                  example: '1:1'
                  type: string
                image_size:
                  description: >-
                    Image size, one of: "thumbnail" (256 px), "small" (512 px),
                    "medium" (1024 px), "large" (1440 px).
                  example: thumbnail
                  type: string
                creativity:
                  type: integer
                  description: >-
                    Variability and creativity of image generation. Only used in
                    "medium" and "large" models.
                  example: 2
                photorealistic:
                  type: boolean
                  description: >-
                    If true, generate photorealistic images. Only used in
                    "large" model.
                  example: 'false'
                random_seed:
                  type: integer
                  description: If set, it results in deterministic generation.
                  example: 1
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  image_generation_task:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Task ID
                    x-apidog-orders:
                      - id
                    required:
                      - id
                x-apidog-orders:
                  - image_generation_task
                required:
                  - image_generation_task
          headers: {}
          x-apidog-name: Success
      security: []
      x-apidog-folder: API Reference/ML API
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/346351/apis/api-3511410-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://api.mpc.dev.placewise.com
    description: Staging
security: []

```