# Kirim tugas pembuatan gambar

**API:** Model API

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

Mengembalikan HTTP 202 dengan task_id persisten. Lakukan polling GET /api/v1/images/generations/{task_id}. Input datar atau input bertingkat didukung; input bertingkat diutamakan. Field callback diabaikan. Kemampuan dan parameter input bergantung pada model dan kanal yang dikonfigurasi.

## Base URL

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

## Authentication

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

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Request-Id` | header | no | string | ID permintaan pemanggil opsional yang dikembalikan untuk diagnostik. |
| `X-Felo-Channel` | header | no | string, default: "default" | Kode kanal publik yang dipisahkan koma dan berurutan. Hilangkan header ini untuk menggunakan default; default harus digunakan sendiri. Dalam mode wallet, default memindai urutan kanal publik efektif model secara terbalik, melewati kanal yang tidak dipublikasikan atau tidak tersedia, dan memilih penyedia kanal pertama yang tersedia. Ini mencakup endpoint yang tersedia dari penyedia tersebut dengan ID model upstream dan tingkat layanan yang sama. Kanal eksplisit divalidasi dalam urutan yang ditentukan klien; hanya grup penyedia kanal pertama yang dikirimkan. Tidak ada fallback otomatis ke penyedia lain. Header penyedia lama tidak dapat menimpa perutean kanal. |

## 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 bertingkat opsional; diutamakan di atas input datar.",
      "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": "Saat ini hanya default (standard) yang didukung. Nilai yang dihilangkan, null, alias, dan string yang tidak didukung akan kembali ke default; tipe lain mengembalikan HTTP 400. Kanal dan harga yang dikonfigurasi tetap tidak berubah. API teks mengirim nilai standar penyedia; API Decisions dan pembuatan menghilangkan field upstream."
        }
      }
    },
    "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": "Saat ini hanya default (standard) yang didukung. Nilai yang dihilangkan, null, alias, dan string yang tidak didukung akan kembali ke default; tipe lain mengembalikan HTTP 400. Kanal dan harga yang dikonfigurasi tetap tidak berubah. API teks mengirim nilai standar penyedia; API Decisions dan pembuatan menghilangkan field upstream."
    }
  },
  "additionalProperties": true,
  "description": "Input khusus model mengikuti protokol model publik yang dikonfigurasi."
}
```

Example:

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

## Responses

### 202 — Tugas diterima

**application/json**

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

### 400 — Permintaan tidak valid (model tidak dikenal, mode input tercampur, field tidak valid)

**application/json**

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

### 401 — Kunci API Felo tidak valid atau tidak ada

**application/json**

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

### 402 — Saldo tidak cukup / persyaratan tagihan tidak terpenuhi

**application/json**

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

### 403 — Akun tidak diizinkan (diperlukan langganan atau pengguna diblokir). Model yang dinonaktifkan juga ditolak sebelum panggilan upstream. Permintaan dan tugas yang sudah diterima tetap berlanjut.

**application/json**

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

### 429 — Batas permintaan atau pengeluaran tercapai

**application/json**

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

### 502 — Penyedia upstream gagal

**application/json**

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

### 503 — Layanan pembuatan atau layanan tagihan sementara tidak tersedia

**application/json**

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

## Schema definitions

### GenerationError

`#/components/schemas/GenerationError`

```json
{
  "type": "object",
  "description": "Envelope error yang kompatibel dengan 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 yang digunakan untuk polling."
    },
    "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 hingga tugas berhasil."
    }
  }
}
```
