# إرسال مهمة توليد فيديو

**API:** Model API

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

إدخال فيديو مسطّح بأسلوب OpenRouter. تحتفظ معرّفات نماذج Felo والقنوات ومعرّفات المهام والاستجابات بتنسيق Felo. تُرفض أغلفة input القديمة والحقول الأصلية الخاصة بالمزوّدين. لا يُدعم رد الاتصال (callback) ولا المتابعة ولا خيارات المزوّد ولا رفع دقة الفيديو. قد تقيّد قدرات النموذج أو القناة هذه المعاملات أكثر. يعيد HTTP 202 مع task_id من Felo. استطلع GET /api/v1/videos/generations/{task_id}. تعيد الحقول غير المدعومة HTTP 400.

## Base URL

- `https://openapi.felo.ai` — بيئة الإنتاج

## Authentication

- `FeloBearerAuth` (http bearer) — مفتاح API من Felo يُرسل في الترويسة `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — مفتاح API من Felo يُرسل في الترويسة `X-API-Key: <key>`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Request-Id` | header | no | string | معرّف طلب اختياري من المستدعي يُعاد في الاستجابة لأغراض التشخيص. |
| `X-Felo-Channel` | header | no | string, default: "default" | رموز قنوات عامة مرتبة ومفصولة بفواصل. احذف هذه الترويسة لاستخدام default؛ ويجب استخدام default وحده. في وضع المحفظة، يفحص default ترتيب القنوات العامة الفعلية للنموذج بترتيب عكسي، ويتخطى القنوات غير المنشورة أو غير المتاحة، ويختار مزوّد أول قناة متاحة. ويشمل نقاط النهاية المتاحة من ذلك المزوّد ذات معرّف النموذج الأعلى ومستوى الخدمة نفسيهما. تُتحقق القنوات الصريحة بالترتيب الذي يحدده العميل؛ ولا تُقدَّم سوى مجموعة مزوّد القناة الأولى. لا يوجد رجوع تلقائي إلى مزوّدين آخرين. لا يمكن لترويسات المزوّد القديمة تجاوز توجيه القنوات. |

## Request body

Required: **yes**

### application/json

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

```json
{
  "type": "object",
  "required": [
    "model"
  ],
  "additionalProperties": false,
  "description": "إدخال فيديو مسطّح بأسلوب OpenRouter. تحتفظ معرّفات نماذج Felo والقنوات ومعرّفات المهام والاستجابات بتنسيق Felo. تُرفض أغلفة input القديمة والحقول الأصلية الخاصة بالمزوّدين. لا يُدعم رد الاتصال (callback) ولا المتابعة ولا خيارات المزوّد ولا رفع دقة الفيديو. قد تقيّد قدرات النموذج أو القناة هذه المعاملات أكثر.",
  "properties": {
    "model": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S"
    },
    "prompt": {
      "type": "string"
    },
    "duration": {
      "type": "integer",
      "minimum": 1
    },
    "resolution": {
      "type": "string",
      "enum": [
        "360p",
        "480p",
        "720p",
        "768p",
        "1080p",
        "1K",
        "2K",
        "4K"
      ]
    },
    "aspect_ratio": {
      "type": "string",
      "enum": [
        "16:9",
        "9:16",
        "1:1",
        "4:3",
        "3:4",
        "3:2",
        "2:3",
        "21:9",
        "9:21"
      ]
    },
    "generate_audio": {
      "type": "boolean"
    },
    "character_orientation": {
      "type": "string",
      "enum": [
        "image",
        "video"
      ],
      "description": "Required by supported Kling motion-control models: orientation source."
    },
    "seed": {
      "type": "integer"
    },
    "size": {
      "type": "string",
      "pattern": "^[1-9][0-9]*x[1-9][0-9]*$"
    },
    "frame_images": {
      "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."
              }
            }
          },
          "frame_type": {
            "type": "string",
            "enum": [
              "first_frame",
              "last_frame"
            ]
          }
        },
        "required": [
          "type",
          "image_url",
          "frame_type"
        ]
      }
    },
    "input_references": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "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."
                  }
                }
              }
            },
            "required": [
              "type",
              "image_url"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "video_url"
                ]
              },
              "video_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."
                  }
                }
              }
            },
            "required": [
              "type",
              "video_url"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "audio_url"
                ]
              },
              "audio_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."
                  }
                }
              }
            },
            "required": [
              "type",
              "audio_url"
            ]
          }
        ]
      }
    },
    "user": {
      "type": "string",
      "maxLength": 256
    },
    "session_id": {
      "type": "string",
      "maxLength": 256
    },
    "trace": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "trace_id": {
          "type": "string"
        },
        "trace_name": {
          "type": "string"
        },
        "span_name": {
          "type": "string"
        },
        "generation_name": {
          "type": "string"
        },
        "parent_span_id": {
          "type": "string"
        }
      }
    },
    "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 provider_options."
        }
      }
    }
  }
}
```

Example:

```json
{
  "model": "veo-3.1-lite",
  "prompt": "A cinematic camera move",
  "duration": 4,
  "resolution": "720p",
  "generate_audio": false,
  "frame_images": [
    {
      "type": "image_url",
      "frame_type": "first_frame",
      "image_url": {
        "url": "https://example.com/first.png"
      }
    }
  ]
}
```

## Responses

### 202 — تم قبول المهمة

**application/json**

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

### 400 — طلب غير صالح (نموذج غير معروف، أنماط إدخال مختلطة، حقول غير صالحة)

**application/json**

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

### 401 — مفتاح API من Felo غير صالح أو مفقود

**application/json**

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

### 402 — الرصيد غير كافٍ / متطلب الفوترة غير مستوفٍ

**application/json**

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

### 403 — الحساب غير مصرّح له (يلزم اشتراك أو المستخدم محظور). تُرفض النماذج المعطّلة قبل استدعاءات المنبع أيضًا. تظل الطلبات والمهام المقبولة قائمة.

**application/json**

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

### 429 — تم بلوغ حد الطلبات أو حد الإنفاق

**application/json**

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

### 502 — فشل مزوّد المنبع

**application/json**

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

### 503 — خدمة التوليد أو خدمة الفوترة غير متاحة مؤقتًا

**application/json**

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

## Schema definitions

### GenerationError

`#/components/schemas/GenerationError`

```json
{
  "type": "object",
  "description": "مغلّف أخطاء متوافق مع 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"
        }
      }
    }
  }
}
```

### VideoGenerationAccepted

`#/components/schemas/VideoGenerationAccepted`

```json
{
  "type": "object",
  "required": [
    "task_id",
    "status",
    "kind",
    "outputs"
  ],
  "properties": {
    "task_id": {
      "type": "string",
      "description": "معرّف المهمة لاستخدامه في الاستعلام."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued"
      ]
    },
    "kind": {
      "type": "string",
      "enum": [
        "video"
      ]
    },
    "outputs": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "فارغ حتى تنجح المهمة."
    }
  }
}
```
