> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Kling Image O1 with Comfy Router

> Call kling/kling-image-o1 through Comfy Router: endpoint, request shape and the response Router returns.

API Reference for `kling/kling-image-o1`, served by Comfy Router from Kling.

## Quick start

Create a key at [platform.comfy.org/profile/api-keys](https://platform.comfy.org/profile/api-keys) and export it as `COMFY_API_KEY`. The Python and TypeScript snippets use the Comfy SDKs (`pip install comfy-sdk`, `npm install @comfyorg/sdk`); the cURL snippet is the same call over raw HTTP.

**Model ID:** `kling/kling-image-o1`

**Endpoint:** `POST https://api.comfy.org/v2/models/kling/kling-image-o1`

<CodeGroup>
  ```python Python theme={null}
  from comfy_sdk import Comfy

  # Reads COMFY_API_KEY from the environment. Each call sends a fresh
  # Idempotency-Key and waits up to 10 minutes for the finished result.
  with Comfy() as client:
      result = client.models.run(
          "kling/kling-image-o1",
          {
              "aspect_ratio": "1:1",
              "n": 1,
              "prompt": "A watercolour koi pond at dawn, soft light.",
              "resolution": "1k",
          },
      )

  print(result)
  ```

  ```typescript TypeScript theme={null}
  import { comfy } from "@comfyorg/sdk";

  // Reads COMFY_API_KEY from the environment. Each call sends a fresh
  // Idempotency-Key and waits up to 10 minutes for the finished result.
  const { data } = await comfy.models.run("kling/kling-image-o1", {
    aspect_ratio: "1:1",
    n: 1,
    prompt: "A watercolour koi pond at dawn, soft light.",
    resolution: "1k",
  });

  console.log(data);
  ```

  ```bash cURL theme={null}
  curl https://api.comfy.org/v2/models/kling/kling-image-o1 \
    -H "X-API-Key: $COMFY_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d "{\"aspect_ratio\": \"1:1\", \"n\": 1, \"prompt\": \"A watercolour koi pond at dawn, soft light.\", \"resolution\": \"1k\"}"
  ```
</CodeGroup>

## Schema

### Input

<ParamField body="aspect_ratio" type="string" default="&#x22;auto&#x22;">
  Aspect ratio of the generated images (width:height). auto is to intelligently generate images based on incoming content.

  Possible values: `16:9`, `9:16`, `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9`, `auto`
</ParamField>

<ParamField body="callback_url" type="string (uri)">
  The callback notification address for the result of this task. If configured, the server will actively notify when the task status changes.

  Format: `uri`
</ParamField>

<ParamField body="element_list" type="object[]">
  Reference Element List based on element ID configuration. The sum of reference elements and reference images shall not exceed 10.
</ParamField>

<ParamField body="element_list[].element_id" type="integer" required>
  Element ID

  Format: `int64`
</ParamField>

<ParamField body="external_task_id" type="string">
  Customized Task ID. Must be unique within a single user account.
</ParamField>

<ParamField body="image_list" type="object[]">
  Reference Image List. Supports inputting image Base64 encoding or image URL (ensure accessibility). Supported formats include .jpg/.jpeg/.png. File size cannot exceed 10MB. Width and height dimensions shall not be less than 300px, aspect ratio between 1:2.5 \~ 2.5:1. The sum of reference elements and reference images shall not exceed 10.
</ParamField>

<ParamField body="image_list[].image" type="string" required>
  Image Base64 encoding or image URL (ensure accessibility)
</ParamField>

<ParamField body="model_name" type="string">
  Model name. Omit it or send null when using Comfy Router; the model is selected by the request path. A supplied name must match that path.
</ParamField>

<ParamField body="n" type="integer" default="1">
  Number of generated images. Value range \[1,9].

  Range: `1` to `9`
</ParamField>

<ParamField body="prompt" type="string" required>
  Text prompt words, which can include positive and negative descriptions. Must not exceed 2,500 characters. The Omni model can achieve various capabilities through Prompt with elements and images. Specify an image in the format of \<\<\<>>>, such as \<\<\<image\_1>>>.
</ParamField>

<ParamField body="resolution" type="string" default="&#x22;1k&#x22;">
  Image generation resolution. 1k is 1K standard, 2k is 2K high-res, 4k is 4K high-res.

  Possible values: `1k`, `2k`, `4k`
</ParamField>

<ParamField body="result_type" type="string" default="&#x22;single&#x22;">
  Control whether to generate a single image or a series of images.

  Possible values: `single`, `series`
</ParamField>

<ParamField body="series_amount" type="integer" default="4">
  Number of images in a series. Value range \[2,9].

  Range: `2` to `9`
</ParamField>

Generated from the schema Router serves at `GET /v2/models/kling/kling-image-o1/openapi.json`, the same document it validates a call against before the request reaches the provider.

### Output

<ResponseField name="code" type="integer">
  Error code
</ResponseField>

<ResponseField name="data" type="object" />

<ResponseField name="data.created_at" type="integer">
  Task creation time, Unix timestamp in milliseconds
</ResponseField>

<ResponseField name="data.final_unit_deduction" type="string">
  The deduction units of task
</ResponseField>

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

<ResponseField name="data.task_info" type="object" />

<ResponseField name="data.task_info.external_task_id" type="string">
  Customer-defined task ID
</ResponseField>

<ResponseField name="data.task_result" type="object" />

<ResponseField name="data.task_result.images" type="object[]" />

<ResponseField name="data.task_result.images[].index" type="integer">
  Image Number (0-9)
</ResponseField>

<ResponseField name="data.task_result.images[].url" type="string (uri)">
  URL for generated image

  Format: `uri`
</ResponseField>

<ResponseField name="data.task_result.result_type" type="string">
  Whether the result is a single image or a series of images

  Possible values: `single`, `series`
</ResponseField>

<ResponseField name="data.task_result.series_images" type="object[]">
  Series images result list
</ResponseField>

<ResponseField name="data.task_result.series_images[].index" type="integer">
  Series-image sequence number
</ResponseField>

<ResponseField name="data.task_result.series_images[].url" type="string (uri)">
  URL for generated image

  Format: `uri`
</ResponseField>

<ResponseField name="data.task_status" type="string">
  Task Status

  Possible values: `submitted`, `processing`, `succeed`, `failed`
</ResponseField>

<ResponseField name="data.task_status_msg" type="string">
  Task status information, displaying the failure reason when the task fails (such as triggering the content risk control of the platform, etc.)
</ResponseField>

<ResponseField name="data.updated_at" type="integer">
  Task update time, Unix timestamp in milliseconds
</ResponseField>

<ResponseField name="message" type="string">
  Error message
</ResponseField>

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

## Examples

### Input

```json theme={null}
{
  "aspect_ratio": "1:1",
  "n": 1,
  "prompt": "A watercolour koi pond at dawn, soft light.",
  "resolution": "1k"
}
```

### Output

```json theme={null}
{
  "code": 0,
  "data": {
    "created_at": 1798761600000,
    "task_id": "kling-image-task-3c4d5e6f7a8b",
    "task_result": {
      "images": [
        {
          "index": 0,
          "url": "https://example.invalid/kling/kling-image-o1/generated.png"
        }
      ],
      "result_type": "single"
    },
    "task_status": "succeed",
    "task_status_msg": "",
    "updated_at": 1798761660000
  },
  "message": "SUCCEED",
  "request_id": "6a4b2c80-1e93-4d57-b8f2-05c7e9a3d146"
}
```

## Before you ship

The snippets above are the shortest working call. Three things are the same for every model and are documented once on the [Comfy Router headers](/development/comfy-router/headers) page: send an `Idempotency-Key` on every paid call and reuse it when you retry, expect the connection to be held up to Router's 10 minute deadline, and keep `X-Comfy-Request-Id` from every response. The SDKs do all three for you; the cURL tab does none of them. On failure, `X-Comfy-Error-Type` names the bucket, and a `422` means the body failed the model's schema and was never billed.

<CardGroup cols={3}>
  <Card title="Headers" icon="list" href="/development/comfy-router/headers">
    Authentication, idempotency, request IDs, error buckets, retry pacing, spend limits.
  </Card>

  <Card title="Quick Start" icon="rocket" href="/development/comfy-router/quickstart">
    Typed error handling in Python and TypeScript, reading the 422, walking the catalog.
  </Card>

  <Card title="Limitations" icon="triangle-exclamation" href="/development/comfy-router/limitations">
    What Router does not do today, and what to use instead.
  </Card>
</CardGroup>
