# 图片生成

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1beta/models/{modeName}:generateContent:
    post:
      summary: 图片生成
      deprecated: false
      description: 官方文档：https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn
      tags:
        - 聊天(Chat)/谷歌Gemini 接口/原生格式
      parameters:
        - name: modeName
          in: path
          description: |-
            模型名称：
            gemini-2.5-flash-image
            gemini-2.5-flash-image-preview
            gemini-3-pro-image-preview
            gemini-3.1-flash-image-preview
          required: true
          example: gemini-2.5-flash-image-preview
          schema:
            type: string
        - name: key
          in: query
          description: ''
          required: true
          example: '{{YOUR_API_KEY}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                contents:
                  type: array
                  items:
                    type: object
                    properties:
                      parts:
                        type: array
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: 提示词
                            inline_data:
                              type: object
                              properties:
                                mime_type:
                                  type: string
                                  description: 图片MIME类型
                                data:
                                  type: string
                                  description: 图片 base64 追多支持传入 14 张图片
                              x-apifox-orders:
                                - mime_type
                                - data
                              description: 图片内嵌数据
                              required:
                                - mime_type
                                - data
                          x-apifox-orders:
                            - text
                            - inline_data
                          required:
                            - text
                    x-apifox-orders:
                      - parts
                    required:
                      - parts
                generationConfig:
                  type: object
                  properties:
                    responseModalities:
                      type: array
                      items:
                        type: string
                      description: |-
                        响应模式：
                        Text、Image
                        默认：["Text", "Image"]
                    imageConfig:
                      type: object
                      properties:
                        aspectRatio:
                          type: string
                          description: |-
                            宽高比：
                            1:1、2:3、3:2、3:4、4:3、4:5、5:4、9:16、16:9、21:9 支持所有模型
                            1:4、1:8、4:1、8:1  这几个仅支持Gemini 3.1模型
                        imageSize:
                          type: string
                          description: |-
                            分辨率：
                            0.5K、1K、2K、4K
                            默认值：1K
                            注意：Gemini 2.5只支持1K，0.5K仅支持Gemini 3.1模型，值须填“512”
                      x-apifox-orders:
                        - aspectRatio
                        - imageSize
                      description: 图片配置
                  x-apifox-orders:
                    - responseModalities
                    - imageConfig
                  description: 生成配置
              required:
                - contents
              x-apifox-orders:
                - contents
                - generationConfig
            examples:
              '1':
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Hi, can you create a 3d rendered image of a pig with
                            wings and a top hat flying over a happy futuristic
                            scifi city with lots of greenery?
                  generationConfig:
                    responseModalities:
                      - IMAGE
                summary: 默认
              '2':
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            HA [style] sticker of a [subject], featuring [key
                            characteristics] and a [color palette]. The design
                            should have [line style] and [shading style]. The
                            background must be transparent.
                  generationConfig:
                    responseModalities:
                      - IMAGE
                    imageConfig:
                      aspectRatio: '9:16'
                      imageSize: 1K
                summary: 文生图
              '3':
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Turn this rough [medium] sketch of a [subject] into
                            a [style description] photo. Keep the [specific
                            features] from the sketch but add [new
                            details/materials].
                        - inline_data:
                            mime_type: image/jpeg
                            data: image_base64
                  generationConfig:
                    responseModalities:
                      - IMAGE
                    imageConfig:
                      aspectRatio: '9:16'
                      imageSize: 1K
                summary: 图生图（图片编辑）
              '4':
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Using the provided images, place [element from image
                            2] onto [element from image 1]. Ensure that the
                            features of [element from image 1] remain completely
                            unchanged. The added element should [description of
                            how the element should integrate].
                        - inline_data:
                            mime_type: image/jpeg
                            data: image_base64_1
                        - inline_data:
                            mime_type: image/jpeg
                            data: image_base64_2
                  generationConfig:
                    responseModalities:
                      - IMAGE
                    imageConfig:
                      aspectRatio: '9:16'
                      imageSize: 1K
                summary: 多图生图
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-orders: []
          headers: {}
          x-apifox-name: 成功
      security:
        - bearer: []
      x-apifox-folder: 聊天(Chat)/谷歌Gemini 接口/原生格式
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/8227283/apis/api-453793858-run
components:
  schemas: {}
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
servers: []
security:
  - bearer: []

```
