> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Video generation için polling ve webhook kullanın

> Task ID'lerini saklayarak, task durumunu kontrol ederek ve callback teslimat hatalarını işleyerek CometAPI video generation sürecini polling ve webhook'larla takip edin.

Video generation için temel yöntem olarak polling kullanın; çünkü her async job sorgulayabileceğiniz bir task ID döndürür. Yalnızca seçilen video endpoint callback URL'leri desteklediğinde webhook ekleyin ve kaçırılan veya provider'a özgü callback teslimatları için polling'i tek doğruluk kaynağı olarak tutun.

## Bir video task oluşturun

Aşağıdaki istek, minimal bir video task oluşturur ve döndürülen ID'yi saklar. Duration, resolution veya callback alanlarını yalnızca seçilen model sayfası bu alanları belgeliyorsa ekleyin.

```bash theme={null}
curl https://api.cometapi.com/v1/videos \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -F "model=doubao-seedance-2-0" \
  -F "prompt=A cinematic shot of a paper airplane crossing a desk"
```

Yanıt, bir task ID ve status içerir:

```json theme={null}
{
  "id": "task_example",
  "task_id": "task_example",
  "object": "video",
  "model": "doubao-seedance-2-0",
  "status": "queued",
  "progress": 0,
  "created_at": 1779872000
}
```

## Durumu poll edin

Aşağıdaki istek video task durumunu kontrol eder:

```bash theme={null}
curl https://api.cometapi.com/v1/videos/task_example \
  -H "Authorization: Bearer $COMETAPI_KEY"
```

Task ilerledikçe yanıt değişir. Tamamlanan yanıtlar, model adapter bir sonuç URL'sine sahipse `video_url` içerebilir; aksi halde modele özgü sonuç alanlarını veya model proxied download destekliyorsa `/v1/videos/{id}/content` content route'unu kullanın.

```json theme={null}
{
  "id": "task_example",
  "object": "video",
  "model": "doubao-seedance-2-0",
  "status": "completed",
  "progress": 100,
  "completed_at": 1779872300,
  "video_url": "<generated-video-url>"
}
```

## Bir webhook alın

CometAPI, her video model için tek bir evrensel callback payload tanımlamaz. Callback'leri provider'a özgü pass-through event'ler olarak değerlendirin, ham body'yi saklayın ve nihai durumu polling ile uzlaştırın.

Aşağıdaki Express handler bir video callback'i kabul eder ve event'i saklar:

```javascript theme={null}
import express from "express";

const app = express();
app.use(express.json({ limit: "2mb" }));

app.post("/cometapi/video-webhook", async (request, response) => {
  const event = request.body;

  console.log("Task ID:", event.task_id || event.id);
  console.log("Status:", event.status);

  response.status(200).json({ received: true });
});

app.listen(3000);
```

Bir callback payload genellikle task kimliği ve status alanlarını içerir, ancak tam iç içe yapı seçilen model veya provider'a bağlıdır:

```json theme={null}
{
  "task_id": "task_example",
  "status": "completed",
  "progress": 100,
  "result": {
    "video_url": "https://example.com/result.mp4"
  }
}
```

## Yaygın hatalar

| Error                               | Fix                                                                                                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Kaybolan callback                   | Uygulamanız terminal bir durumu kaydedene kadar task ID ile poll edin.                                                                     |
| Yinelenen callback                  | Callback işlemeyi task ID bazında idempotent hale getirin.                                                                                 |
| Callback reddedildi                 | Hızlıca bir `2xx` yanıtı döndürün, ardından job'ı arka planda işleyin.                                                                     |
| Provider'a özgü payload uyuşmazlığı | Ham callback payload'unu saklayın ve uygulamanızda normalize edin.                                                                         |
| Eksik `video_url`                   | `video_url` alanını opsiyonel kabul edin ve varsa polling ile modele özgü sonuç alanlarını veya `/v1/videos/{id}/content` yolunu kullanın. |

## İlgili bağlantılar

* [Video Models](/api/video)
* [Video oluştur](/api/video/sora-2/create)
* [Videoyu al](/api/video/sora-2/retrieve)
* [Models sayfası](/tr/overview/models)
* [Model dizini](https://www.cometapi.com/models/)
* [Fiyatlandırma](https://www.cometapi.com/pricing/)

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "TechArticle",
        "@id": "https://apidoc.cometapi.com/guides/webhook-and-polling-for-video-generation",
        "headline": "Video oluşturma için webhooks ve polling nasıl kullanılır?",
        "description": "Görev kimliklerini depolayarak, görev durumunu kontrol ederek ve callback teslimat hatalarını işleyerek CometAPI video oluşturma için polling ve webhooks kullanın.",
        "url": "https://apidoc.cometapi.com/guides/webhook-and-polling-for-video-generation",
        "author": {
          "@type": "Organization",
          "name": "CometAPI"
        },
        "publisher": {
          "@type": "Organization",
          "name": "CometAPI",
          "url": "https://www.cometapi.com"
        }
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI Dokümantasyonu",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "Kılavuzlar",
            "item": "https://apidoc.cometapi.com/guides/use-cometapi-with-openai-sdk"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "Video oluşturma için webhooks ve polling nasıl kullanılır?",
            "item": "https://apidoc.cometapi.com/guides/webhook-and-polling-for-video-generation"
          }
        ]
      }
    ]
    }
    `}
</script>
