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

# 图像生成

> Midjourney 文生图，一次四张。默认 V8.2，也支持 V8.1、V8、V7 与 Niji 7 / 6，在提示词末尾写 `--v 7` 这样的参数选版本；可以垫图，Midjourney 参数照常写。

> [!TIP]
>
> 也可以用统一任务接口 `POST /v1/task/submit` 提交：`model` 填 `midjourney-imagine`，参数放进 `input`。两种写法效果与计费完全一样。

提交后返回任务 ID，用 [查询结果](https://docs.rixapi.com/docs/cn/api-reference/midjourney/task.md) 取图，或者提交时带上 `notify_hook` 等推送。完成后结果里的 `actions` 列出还能接着做的加工，调 [图像操作](https://docs.rixapi.com/docs/cn/api-reference/midjourney/action.md) 继续。


## OpenAPI

````yaml cn/openapi/midjourney.json POST /midjourney/imagine
openapi: 3.1.0
info:
  title: Midjourney API
  version: 1.0.0
  description: Midjourney 接口
servers:
  - url: https://api.ephone.ai
security:
  - bearerAuth: []
paths:
  /midjourney/imagine:
    post:
      summary: 图像生成
      description: >-
        Midjourney 文生图，一次四张。默认 V8.2，也支持 V8.1、V8、V7 与 Niji 7 / 6，在提示词末尾写 `--v 7`
        这样的参数选版本；可以垫图，Midjourney 参数照常写。
      operationId: midjourney_imagine
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                prompt:
                  type: string
                  maxLength: 6000
                  description: >-
                    **提示词**：描述画面，可以带 Midjourney 参数，如 `a cat in the rain --ar
                    16:9 --v 7`。只传 images 时可以不写。
                images:
                  type: array
                  maxItems: 5
                  description: >-
                    **垫图**：最多 5 张，作为画面参考放在提示词前面。图片 URL（公网可访问）或 base64 data
                    URI，单张不超过 20 MB。
                  items:
                    type: string
                speed:
                  type: string
                  enum:
                    - relax
                    - fast
                    - turbo
                  default: fast
                  description: >-
                    **速度**：慢速（relax）价格最低、排队较久；极速（turbo）最快、2 倍价格。也可以在提示词里写
                    --relax / --fast / --turbo，请求参数优先；都不写为快速。
                notify_hook:
                  type: string
                  format: uri
                  description: >-
                    **推送地址**：任务结束后，把和查询结果相同的内容 POST 到这个地址（公网可以访问的 http / https
                    地址）。不传就自己查询。
              required:
                - prompt
            example:
              prompt: a lighthouse on a rocky coast at dawn --ar 16:9 --v 7
              speed: fast
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
              example:
                task_id: mj-6f1c2b0e9a7d4e2fb1c3d5e7f9a1b2c3
                action: imagine
                status: submitted
                created_at: 1792000000
        '400':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_request
                  message: index must be between 1 and 4
        '401':
          description: unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unauthorized
                  message: Invalid API key
        '402':
          description: insufficient_quota
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: insufficient_quota
                  message: Insufficient balance
        '429':
          description: queue_full
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: queue_full
                  message: Queue is full, please try again later
        '500':
          description: upstream_error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: upstream_error
                  message: The service is temporarily unavailable, please retry
components:
  schemas:
    SubmitResponse:
      type: object
      properties:
        task_id:
          type: string
          description: 任务 ID。
        action:
          type: string
          description: 动作名，例如 `imagine`、`upscale`。
        status:
          type: string
          description: 任务状态，取值见上表。
          enum:
            - submitted
            - in_progress
            - success
            - failure
        created_at:
          type: integer
          description: 创建时间（Unix 秒）。
      required:
        - task_id
        - action
        - status
        - created_at
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: '在请求头 `Authorization: Bearer YOUR_API_KEY` 里带上 API Key。'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.