> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siliconflow.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建图片生成请求

> Creates an image response for the given prompt. The URL for the generated image is valid for one hour. Please make sure to download and store it promptly to avoid any issues due to URL expiration.



## OpenAPI

````yaml post /images/generations
openapi: 3.0.0
info:
  title: SiliconFlow API
  description: The SiliconFlow REST API
  version: 1.0.0
  contact:
    name: SiliconFlow Support
    url: https://www.siliconflow.cn/
  license:
    name: MIT
    url: https://github.com/siliconflow/siliconcloud/blob/main/LICENSE
servers:
  - url: https://api.siliconflow.cn/v1
security:
  - bearerAuth: []
paths:
  /images/generations:
    post:
      tags:
        - Image
      summary: Image Generation
      description: >-
        Creates an image response for the given prompt. The URL for the
        generated image is valid for one hour. Please make sure to download and
        store it promptly to avoid any issues due to URL expiration.
      operationId: ImageGeneration
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Kolors'
      responses:
        '200':
          description: >-
            The response from the model. The response header contains the
            x-siliconcloud-trace-id field, which serves as a unique identifier
            for tracing requests, facilitating log queries and issue
            troubleshooting.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesGenerationResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimit'
        '503':
          $ref: '#/components/responses/Overloaded'
        '504':
          $ref: '#/components/responses/Timeout'
      deprecated: false
      x-codeSamples:
        - lang: python
          label: T2Image
          source: >
            import requests

            url = "https://api.siliconflow.cn/v1/images/generations"

            payload = {
                "model": "Kwai-Kolors/Kolors",
                "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
                "image_size": "1024x1024",
                "batch_size": 1,
                "num_inference_steps": 20,
                "guidance_scale": 7.5
            }

            headers = {
                "Authorization": "Bearer YOUR-API-KEY",
                "Content-Type": "application/json"
            }

            response = requests.request("POST", url, json=payload,
            headers=headers)

            print(response.text)
        - lang: curl
          label: T2Image
          source: |
            curl --request POST \
              --url https://api.siliconflow.cn/v1/images/generations \
              --header 'Authorization: Bearer YOUR-API-KEY' \
              --header 'Content-Type: application/json' \
              --data '{
              "model": "Kwai-Kolors/Kolors",
              "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "image_size": "1024x1024",
              "batch_size": 1,
              "num_inference_steps": 20,
              "guidance_scale": 7.5
            }'
        - lang: javaScript
          label: T2Image
          source: |
            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer YOUR-API-KEY',
                'Content-Type': 'application/json'
              },
              body: '{"model":"Kwai-Kolors/Kolors",
              "prompt":"an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "image_size":"1024x1024",
              "batch_size":1,
              "num_inference_steps":20,
              "guidance_scale":7.5
            };

            fetch('https://api.siliconflow.cn/v1/images/generations', options)
              .then(response => response.json())
              .then(response => console.log(response))
              .catch(err => console.error(err));
        - lang: python
          label: I2Image
          source: >
            import requests

            url = "https://api.siliconflow.cn/v1/images/generations"

            payload = {
                "model": "Kwai-Kolors/Kolors",
                "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
                "image_size": "1024x1024",
                "batch_size": 1,
                "num_inference_steps": 20,
                "guidance_scale": 7.5,
                "image": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"
            }

            headers = {
                "Authorization": "Bearer YOUR-API-KEY",
                "Content-Type": "application/json"
            }

            response = requests.request("POST", url, json=payload,
            headers=headers)

            print(response.text)
        - lang: curl
          label: I2Image
          source: |
            curl --request POST \
              --url https://api.siliconflow.cn/v1/images/generations \
              --header 'Authorization: Bearer YOUR-API-KEY' \
              --header 'Content-Type: application/json' \
              --data '{
              "model": "Kwai-Kolors/Kolors",
              "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "image_size": "1024x1024",
              "batch_size": 1,
              "num_inference_steps": 20,
              "guidance_scale": 7.5,
              "image": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"
            }'
        - lang: javaScript
          label: I2Image
          source: |
            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer YOUR-API-KEY',
                'Content-Type': 'application/json'
              },
              body: '{"model":"Kwai-Kolors/Kolors",
              "prompt":"an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "image_size":"1024x1024",
              "batch_size":1,
              "num_inference_steps":20,
              "guidance_scale":7.5
              "image":"https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"}'
            };

            fetch('https://api.siliconflow.cn/v1/images/generations', options)
              .then(response => response.json())
              .then(response => console.log(response))
              .catch(err => console.error(err));
        - lang: python
          label: Qwen/Qwen-Image-Edit-2509
          source: >
            import requests


            url = "https://api.siliconflow.cn/v1/images/generations"


            payload = {
                "model": "Qwen/Qwen-Image-Edit-2509",
                "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
                "num_inference_steps": 20,
                "guidance_scale": 4,
                "image": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
                "image2": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
                "image3": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"
            }

            headers = {
                "Authorization": "Bearer YOUR-API-KEY",
                "Content-Type": "application/json"
            }


            response = requests.request("POST", url, json=payload,
            headers=headers)

            print(response.text)
        - lang: curl
          label: Qwen/Qwen-Image-Edit-2509
          source: |
            curl --request POST \
              --url https://api.siliconflow.cn/v1/images/generations \
              --header 'Authorization: Bearer YOUR-API-KEY' \
              --header 'Content-Type: application/json' \
              --data '{
              "model": "Qwen/Qwen-Image-Edit-2509",
              "prompt": "an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "num_inference_steps": 20,
              "guidance_scale": 4,
              "image": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
              "image2": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
              "image3": "https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"
            }'
        - lang: javaScript
          label: Qwen/Qwen-Image-Edit-2509
          source: |
            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer YOUR-API-KEY',
                'Content-Type': 'application/json'
              },
              body: '{"model":"Qwen/Qwen-Image-Edit-2509",
              "prompt":"an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea",
              "num_inference_steps":20,
              "guidance_scale":4,
              "image":"https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
              "image2":"https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641",
              "image3":"https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641"}'
            };

            fetch('https://api.siliconflow.cn/v1/images/generations', options)
              .then(response => response.json())
              .then(response => console.log(response))
              .catch(err => console.error(err));
