> ## 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 /v1/images/generations` 调用即梦模型生成图像。

# 即梦图像生成

OpenAI 兼容格式的图像生成接口，支持即梦模型的图像生成能力。

* 路由入口是 `POST /v1/images/generations`。
* 当前使用 `application/json` 提交。
* 支持即梦模型（`jimeng-4.0`、`jimeng-4.5`）。
* 支持通过 `image` 字段传入参考图进行图生图。

## 支持模型

* `jimeng-4.0`：即梦 4.0 模型
* `jimeng-4.5`：即梦 4.5 模型

## 方法与路径

```http theme={null}
POST /v1/images/generations
```

## 请求示例

<CodeGroup>
  ```bash theme={null}
  curl -X POST https://octopusx.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{
      "model": "jimeng-4.0",
      "prompt": "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
      "n": 1,
      "size": "1024*1024"
    }'
  ```

  ```python theme={null}
  import requests

  resp = requests.post(
      "https://octopusx.ai/v1/images/generations",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
          "Accept": "application/json",
      },
      json={
          "model": "jimeng-4.0",
          "prompt": "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
          "n": 1,
          "size": "1024*1024",
      },
      timeout=60,
  )
  print(resp.json())
  ```

  ```javascript theme={null}
  const response = await fetch("https://octopusx.ai/v1/images/generations", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
      Accept: "application/json",
    },
    body: JSON.stringify({
      model: "jimeng-4.0",
      prompt: "A close-up depiction of a domestic cat in a relaxed state. The cat features vibrant orange fur, with striking white markings around its eyes that extend down to its soft, pink nose.",
      n: 1,
      size: "1024*1024",
    }),
  });

  console.log(await response.json());
  ```
</CodeGroup>

### 带参考图示例

<CodeGroup>
  ```bash theme={null}
  curl -X POST https://octopusx.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{
      "model": "jimeng-4.0",
      "prompt": "参考图片生成写实类型的图像",
      "n": 1,
      "image": ["https://example.com/reference.png"],
      "ratio": "16:9",
      "resolution": "2k"
    }'
  ```

  ```python theme={null}
  import requests

  resp = requests.post(
      "https://octopusx.ai/v1/images/generations",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
          "Accept": "application/json",
      },
      json={
          "model": "jimeng-4.0",
          "prompt": "参考图片生成写实类型的图像",
          "n": 1,
          "image": ["https://example.com/reference.png"],
          "ratio": "16:9",
          "resolution": "2k",
      },
      timeout=60,
  )
  print(resp.json())
  ```
</CodeGroup>

## 响应示例

<ResponseExample>
  ```json 200 theme={null}
  {
    "created": 1735689600,
    "data": [
      {
        "url": "https://example.com/generated-image.png",
        "revised_prompt": "A close-up depiction of a domestic cat in a relaxed state..."
      }
    ]
  }
  ```
</ResponseExample>

## 认证

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

## Body

<ParamField body="model" type="string" required>
  模型名称。支持 `jimeng-4.0`、`jimeng-4.5`。
</ParamField>

<ParamField body="prompt" type="string" required>
  提示词。生成图像的文本描述，支持中文和英文。
</ParamField>

<ParamField body="n" type="integer" required>
  图像数量。生成图片的数量。
</ParamField>

<ParamField body="size" type="string">
  图像大小。分辨率设置，例如 `1024*1024`。
</ParamField>

<ParamField body="image" type="array">
  垫图。参考图片 URL 数组，用于图生图场景。
</ParamField>

<ParamField body="ratio" type="string">
  图片比例。例如 `1:1`、`16:9`、`9:16`、`4:3`、`3:4` 等。
</ParamField>

<ParamField body="resolution" type="string">
  分辨率。可选值：`1k`、`2k`、`4k`。
</ParamField>

## Response

<ResponseField name="created" type="integer">
  生成时间戳（Unix 时间戳）。
</ResponseField>

<ResponseField name="data" type="array">
  生成结果数组。
</ResponseField>

<ResponseField name="data[].url" type="string">
  生成图片的 URL 地址。
</ResponseField>

<ResponseField name="data[].revised_prompt" type="string">
  改写后的提示词（部分上游会返回）。
</ResponseField>

## 相关接口

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