> ## Documentation Index
> Fetch the complete documentation index at: https://oxenai-eric-revamp-getting-started.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Async Queue

> Enqueue image and video generations that run in the background

## Overview

Video generation can take minutes. The async queue returns immediately with a generation id so you can avoid long-lived HTTP connections, run up to 4 generations in parallel, and build progress-tracking UIs.

## Enqueue a Job

<CodeGroup>
  ```python Python theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  HEADERS = {
      "Authorization": f"Bearer {API_KEY}",
      "Content-Type": "application/json",
  }

  response = requests.post(
      "https://hub.oxen.ai/api/ai/queue",
      headers=HEADERS,
      json={
          "model": "kling-video-v2-6-pro-text-to-video",
          "prompt": "A sunset timelapse over the ocean",
          "duration": 5,
      },
  )

  generations = response.json()["generations"]
  print(f"Enqueued {len(generations)} generation(s)")
  for g in generations:
      print(g["generation_id"], g["status"])
  ```

  ```bash cURL theme={null}
  curl -X POST https://hub.oxen.ai/api/ai/queue \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-video-v2-6-pro-text-to-video",
      "prompt": "A sunset timelapse over the ocean",
      "duration": 5
    }'
  ```
</CodeGroup>

## Poll Until Done

List in-progress generations with `GET /ai/queue`. A generation drops off the list once it finishes (or fails).

<CodeGroup>
  ```python Python theme={null}
  import time

  MODEL = "kling-video-v2-6-pro-text-to-video"

  while True:
      status = requests.get(
          "https://hub.oxen.ai/api/ai/queue",
          headers=HEADERS,
          params={"model": MODEL},
      ).json()
      if status["count"] == 0:
          break
      print(f"Still processing: {status['count']} remaining")
      time.sleep(10)

  print("Done!")
  ```

  ```bash cURL theme={null}
  curl -H "Authorization: Bearer YOUR_API_KEY" \
    "https://hub.oxen.ai/api/ai/queue?model=kling-video-v2-6-pro-text-to-video"
  ```
</CodeGroup>

## Fetch a Single Job

Use the generation id when you want one job's status without listing everything:

```bash theme={null}
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://hub.oxen.ai/api/ai/queue/GENERATION_ID"
```

## What's Next

* [Async Queue Reference](/inference-api/reference/async_queue) for the full parameter list, polling details, and cancellation
* [Video Generation Quick Start](/inference-api/quickstart/video-generation) for the synchronous counterpart
* [Model API References](/inference-api/reference/model-references) for per-model parameters you can pass through the queue
