# Hantar tugas penjanaan imej

**API:** Model API

**Endpoint:** `POST /api/v1/images/generations`

Memulangkan HTTP 202 dengan task_id yang berterusan. Semak GET /api/v1/images/generations/{task_id} secara berkala. Input rata atau input bersarang disokong; input bersarang diutamakan. Medan callback diabaikan. Keupayaan dan parameter input bergantung pada model dan saluran yang dikonfigurasikan.

## Base URL

- `https://openapi.felo.ai` — Pengeluaran

## Authentication

- `FeloBearerAuth` (http bearer) — Kunci API Felo dihantar sebagai `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — Kunci API Felo dihantar sebagai `X-API-Key: <key>`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Request-Id` | header | no | string | ID permintaan pemanggil pilihan yang dipantulkan semula untuk diagnostik. |
| `X-Felo-Channel` | header | no | string, default: "default" | Kod saluran awam yang dipisahkan koma dan tersusun. Tinggalkan pengepala ini untuk menggunakan default; default mesti digunakan secara bersendirian. Dalam mod dompet, default mengimbas susunan saluran awam berkesan model secara terbalik, melangkau saluran yang tidak diterbitkan atau tidak tersedia, dan memilih penyedia saluran pertama yang tersedia. Ia merangkumi endpoint tersedia daripada penyedia itu dengan ID model huluan dan tahap perkhidmatan yang sama. Saluran eksplisit disahkan mengikut susunan yang ditetapkan klien; hanya kumpulan penyedia saluran pertama yang dihantar. Tiada sandaran automatik kepada penyedia lain. Pengepala penyedia legasi tidak boleh mengatasi penghalaan saluran. |

## Request body

Required: **yes**

### application/json

Schema: `ImageGenerationRequest` (`#/components/schemas/ImageGenerationRequest`)

```json
{
  "type": "object",
  "required": [
    "model"
  ],
  "properties": {
    "model": {
      "type": "string"
    },
    "prompt": {
      "type": "string"
    },
    "input": {
      "type": "object",
      "additionalProperties": true,
      "description": "Input bersarang pilihan; diutamakan berbanding input rata.",
      "properties": {
        "input_references": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "image_url"
                ]
              },
              "image_url": {
                "type": "object",
                "additionalProperties": false,
                "oneOf": [
                  {
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "required": [
                      "file_id"
                    ]
                  }
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "\\S",
                    "not": {
                      "pattern": "^\\s*felo_file_"
                    }
                  },
                  "file_id": {
                    "type": "string",
                    "maxLength": 80,
                    "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                    "description": "Uploaded Felo file owned by the authenticated user."
                  }
                }
              },
              "role": {
                "type": "string",
                "description": "Optional asset role for models that define reference roles, e.g. refer_image, style_refer_image or subject_refer_image for Kling long images. Other channels reject it."
              }
            },
            "required": [
              "type",
              "image_url"
            ]
          },
          "description": "Reference images by URL/data URI or uploaded Felo file_id. At most 100 Felo references and 50,000,000 bytes per request; model/channel limits may be lower. Keep files until completion."
        },
        "service_tier": {
          "type": [
            "string",
            "null"
          ],
          "default": "default",
          "description": "Pada masa ini hanya default (standard) disokong. Nilai yang ditinggalkan, null, alias dan rentetan tidak disokong akan kembali kepada default; jenis lain memulangkan HTTP 400. Saluran dan harga yang dikonfigurasikan kekal tidak berubah. API teks menghantar nilai standard penyedia; API Decisions dan penjanaan meninggalkan medan huluan."
        }
      }
    },
    "n": {
      "type": "integer"
    },
    "size": {
      "type": "string",
      "description": "Model-specific size. For supported Gemini token-priced image models, pixel dimensions select the nearest supported aspect ratio only; ignored when aspect_ratio is supplied. Use image_size or resolution for the resolution tier."
    },
    "image_size": {
      "type": "string",
      "enum": [
        "512",
        "1K",
        "2K",
        "4K"
      ],
      "description": "Resolution tier for supported Gemini token-priced image models. Available tiers depend on the model and channel."
    },
    "resolution": {
      "type": "string",
      "description": "Resolution tier; must agree with image_size when both are supplied."
    },
    "aspect_ratio": {
      "type": "string",
      "description": "Output aspect ratio. Supported values depend on the model and channel."
    },
    "provider": {
      "type": "object",
      "required": [
        "options"
      ],
      "additionalProperties": false,
      "properties": {
        "options": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 1,
          "additionalProperties": {
            "type": "object"
          },
          "description": "Options keyed by the slug published in the model catalog."
        }
      }
    },
    "quality": {
      "type": "string",
      "description": "Model-specific quality or resolution tier. For supported Gemini token-priced models, auto/low map to 1K, medium to 2K and high to 4K, subject to model capabilities. Explicit image_size or resolution takes precedence over these labels. Estimated reservations do not replace actual usage billing."
    },
    "input_references": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image_url"
            ]
          },
          "image_url": {
            "type": "object",
            "additionalProperties": false,
            "oneOf": [
              {
                "required": [
                  "url"
                ]
              },
              {
                "required": [
                  "file_id"
                ]
              }
            ],
            "properties": {
              "url": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S",
                "not": {
                  "pattern": "^\\s*felo_file_"
                }
              },
              "file_id": {
                "type": "string",
                "maxLength": 80,
                "pattern": "^felo_file_[A-Za-z0-9_-]{1,70}$",
                "description": "Uploaded Felo file owned by the authenticated user."
              }
            }
          },
          "role": {
            "type": "string",
            "description": "Optional asset role for models that define reference roles, e.g. refer_image, style_refer_image or subject_refer_image for Kling long images. Other channels reject it."
          }
        },
        "required": [
          "type",
          "image_url"
        ]
      },
      "description": "Reference images by URL/data URI or uploaded Felo file_id. At most 100 Felo references and 50,000,000 bytes per request; model/channel limits may be lower. Keep files until completion."
    },
    "skill": {
      "type": "string",
      "description": "Long-image type for models that publish it in parameter_definitions, e.g. ecommerce or webpage."
    },
    "length": {
      "type": "string",
      "description": "Page length for long-image models; see applies_when in parameter_definitions for the skills it applies to."
    },
    "service_tier": {
      "type": [
        "string",
        "null"
      ],
      "default": "default",
      "description": "Pada masa ini hanya default (standard) disokong. Nilai yang ditinggalkan, null, alias dan rentetan tidak disokong akan kembali kepada default; jenis lain memulangkan HTTP 400. Saluran dan harga yang dikonfigurasikan kekal tidak berubah. API teks menghantar nilai standard penyedia; API Decisions dan penjanaan meninggalkan medan huluan."
    }
  },
  "additionalProperties": true,
  "description": "Input khusus model mengikut protokol model awam yang dikonfigurasikan."
}
```