components:
  schemas:
    Kolors:
      title: Kolors
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          example: Qwen/Qwen-Image-Edit-2509
          description: >-
            Corresponding Model Name. To better enhance service quality, we will
            make periodic changes to the models provided by this service,
            including but not limited to model on/offlining and adjustments to
            model service capabilities. We will notify you of such changes
            through appropriate means such as announcements or message pushes
            where feasible. **For a complete list of available models, please
            check the
            [Models](https://cloud.siliconflow.cn/sft-d29cs9gh3vvc73c59kb0/models?types=to-image)**.
        prompt:
          type: string
          example: >-
            an island near sea, with seagulls, moon shining over the sea, light
            house, boats int he background, fish flying over the sea
        negative_prompt:
          title: Negative Prompt
          type: string
          description: negative prompt
        image_size:
          type: string
          title: Image size, format is  [width]x[height].
          description: >
            Image resolution in "widthxheight" format (Required). To ensure
            optimal quality, using the recommended values for your model is
            strongly advised. **Qwen/Qwen-Image-Edit-2509 and
            Qwen/Qwen-Image-Edit not support this field.**
              Recommended Values:  
              - For Kolor model:  
                - "1024x1024" (1:1)
                - "960x1280" (3:4)
                - "768x1024" (3:4)
                - "720x1440" (1:2)
                - "720x1280" (9:16)
              - For Qwen-Image model:  
                - "1328x1328" (1:1)
                - "1664x928" (16:9)
                - "928x1664" (9:16)
                - "1472x1140" (4:3)
                - "1140x1472" (3:4)
                - "1584x1056" (3:2)
                - "1056x1584" (2:3)
        batch_size:
          title: Number Images
          description: number of output images. Only applicable to Kwai-Kolors/Kolors.
          type: integer
          minimum: 1
          maximum: 4
          default: 1
        seed:
          title: Seed
          type: integer
          minimum: 0
          maximum: 9999999999
        num_inference_steps:
          title: Number Inference Steps
          description: number of inference steps
          type: integer
          minimum: 1
          maximum: 100
          default: 20
        guidance_scale:
          title: Guidance Scale
          description: >-
            This value is used to control the degree of match between the
            generated image and the given prompt. The higher the value, the more
            the generated image will tend to strictly match the text prompt. The
            lower the value, the more creative and diverse the generated image
            will be, potentially containing more unexpected elements. Only
            applicable to Kwai-Kolors/Kolors.
          type: number
          minimum: 0
          maximum: 20
          default: 7.5
        image:
          $ref: '#/components/schemas/upload_image_url'
        image2:
          $ref: '#/components/schemas/upload_image_url_array'
        image3:
          $ref: '#/components/schemas/upload_image_url_array'
    ImagesGenerationResponse:
      type: object
      properties:
        images:
          type: array
          items:
            type: object
            properties:
              url:
                description: >-
                  The URL for the generated image is valid for one hour. Please
                  make sure to download and store it promptly to avoid any
                  issues due to URL expiration.
                type: string
        timings:
          type: object
          properties:
            inference:
              type: number
              format: float
        seed:
          type: integer
    upload_image_url:
      title: Upload Image
      description: The image used for uploading an image can be in base64 format or a URL.
      type: string
      enum:
        - data:image/png;base64, XXX
        - img_url
      example: >-
        https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641
    upload_image_url_array:
      title: Upload Image
      description: >-
        The image used for uploading an image can be in base64 format or a URL.
        This field is only applicable to Qwen/Qwen-Image-Edit-2509.
      type: string
      enum:
        - data:image/png;base64, XXX
        - img_url
      example: >-
        https://inews.gtimg.com/om_bt/Os3eJ8u3SgB3Kd-zrRRhgfR5hUvdwcVPKUTNO6O7sZfUwAA/641
    BadRquestData:
      type: object
      required:
        - message
        - data
        - code
      properties:
        code:
          type: integer
          nullable: true
          default: false
          example: 20012
        message:
          type: string
          nullable: false
        data:
          type: string
          nullable: false
    UnauthorizedData:
      type: string
      default: false
      example: Invalid token
    ForbiddenData:
      type: string
      default: false
      example: Forbidden
    NotFoundData:
      type: string
      default: false
      example: 404 page not found
    RateLimitData:
      type: object
      required:
        - message
        - data
      properties:
        message:
          type: string
          example: >-
            Request was rejected due to rate limiting. If you want more, please
            contact contact@siliconflow.cn. Details:TPM limit reached.
        data:
          type: string
    OverloadedtData:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          type: integer
          example: 50505
        message:
          type: string
          example: Model service overloaded. Please try again later.
        data:
          type: string
          nullable: false
    TimeoutData:
      type: string
  responses:
    BadRequest:
      description: BadRequest
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BadRquestData'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedData'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ForbiddenData'
    NotFound:
      description: NotFound
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFoundData'
    RateLimit:
      description: RateLimit
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitData'
    Overloaded:
      description: Overloaded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OverloadedtData'
    Timeout:
      description: Timeout
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TimeoutData'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: your api key
      description: >-
        Use the following format for authentication: Bearer [<your api
        key>](https://cloud.siliconflow.cn/account/ak)

````