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

# Jimeng Official Format Image Generation

> Generate images using the official Jimeng format interface via `POST /jm`.

# Jimeng Official Format Image Generation

An image generation API in Jimeng’s official format, submitted in JSON and requiring query parameters.

* The routing entry is `POST /jm`.
* The `Action` and `Version` query parameters must be included in the URL.
* Currently submitted using `application/json`.
* Supports text-to-image, image-to-image, and other scenarios.
* After successful submission, a task `task_id` is returned. Use [Query Task](./official-query) to fetch the result later.

## Supported Models

* `jimeng-4.0`: Jimeng 4.0 model

## Method and Path

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

## Request Example

<CodeGroup>
  ```bash theme={null}
  curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncSubmitTask&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",
      "model": "jimeng-4.0",
      "prompt": "The sunset glow illuminates the lake, with delicate oil painting texture",
      "force_single": true,
      "image_urls": [],
      "width": 1024,
      "height": 1024
    }'
  ```

  ```python theme={null}
  import requests

  resp = requests.post(
      "https://octopusx.ai/jm",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
          "Accept": "application/json",
      },
      params={
          "Action": "CVSync2AsyncSubmitTask",
          "Version": "2022-08-31",
      },
      json={
          "req_key": "jimeng_t2i_v40",
          "model": "jimeng-4.0",
          "prompt": "The sunset glow illuminates the lake, with delicate oil painting texture",
          "force_single": True,
          "image_urls": [],
          "width": 1024,
          "height": 1024,
      },
      timeout=60,
  )
  print(resp.json())
  ```
</CodeGroup>

### Example with Reference Images

<CodeGroup>
  ```bash theme={null}
  curl -X POST "https://octopusx.ai/jm?Action=CVSync2AsyncSubmitTask&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",
      "model": "jimeng-4.0",
      "prompt": "Generate an artistic style based on the reference images",
      "force_single": true,
      "image_urls": [
        "https://example.com/reference1.png",
        "https://example.com/reference2.png"
      ],
      "resolution": "2k"
    }'
  ```

  ```python theme={null}
  import requests

  resp = requests.post(
      "https://octopusx.ai/jm",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
          "Accept": "application/json",
      },
      params={
          "Action": "CVSync2AsyncSubmitTask",
          "Version": "2022-08-31",
      },
      json={
          "req_key": "jimeng_t2i_v40",
          "model": "jimeng-4.0",
          "prompt": "Generate an artistic style based on the reference images",
          "force_single": True,
          "image_urls": [
              "https://example.com/reference1.png",
              "https://example.com/reference2.png",
          ],
          "resolution": "2k",
      },
      timeout=60,
  )
  print(resp.json())
  ```
</CodeGroup>

## Response Example

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

## Authentication

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

## Query Parameters

<ParamField query="Action" type="string">
  Operation type. Fixed value: `CVSync2AsyncSubmitTask` (submit task).
</ParamField>

<ParamField query="Version" type="string">
  API version. Fixed value: `2022-08-31`.
</ParamField>

## Body

<ParamField body="req_key" type="string" required>
  Service identifier. Fixed value: `jimeng_t2i_v40`.
</ParamField>

<ParamField body="model" type="string" required>
  Model name. For example, `jimeng-4.0`.
</ParamField>

<ParamField body="prompt" type="string" required>
  The prompt used to generate the image. Both Chinese and English are supported. It is recommended to keep it within 800 characters at most; overly long prompts may cause generation anomalies or fail to take effect. You can directly specify the image generation ratio in the prompt.
</ParamField>

<ParamField body="resolution" type="string">
  Resolution. Optional values: `1k`, `2k`, `4k`.
</ParamField>

<ParamField body="size" type="integer">
  The image area to generate (deprecated). Default: 4194304, which is 2048*2048, generating a 2K resolution image. Range: \[1024*1024, 4096\*4096], capable of generating 1K to 4K resolution images.
</ParamField>

<ParamField body="force_single" type="boolean">
  Whether to force generation of a single image. Default: `false`.
</ParamField>

<ParamField body="image_urls" type="array">
  Image file URLs. Supports 0 to 10 images for image-to-image scenarios.
</ParamField>

<ParamField body="width" type="integer">
  Image width. Recommended values: 1024 (1K), 2048 (2K), 4096 (4K), etc.
</ParamField>

<ParamField body="height" type="integer">
  Image height. Recommended values: 1024 (1K), 2048 (2K), 4096 (4K), etc.
</ParamField>

## Response

<ResponseField name="code" type="integer">
  Status code. `10000` indicates success.
</ResponseField>

<ResponseField name="data" type="object">
  Response data container.
</ResponseField>

<ResponseField name="data.task_id" type="string">
  Task ID. Used to query task status and results later.
</ResponseField>

<ResponseField name="data.status" type="string">
  Task status.
</ResponseField>

<ResponseField name="message" type="string">
  Status message.
</ResponseField>

<ResponseField name="request_id" type="string">
  Request ID.
</ResponseField>

<ResponseField name="status" type="integer">
  Status code.
</ResponseField>

<ResponseField name="time_elapsed" type="string">
  Request duration.
</ResponseField>

## Recommended Sizes

### 1K Resolution

| Width x Height | Ratio |
| -------------- | ----- |
| 1024x1024      | 1:1   |

### 2K Resolution

| Width x Height | Ratio |
| -------------- | ----- |
| 2048x2048      | 1:1   |
| 2304x1728      | 4:3   |
| 2496x1664      | 3:2   |
| 2560x1440      | 16:9  |
| 3024x1296      | 21:9  |

### 4K Resolution

| Width x Height | Ratio |
| -------------- | ----- |
| 4096x4096      | 1:1   |
| 4694x3520      | 4:3   |
| 4992x3328      | 3:2   |
| 5404x3040      | 16:9  |
| 6198x2656      | 21:9  |

## Related APIs

* [Jimeng Image Overview](./overview)
* [Image Generation](./generation)
* [Image Editing](./edit)
* [Official Format Query](./official-query)
