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

# 即梦官方格式查询任务

> 使用 `POST /jm` 查询即梦官方格式任务状态与结果。

# 即梦官方格式查询任务

即梦官方格式的任务查询接口，用于查询图像生成任务的状态与结果。

* 路由入口是 `POST /jm`。
* 需要在 URL 中携带 `Action` 和 `Version` 查询参数。
* 通过 Body 中的 `task_id` 指定要查询的任务。
* 返回任务状态（`generating`、`success`、`failed`）及图像下载地址。

## 方法与路径

```http theme={null}
POST /jm?Action=CVSync2AsyncGetResult&Version=2022-08-31
```

## 请求示例

<CodeGroup>
  ```bash theme={null}
  curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncGetResult&Version=2022-08-31" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{
      "req_key": "jimeng_t2i_v40",
      "task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
      "req_json": "{\"return_url\": true}"
    }'
  ```

  ```python theme={null}
  import requests
  import json

  resp = requests.post(
      "https://octopusx.ai/jm",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
          "Accept": "application/json",
      },
      params={
          "Action": "CVSync2AsyncGetResult",
          "Version": "2022-08-31",
      },
      json={
          "req_key": "jimeng_t2i_v40",
          "task_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
          "req_json": json.dumps({"return_url": True}),
      },
      timeout=60,
  )
  print(resp.json())
  ```
</CodeGroup>

## 响应示例

### 生成中

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 10000,
    "data": {
      "binary_data_base64": [],
      "image_urls": null,
      "status": "generating"
    },
    "message": "Success",
    "request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
    "status": 10000,
    "time_elapsed": "35.381µs"
  }
  ```
</ResponseExample>

### 生成成功

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 10000,
    "data": {
      "binary_data_base64": [],
      "image_urls": [
        "https://example.com/generated-image-1.png",
        "https://example.com/generated-image-2.png"
      ],
      "status": "success"
    },
    "message": "Success",
    "request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
    "status": 10000,
    "time_elapsed": "2.5s"
  }
  ```
</ResponseExample>

### 生成失败

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 10001,
    "data": {
      "binary_data_base64": [],
      "image_urls": null,
      "status": "failed"
    },
    "message": "Task failed",
    "request_id": "67fb9e82-126e-4c71-bb16-a3bb3789e3b7",
    "status": 10001,
    "time_elapsed": "1.2s"
  }
  ```
</ResponseExample>

## 认证

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## 查询参数

<ParamField query="Action" type="string">
  操作类型。固定值：`CVSync2AsyncGetResult`（查询结果）。
</ParamField>

<ParamField query="Version" type="string">
  API 版本。固定值：`2022-08-31`。
</ParamField>

## Body

<ParamField body="req_key" type="string" required>
  服务标识。取固定值：`jimeng_t2i_v40`。
</ParamField>

<ParamField body="task_id" type="string" required>
  任务 ID。创建任务时返回的 `task_id`。
</ParamField>

<ParamField body="req_json" type="string" required>
  JSON 序列化后的字符串。目前支持水印配置和是否以图片链接形式返回，可在返回结果中添加。例如：`{"return_url": true}`。
</ParamField>

## Response

<ResponseField name="code" type="integer">
  状态码。`10000` 表示成功。
</ResponseField>

<ResponseField name="data" type="object">
  响应数据容器。
</ResponseField>

<ResponseField name="data.binary_data_base64" type="array">
  图片的 Base64 编码数组。
</ResponseField>

<ResponseField name="data.image_urls" type="array | null">
  图片 URL 数组。当 `req_json` 中设置 `return_url: true` 时返回。
</ResponseField>

<ResponseField name="data.status" type="string">
  任务状态。可选值：`generating`（生成中）、`success`（成功）、`failed`（失败）。
</ResponseField>

<ResponseField name="message" type="string">
  状态消息。
</ResponseField>

<ResponseField name="request_id" type="string">
  请求 ID。
</ResponseField>

<ResponseField name="status" type="integer">
  状态码。
</ResponseField>

<ResponseField name="time_elapsed" type="string">
  请求耗时。
</ResponseField>

## 相关接口

* [即梦图像概览](./overview)
* [图像生成](./generation)
* [图像编辑](./edit)
* [官方格式生图](./official-generation)
