> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiid.edu.kg/llms.txt
> Use this file to discover all available pages before exploring further.

# Tạo hình ảnh (tương thích OpenAI Dall-E)

> OpenAI API tạo ảnh theo định dạng Dall-E.

- `POST /v1/images/generations`: Tạo tác vụ tạo ảnh

Header xác thực tiêu chuẩn:
- `Content-Type: application/json`

- `model: string`: Bắt buộc, tên mô hình công khai
- `prompt: string`: Khuyến nghị, mô tả tạo ảnh
- `n: number`: Tùy chọn, số lượng ảnh tạo
- `size: string`: Tùy chọn, biểu thức kích thước hoặc độ phân giải
- `quality: string`: Tùy chọn, mức chất lượng
- `response_format: string`: Tùy chọn, định dạng trả về

Các tham số mở rộng tương thích thường dùng:
- `image`
- `image_url`
- `image_urls`
- `image_list`
- `subject_image_list`
- `scene_image`
- `style_image`
- `negative_prompt`
- `aspect_ratio`
- `resolution`
- `callback_url`
- `external_task_id`

Kling Tham số mở rộng chuyên dụng:
- `model_name`
- `element_list`
- `result_type`
- `series_amount`
- `human_image`
- `cloth_image`
- `up_expansion_ratio`
- `down_expansion_ratio`
- `left_expansion_ratio`
- `right_expansion_ratio`

### 3.1 Dòng Nano Banana

Mô hình công khai:
- `nano-banana`
- `nano-banana-pro`
- `nano-banana-pro-2k`
- `nano-banana-pro-4k`
- `nano-banana-2`
- `nano-banana-2-2k`
- `nano-banana-2-4k`

Mô tả khả năng:
- `nano-banana`: Tạo ảnh từ văn bản cơ bản, cũng tương thích với chỉnh sửa ảnh
- `nano-banana-pro*`: Phiên bản chất lượng cao hơn
- `nano-banana-2*`: Họ phiên bản mới hơn
- `*-2k` / `*-4k`: Mẫu độ phân giải cao

Tham số thường dùng:
- Text-to-image: `model + prompt`
- Chỉnh sửa ảnh: `model + prompt + image`, cũng tương thích với `image_urls`
- Mở rộng thường dùng: `n` `size` `quality` `response_format`

Ví dụ:

```json
{
  "model": "nano-banana",
  "prompt": "a cute cat running in cloud",
  "n": 1,
  "size": "1024x1792"
}
```

```json
{
  "model": "nano-banana-pro",
  "prompt": "把主体改成赛博朋克夜景",
  "image": "https://example.com/input.png",
  "n": 1
}
```

### 3.2 Dòng Seedream

Mô hình công khai:
- `doubao-seedream-3-0-t2i-250415`
- `doubao-seedream-4-0-250828`
- `doubao-seedream-4-5-251128`
- `doubao-seedream-5-0-260128`

Mô tả khả năng:
- Thống nhất gọi theo cách text-to-image
- Khuyến nghị ưu tiên truyền tham số chuẩn: `prompt + model + size/aspect_ratio`

Tham số thường dùng:
- `model + prompt`
- Tùy chọn: `size` `aspect_ratio` `n`

### 3.3 Kling Mô hình chính ảnh thông thường

Mô hình chính công khai:
- `kling-image`

Bắt buộc:
- `model`
- `model_name`

Các `model_name` được hỗ trợ:
- `kling-v1`
- `kling-v1-5`
- `kling-v2`
- `kling-v2-new`
- `kling-v2-1`
- `kling-v3`

Mô tả khả năng:
- Text-to-image: `model + model_name + prompt`
- Image-to-image: thêm `image` trên cơ sở text-to-image
- Multi-image-to-image: truyền `subject_image_list`, hoặc truyền nhiều `image_urls/images`
- Outpainting: truyền `image` và tham số tỷ lệ mở rộng ảnh

