> ## 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.

# 查询结果

> 用提交时返回的 `task_id` 查询任务状态与结果。

| status | 含义 |
| - | - |
| `submitted` | 已提交，排队中 |
| `in_progress` | 生成中 |
| `success` | 完成，产物在 `images` / `videos` / `descriptions`，`usage.multiplier` 是这次的规格倍率；查询时带 `X-Billing-Detail: true`，响应头 `X-Billing-Amount` 是这次实际扣了多少钱 |
| `failure` | 失败，原因见 `fail_reason`，费用已退回 |

提交时带了 `notify_hook` 的话，任务结束后我们会把和查询结果相同的内容 POST 到那个地址。推送可能因为网络原因没有送达，长时间没收到时主动查询一次。


## OpenAPI

````yaml cn/openapi/midjourney.json GET /midjourney/task/{task_id}
openapi: 3.1.0
info:
  title: Midjourney API
  version: 1.0.0
  description: Midjourney 接口
servers:
  - url: https://api.ephone.ai
security:
  - bearerAuth: []
paths:
  /midjourney/task/{task_id}:
    get:
      summary: 查询结果
      description: >-
        用提交时返回的 `task_id` 查询任务状态与结果。建议每 3 到 5 秒查一次，`status` 变成 `success` 或
        `failure` 后停止。
      operationId: midjourney_get_task
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
          description: 提交任务时返回的任务 ID。
          example: mj-6f1c2b0e9a7d4e2fb1c3d5e7f9a1b2c3
        - name: X-Billing-Detail
          in: header
          required: false
          schema:
            type: boolean
          description: >-
            传 `true` 时，任务结束后响应头里带上 `X-Billing-Currency` 与
            `X-Billing-Amount`（这个任务实际扣了多少钱），响应内容不变。提交任务时也带上的话，之后查询不带也会返回，任务结束时的回调请求也会带上这两个请求头。
      responses:
        '200':
          description: OK
          headers:
            X-Billing-Currency:
              description: >-
                模型定价的币种：`CNY` 或 `USD`。请求带 `X-Billing-Detail:
                true`（或提交时带过）且任务已结束时才有。
              schema:
                type: string
                enum:
                  - CNY
                  - USD
            X-Billing-Amount:
              description: >-
                实际扣费金额，单位是 `X-Billing-Currency` 给出的币种，例如
                `0.24`。已含折扣与失败退款，请直接使用，不要自己按汇率换算。
              schema:
                type: string
                example: '0.24'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
              example:
                task_id: mj-6f1c2b0e9a7d4e2fb1c3d5e7f9a1b2c3
                action: imagine
                status: success
                speed: fast
                prompt: >-
                  a red bicycle leaning on a brick wall, morning light --ar 3:2
                  --v 8.2
                images:
                  - https://.../1.png
                  - https://.../2.png
                  - https://.../3.png
                  - https://.../4.png
                seed: 3277589003
                actions:
                  - upscale
                  - variation
                  - remix
                  - zoom
                  - pan
                  - inpaint
                  - video
                  - reroll
                created_at: 1792154579
                finished_at: 1792154629
                usage:
                  type: call
                  multiplier: 1
        '401':
          description: unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unauthorized
                  message: Invalid API key
        '404':
          description: task_not_found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: task_not_found
                  message: Task not found
components:
  schemas:
    Task:
      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
        speed:
          type: string
          description: 提交时选的速度档：`relax`、`fast` 或 `turbo`，也是计费的那一档。识图不分速度，没有这一项。
        prompt:
          type: string
          description: 实际提交的提示词。
        images:
          type: array
          items:
            type: string
          description: '图片地址，顺序就是图片序号（第 1 张对应 `index: 1`）。未通过内容审核的位置是空字符串。'
        videos:
          type: array
          items:
            type: string
          description: 视频地址（视频接口），顺序就是视频序号。
        descriptions:
          type: array
          items:
            type: string
          description: 识图结果（describe 接口）。
        seed:
          type: integer
          description: 种子值。
        actions:
          type: array
          items:
            type: string
          description: >-
            这个任务还能接着做的加工，例如 `["upscale", "variation", "reroll"]`。调 `POST
            /midjourney/action` 时填进 `action`，再传 `task_id`；按图操作的还要传
            `index`，`reroll` 不用。
        fail_reason:
          type: string
          description: 失败原因。
        created_at:
          type: integer
          description: 创建时间（Unix 秒）。
        finished_at:
          type: integer
          description: 结束时间（Unix 秒）。
        usage:
          type: object
          description: >-
            用量，只在 `success` 时返回，例如 `{"type": "call", "multiplier":
            2}`。`multiplier` 是规格倍率，相对于价格表里所选速度档的单价：高清为 2，V7 草图为
            0.5，视频按分辨率和数量计；不含账户折扣。实际扣了多少钱看响应头 `X-Billing-Amount`（查询时带
            `X-Billing-Detail: true`）。
      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.