Example:

```json
{
  "model": "configured-image-model",
  "prompt": "a cat"
}
```

## Responses

### 202 — Tugas diterima

**application/json**

Schema: `ImageGenerationAccepted` (`#/components/schemas/ImageGenerationAccepted`)

### 400 — Permintaan tidak sah (model tidak diketahui, mod input bercampur, medan tidak sah)

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 401 — Kunci API Felo tidak sah atau tiada

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 402 — Baki tidak mencukupi / keperluan pengebilan tidak dipenuhi

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 403 — Akaun tidak dibenarkan (langganan diperlukan atau pengguna disekat). Model yang dilumpuhkan juga ditolak sebelum panggilan huluan. Permintaan dan tugas yang telah diterima terus berjalan.

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 429 — Had permintaan atau perbelanjaan telah dicapai

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 502 — Penyedia huluan gagal

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

### 503 — Perkhidmatan penjanaan atau perkhidmatan pengebilan tidak tersedia buat sementara waktu

**application/json**

Schema: `GenerationError` (`#/components/schemas/GenerationError`)

## Schema definitions

### GenerationError

`#/components/schemas/GenerationError`

```json
{
  "type": "object",
  "description": "Sampul ralat serasi OpenAI.",
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "message",
        "type"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "invalid_request_error",
            "server_error"
          ]
        },
        "param": {
          "type": "string",
          "nullable": true
        },
        "code": {
          "type": "string"
        }
      }
    }
  }
}
```

### ImageGenerationAccepted

`#/components/schemas/ImageGenerationAccepted`

```json
{
  "type": "object",
  "required": [
    "task_id",
    "status",
    "kind",
    "outputs"
  ],
  "properties": {
    "task_id": {
      "type": "string",
      "description": "ID tugas untuk digunakan semasa menyemak status."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "image"
      ]
    },
    "outputs": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string",
            "format": "uri"
          },
          {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "watermark_url": {
                "type": "string",
                "format": "uri",
                "nullable": true,
                "description": "Optional watermarked version of this image."
              },
              "b64_json": {
                "type": "string"
              }
            }
          }
        ]
      },
      "description": "Kosong sehingga tugas berjaya."
    }
  }
}
```