Tham số thường dùng:
- `image`
- `subject_image_list`
- `scene_image`
- `style_image`
- `aspect_ratio`
- `resolution`
- `up_expansion_ratio`
- `down_expansion_ratio`
- `left_expansion_ratio`
- `right_expansion_ratio`

Ví dụ:

```json
{
  "model": "kling-image",
  "model_name": "kling-v3",
  "prompt": "海边日落，电影感人像",
  "aspect_ratio": "16:9",
  "n": 1
}
```

### 3.4 Kling Mô hình chính ảnh Omni

Mô hình chính công khai:
- `kling-omni-image`

Bắt buộc:
- `model`
- `model_name`

Các `model_name` được hỗ trợ:
- `kling-image-o1`
- `kling-v3-omni`

Tham số thường dùng:
- `image_list`
- `element_list`
- `resolution`
- `aspect_ratio`
- `result_type`
- `series_amount`

Ví dụ:

```json
{
  "model": "kling-omni-image",
  "model_name": "kling-v3-omni",
  "prompt": "生成一张海边跳舞的图片",
  "element_list": [
    {
      "element_id": 835266081714884677
    }
  ]
}
```

### 3.5 Kling Mô hình thử đồ ảo

Mô hình công khai:
- `kolors-virtual-try-on-v1`
- `kolors-virtual-try-on-v1-5`

Tham số đầu vào tối thiểu:
- `model + human_image + cloth_image`

Giải thích:
- Hai mô hình này bản thân đã là mô hình chính hoàn chỉnh, không cần truyền thêm `model_name`

Ví dụ:

```json
{
  "model": "kolors-virtual-try-on-v1",
  "human_image": "https://example.com/human.jpg",
  "cloth_image": "https://example.com/cloth.jpg"
}
```



## OpenAPI

````yaml api-reference/vi/openapi.json POST /v1/images/generations
openapi: 3.0.0
info:
  title: Tài liệu tham khảo API của 出海营
  version: 1.0.0
  description: Public AI Gateway API Reference
servers:
  - url: https://api.aiid.edu.kg
security:
  - BearerAuth: []
tags:
  - name: Định dạng OpenAI (Chat)
  - name: Định dạng OpenAI (Responses)
  - name: Định dạng Gemini cho tạo ảnh
  - name: Tạo hình ảnhOpenAI định dạng DALL-E
  - name: Lấy danh sách mô hình
  - name: Tạo video HappyHorse và Wan
  - name: Định dạngKling tạo video
  - name: Định dạng Video Generation Omni và Veo
  - name: Tạo video Seedance
  - name: Định dạng tương thích Sora cho tạo video
  - name: Tạo video Vidu
  - name: Định dạng tác vụ tạo nhạc
