# Prześlij zadanie generowania obrazu

**API:** Model API

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

Zwraca HTTP 202 z trwałym task_id. Odpytuj GET /api/v1/images/generations/{task_id}. Obsługiwane jest wejście płaskie lub zagnieżdżone; wejście zagnieżdżone ma pierwszeństwo. Pola callback są ignorowane. Możliwości i parametry wejściowe zależą od skonfigurowanego modelu i kanału.

## Base URL

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

## Authentication

- `FeloBearerAuth` (http bearer) — Klucz API Felo przesyłany jako `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — Klucz API Felo przesyłany jako `X-API-Key: <key>`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Request-Id` | header | no | string | Opcjonalny identyfikator żądania wywołującego, zwracany w celach diagnostycznych. |
| `X-Felo-Channel` | header | no | string, default: "default" | Uporządkowane kody publicznych kanałów rozdzielone przecinkami. Pomiń ten nagłówek, aby użyć wartości domyślnej; wartość domyślna musi być używana samodzielnie. W trybie portfela wartość domyślna przegląda efektywną kolejność publicznych kanałów modelu od końca, pomija kanały nieopublikowane lub niedostępne i wybiera dostawcę pierwszego dostępnego kanału. Obejmuje dostępne endpointy tego dostawcy o tym samym identyfikatorze modelu upstream i tym samym poziomie usługi. Jawne kanały są weryfikowane w kolejności podanej przez klienta; przesyłana jest tylko grupa dostawcy pierwszego kanału. Brak automatycznego przełączania na innych dostawców. Przestarzałe nagłówki dostawcy nie mogą nadpisać routingu kanałów. |

## 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": "Opcjonalne zagnieżdżone wejście; ma pierwszeństwo przed wejściem płaskim.",
      "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": "Obecnie obsługiwana jest tylko wartość default (standard). Pominięcie, null, aliasy i nieobsługiwane ciągi znaków powodują powrót do wartości default; inne typy zwracają HTTP 400. Skonfigurowane kanały i ceny pozostają bez zmian. Interfejsy API modeli tekstowych wysyłają standardową wartość dostawcy; interfejsy Decisions i generowania pomijają pole 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": "Obecnie obsługiwana jest tylko wartość default (standard). Pominięcie, null, aliasy i nieobsługiwane ciągi znaków powodują powrót do wartości default; inne typy zwracają HTTP 400. Skonfigurowane kanały i ceny pozostają bez zmian. Interfejsy API modeli tekstowych wysyłają standardową wartość dostawcy; interfejsy Decisions i generowania pomijają pole upstream."
    }
  },
  "additionalProperties": true,
  "description": "Wejście zależne od modelu jest zgodne ze skonfigurowanym publicznym protokołem modelu."
}
```

Example:

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

## Responses

### 202 — Zadanie przyjęte

**application/json**

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

### 400 — Nieprawidłowe żądanie (nieznany model, mieszane tryby wejścia, nieprawidłowe pola)

**application/json**

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

### 401 — Nieprawidłowy lub brakujący klucz API Felo

**application/json**

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

### 402 — Niewystarczające saldo / niespełniony warunek rozliczeniowy

**application/json**

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

### 403 — Konto nie ma uprawnień (wymagana subskrypcja lub użytkownik zablokowany). Wyłączone modele są również odrzucane przed wywołaniami upstream. Istniejące przyjęte żądania i zadania są kontynuowane.

**application/json**

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

### 429 — Osiągnięto limit żądań lub wydatków

**application/json**

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

### 502 — Błąd dostawcy upstream

**application/json**

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

### 503 — Usługa generowania lub usługa rozliczeniowa tymczasowo niedostępna

**application/json**

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

## Schema definitions

### GenerationError

`#/components/schemas/GenerationError`

```json
{
  "type": "object",
  "description": "Koperta błędu zgodna z 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": "Identyfikator zadania używany do odpytywania."
    },
    "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": "Puste, dopóki zadanie się nie powiedzie."
    }
  }
}
```
