> ## 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 Image Generation

> Use `POST /v1/images/generations` to call the Jimeng model for image generation.

# Jimeng Image Generation

An image generation API in OpenAI-compatible format, supporting the image generation capabilities of the Jimeng model.

* The route entry is `POST /v1/images/generations`.
* Currently submitted using `application/json`.
* Supports Jimeng models (`jimeng-4.0`, `jimeng-4.5`).
* Supports image-to-image generation by passing a reference image through the `image` field.

## Supported Models

* `jimeng-4.0`: Jimeng 4.0 model
* `jimeng-4.5`: Jimeng 4.5 model

## Method and Path

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

## Request Example

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

### Example with Reference Image

<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": "Generate a photorealistic image based on the reference image",
      "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": "Generate a photorealistic image based on the reference image",
          "n": 1,
          "image": ["https://example.com/reference.png"],
          "ratio": "16:9",
          "resolution": "2k",
      },
      timeout=60,
  )
  print(resp.json())
  ```
</CodeGroup>

## Response Example

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

## Authentication

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

## Body

<ParamField body="model" type="string" required>
  Model name. Supports `jimeng-4.0` and `jimeng-4.5`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Prompt. The text description for image generation, supporting both Chinese and English.
</ParamField>

<ParamField body="n" type="integer" required>
  Number of images. The number of images to generate.
</ParamField>

<ParamField body="size" type="string">
  Image size. Resolution settings, such as `1024*1024`.
</ParamField>

<ParamField body="image" type="array">
  Reference image. An array of reference image URLs, used for image-to-image scenarios.
</ParamField>

<ParamField body="ratio" type="string">
  Image ratio. For example, `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, and so on.
</ParamField>

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

## Response

<ResponseField name="created" type="integer">
  Generation timestamp (Unix timestamp).
</ResponseField>

<ResponseField name="data" type="array">
  Array of generation results.
</ResponseField>

<ResponseField name="data[].url" type="string">
  URL of the generated image.
</ResponseField>

<ResponseField name="data[].revised_prompt" type="string">
  Rewritten prompt (returned by some upstream services).
</ResponseField>

## Related APIs

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