paths:
  /v1/images/generations:
    post:
      tags:
        - Tạo hình ảnhOpenAI định dạng DALL-E
      summary: Tạo hình ảnh (tương thích OpenAI Dall-E)
      description: >-
        OpenAI API tạo ảnh theo định dạng Dall-E.


        - `POST /v1/images/generations`: Tạo tác vụ tạo ảnh


        Header xác thực tiêu chuẩn:

        - `Content-Type: application/json`


        - `model: string`: Bắt buộc, tên mô hình công khai

        - `prompt: string`: Khuyến nghị, mô tả tạo ảnh

        - `n: number`: Tùy chọn, số lượng ảnh tạo

        - `size: string`: Tùy chọn, biểu thức kích thước hoặc độ phân giải

        - `quality: string`: Tùy chọn, mức chất lượng

        - `response_format: string`: Tùy chọn, định dạng trả về


        Các tham số mở rộng tương thích thường dùng:

        - `image`

        - `image_url`

        - `image_urls`

        - `image_list`

        - `subject_image_list`

        - `scene_image`

        - `style_image`

        - `negative_prompt`

        - `aspect_ratio`

        - `resolution`

        - `callback_url`

        - `external_task_id`


        Kling Tham số mở rộng chuyên dụng:

        - `model_name`

        - `element_list`

        - `result_type`

        - `series_amount`

        - `human_image`

        - `cloth_image`

        - `up_expansion_ratio`

        - `down_expansion_ratio`

        - `left_expansion_ratio`

        - `right_expansion_ratio`


        ### 3.1 Dòng Nano Banana


        Mô hình công khai:

        - `nano-banana`

        - `nano-banana-pro`

        - `nano-banana-pro-2k`

        - `nano-banana-pro-4k`

        - `nano-banana-2`

        - `nano-banana-2-2k`

        - `nano-banana-2-4k`


        Mô tả khả năng:

        - `nano-banana`: Tạo ảnh từ văn bản cơ bản, cũng tương thích với chỉnh
        sửa ảnh

        - `nano-banana-pro*`: Phiên bản chất lượng cao hơn

        - `nano-banana-2*`: Họ phiên bản mới hơn

        - `*-2k` / `*-4k`: Mẫu độ phân giải cao


        Tham số thường dùng:

        - Text-to-image: `model + prompt`

        - Chỉnh sửa ảnh: `model + prompt + image`, cũng tương thích với
        `image_urls`

        - Mở rộng thường dùng: `n` `size` `quality` `response_format`


        Ví dụ:


        ```json

        {
          "model": "nano-banana",
          "prompt": "a cute cat running in cloud",
          "n": 1,
          "size": "1024x1792"
        }

        ```


        ```json

        {
          "model": "nano-banana-pro",
          "prompt": "把主体改成赛博朋克夜景",
          "image": "https://example.com/input.png",
          "n": 1
        }

        ```


        ### 3.2 Dòng Seedream


        Mô hình công khai:

        - `doubao-seedream-3-0-t2i-250415`

        - `doubao-seedream-4-0-250828`

        - `doubao-seedream-4-5-251128`

        - `doubao-seedream-5-0-260128`


        Mô tả khả năng:

        - Thống nhất gọi theo cách text-to-image

        - Khuyến nghị ưu tiên truyền tham số chuẩn: `prompt + model +
        size/aspect_ratio`


        Tham số thường dùng:

        - `model + prompt`

        - Tùy chọn: `size` `aspect_ratio` `n`


        ### 3.3 Kling Mô hình chính ảnh thông thường


        Mô hình chính công khai:

        - `kling-image`


        Bắt buộc:

        - `model`

        - `model_name`


        Các `model_name` được hỗ trợ:

        - `kling-v1`

        - `kling-v1-5`

        - `kling-v2`

        - `kling-v2-new`

        - `kling-v2-1`

        - `kling-v3`


        Mô tả khả năng:

        - Text-to-image: `model + model_name + prompt`

        - Image-to-image: thêm `image` trên cơ sở text-to-image

        - Multi-image-to-image: truyền `subject_image_list`, hoặc truyền nhiều
        `image_urls/images`

        - Outpainting: truyền `image` và tham số tỷ lệ mở rộng ảnh


        Tham số thường dùng:

        - `image`

        - `subject_image_list`

        - `scene_image`

        - `style_image`

        - `aspect_ratio`

        - `resolution`

        - `up_expansion_ratio`

        - `down_expansion_ratio`

        - `left_expansion_ratio`

        - `right_expansion_ratio`


        Ví dụ:


        ```json

        {
          "model": "kling-image",
          "model_name": "kling-v3",
          "prompt": "海边日落，电影感人像",
          "aspect_ratio": "16:9",
          "n": 1
        }

        ```


        ### 3.4 Kling Mô hình chính ảnh Omni


        Mô hình chính công khai:

        - `kling-omni-image`


        Bắt buộc:

        - `model`

        - `model_name`


        Các `model_name` được hỗ trợ:

        - `kling-image-o1`

        - `kling-v3-omni`


        Tham số thường dùng:

        - `image_list`

        - `element_list`

        - `resolution`

        - `aspect_ratio`

        - `result_type`

        - `series_amount`


        Ví dụ:


        ```json

        {
          "model": "kling-omni-image",
          "model_name": "kling-v3-omni",
          "prompt": "生成一张海边跳舞的图片",
          "element_list": [
            {
              "element_id": 835266081714884677
            }
          ]
        }

        ```


        ### 3.5 Kling Mô hình thử đồ ảo


        Mô hình công khai:

        - `kolors-virtual-try-on-v1`

        - `kolors-virtual-try-on-v1-5`


        Tham số đầu vào tối thiểu:

        - `model + human_image + cloth_image`


        Giải thích:

        - Hai mô hình này bản thân đã là mô hình chính hoàn chỉnh, không cần
        truyền thêm `model_name`


        Ví dụ:


        ```json

        {
          "model": "kolors-virtual-try-on-v1",
          "human_image": "https://example.com/human.jpg",
          "cloth_image": "https://example.com/cloth.jpg"
        }

        ```
      operationId: createImageGeneration
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: Tên mô hình hình ảnh công khai.
                  example: dall-e-3
                  enum:
                    - nano-banana
                    - doubao-seedream-3-0-t2i-250415
                    - kling-image
                    - kling-omni-image
                    - kolors-virtual-try-on-v1
                    - kolors-virtual-try-on-v1-5
                prompt:
                  type: string
                  description: Mô tả tạo ảnh. Với mô hình thử đồ ảo, có thể không truyền.
                'n':
                  type: integer
                  description: Số lượng ảnh được tạo.
                  default: 1
                size:
                  type: string
                  description: Biểu thị kích thước hoặc độ phân giải.
                  enum:
                    - 1024x1024
                    - 1024x1792
                    - 1792x1024
                quality:
                  type: string
                  description: Cấp độ chất lượng.
                  enum:
                    - standard
                    - hd
                style:
                  type: string
                  description: Phong cách
                  enum:
                    - vivid
                    - natural
                response_format:
                  type: string
                  description: Định dạng trả về.
                  enum:
                    - url
                    - b64_json
                user:
                  type: string
                  description: ID người dùng
              required:
                - model
                - prompt
            examples:
              nano_banana_text2img:
                summary: Nano Banana Tạo ảnh từ văn bản
                value:
                  model: nano-banana
                  prompt: a cute cat running in cloud
                  'n': 1
                  size: 1024x1792
              seedream_text2img:
                summary: Seedream tạo ảnh từ văn bản
                value:
                  model: doubao-seedream-3-0-t2i-250415
                  prompt: 一张电影感海边日落人像
                  size: 1536x1024
                  'n': 1
              kling_text2img:
                summary: Kling Tạo ảnh từ văn bản
                value:
                  model: kling-image
                  model_name: kling-v3
                  prompt: 海边日落，电影感人像
                  aspect_ratio: '16:9'
                  'n': 1
              kling_img2img:
                summary: Kling Tạo ảnh từ ảnh
                value:
                  model: kling-image
                  model_name: kling-v2-1
                  prompt: 改成赛博朋克夜景风格
                  image: https://example.com/input.png
                  'n': 1
              kling_omni_image:
                summary: Kling Ảnh Omni
                value:
                  model: kling-omni-image
                  model_name: kling-v3-omni
                  prompt: 生成一张海边跳舞的图片
                  element_list:
                    - element_id: 835266081714884700
              kling_virtual_try_on:
                summary: Kling Thử đồ ảo
                value:
                  model: kolors-virtual-try-on-v1
                  human_image: https://example.com/human.jpg
                  cloth_image: https://example.com/cloth.jpg
      responses:
        '200':
          description: Tạo hình ảnh thành công
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
              b64_json:
                type: string
              revised_prompt:
                type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |-
        Sử dụng xác thực Bearer Token.
        Định dạng: `Authorization: Bearer sk-xxxxxx`

````