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

# 图片编辑

<Note>
  注意：目前仅 `gpt-image-1` 和 `nano-banana` 模型支持图片编辑，其他模型不支持。你可以在模型广场筛选查看[系统支持的所有画图模型列表](https://geekai.co/models)，画图模型请求/响应参数结构兼容 [OpenAI](https://platform.openai.com/docs/api-reference/images/generate-image)，切换模型时只需修改对应的模型名称即可，若模型请求/响应参数和 OpenAI 不一致，极客智坊底层会自动转换对齐。
</Note>

图片编辑 API 调用示例可以参考这里：[图片编辑](https://docs.geekai.co/cn/docs/image/edit)。

### 请求/响应参数明细


## OpenAPI

````yaml openapi.yaml POST /images/edits
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /images/edits:
    post:
      tags:
        - ImageEdit
      summary: 图片编辑接口
      description: >-
        基于文本提示对图片进行编辑，支持多种图片生成模型和参数配置，目前仅 `gpt-image-1` 和 `gemini-nano-banana`
        模型支持该接口
      operationId: editImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
                - image
              properties:
                model:
                  type: string
                  description: 画图模型
                  example: gpt-image-1
                prompt:
                  type: string
                  description: 文本提示
                  example: 在小猫的脚下画一只老鼠
                image:
                  oneOf:
                    - type: string
                      description: 单张图片URL/Base64编码数据
                    - type: array
                      description: 多张图片URL/Base64编码数组列表
                      items:
                        type: string
                background:
                  type: string
                  description: 背景透明度，目前仅 gpt-image-1 支持该配置
                  enum:
                    - transparent
                    - opaque
                    - auto
                  default: auto
                mask:
                  type: string
                  description: 用于遮罩的图片URL/Base64编码数据
                size:
                  type: string
                  description: 图片尺寸，不同模型设置不同，详见模型尺寸表
                  example: 1024x1024
                'n':
                  type: integer
                  description: 图片数量，默认为1
                  example: 1
                quality:
                  type: string
                  description: 图片质量，支持 auto/low/medium/high 四个配置项，默认为auto
                  enum:
                    - auto
                    - low
                    - medium
                    - high
                  default: auto
                response_format:
                  type: string
                  description: 图片响应格式，支持 url/b64_json 两种格式，默认为url
                  enum:
                    - url
                    - b64_json
                  default: url
                output_format:
                  type: string
                  description: 图片输出格式，支持 png/jpg/webp 三种格式，默认为png
                  enum:
                    - png
                    - jpg
                    - webp
                  default: png
                retries:
                  type: integer
                  description: 自动重试次数，默认0，表示失败不重试
                  default: 0
                  example: 0
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                required:
                  - created
                  - data
                properties:
                  created:
                    type: integer
                    description: 创建时间戳
                    format: unix-timestamp
                  task_id:
                    type: string
                    description: 任务ID
                  task_status:
                    type: string
                    description: 任务状态
                    enum:
                      - pending
                      - running
                      - succeed
                      - failed
                    example: succeed
                  data:
                    type: array
                    description: 生成的图片列表
                    items:
                      type: object
                      required:
                        - url
                      properties:
                        url:
                          type: string
                          description: 图片URL
                          format: uri
                        b64_json:
                          type: string
                          description: 图片Base64编码数据
                          format: base64
                        revised_prompt:
                          type: string
                          description: 优化后的提示文本
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '413':
          description: 提示文本过长
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    ValidationError:
      description: 参数验证错误
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: 参数验证失败
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: 错误描述
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````