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

# Media jobs

> Images, video, music and speech through asynchronous jobs.

Images, video, music and speech are generated by **jobs**, because a render takes from seconds to several minutes.

<Steps>
  <Step title="Start">
    `POST /v1/{images|videos|music|audio}/jobs` with a model of that kind. The answer comes back at once with `id`, `status: "pending"` and `estimated_cost`.
  </Step>

  <Step title="Poll">
    `GET /v1/{kind}/jobs/{id}` every 3–5 seconds until `status` is `completed` or `failed`. The job keeps running if you stop polling.
  </Step>

  <Step title="Download">
    Each `output` entry has a `url` (`…/v1/{kind}/jobs/{id}/content?index=N`). It serves the file with the same `X-API-KEY`; `Range` requests are supported.
  </Step>
</Steps>

| Kind | Render time | Retention |
| - | - | - |
| Images | Seconds to a couple of minutes (4K up to 5) | 7 days |
| Video | 30 seconds to a few minutes | 7 days |
| Music | Several minutes | Download right away |
| Speech and sound | Depends on the model | Download right away |

The exact deadline is in `expires_at`; after it you get `410 content_expired`. An account can run a limited number of jobs at once (`429 too_many_jobs`).

## Images

`POST /v1/images/jobs` — text-to-image, or editing when `input_images` are given. One image per job.

| Field | Description |
| - | - |
| `model`, `prompt` | Required. Prompt usually up to 5000 characters |
| `size` | `1:1`, `16:9`, `1k`/`2k`/`4k`, `WIDTHxHEIGHT` or `auto` |
| `input_images` | References (https or `data:` URI), usually up to 10 |
| `output_format` | `png` (default), `jpeg`, `webp` |
| `quality` | `standard`, `hd` |
| `mj_task_id`, `mj_index` | Midjourney actions |

## Video

`POST /v1/videos/jobs`. The mode follows the inputs: text only; `image_url` (+ `last_frame_url`) for image-to-video; `reference_image_urls` / `video_urls` for reference-to-video; `video_url` + `image_url` for motion control.

| Field | Description |
| - | - |
| `model`, `prompt` | Required. Prompt up to 10,000 characters |
| `duration` | Seconds; each model has its own set (Veo 4/6/8, Kling 5/10, Seedance 4–15) |
| `aspect_ratio` | `16:9` (default), `9:16`, `1:1` and more |
| `resolution` | `480p`, `720p`, `1080p`, `4k` |
| `audio` | Sound track where supported (may raise the price) |
| `mode` | `standard`, `pro`, `master` |
| `output_format` | `mp4` (default), `mov`, `webm` |

## Music

`POST /v1/music/jobs`. Send only `prompt` and the model writes the lyrics and picks a style. Fields: `lyrics` (up to 5000), `style` (up to 1000), `title` (up to 200), `instrumental`. Some models return two tracks for one price.

## Speech and sound

`POST /v1/audio/jobs`. Speech — `text` + `voice`; dialogue — `dialogue` (turns with `text` and `voice`); sound effects — `text` + `duration_seconds` (up to 30); voice isolation — `audio_url`. Optional: `language_code`, `speed` (0.7–1.2), `stability`, `similarity_boost`.

## Example

```python theme={null}
import os, time, requests

BASE = "https://b2b.api.ascn.ai/api/ai-gateway"
HEADERS = {"X-API-KEY": os.environ["ASCN_API_KEY"]}

job = requests.post(f"{BASE}/v1/images/jobs", headers=HEADERS, json={
    "model": "google/nano-banana-2",
    "prompt": "A cozy cabin at sunrise, cinematic light",
    "size": "16:9",
}).json()

while job["status"] not in ("completed", "failed"):
    time.sleep(4)
    job = requests.get(f"{BASE}/v1/images/jobs/{job['id']}", headers=HEADERS).json()

print(job["output"][0]["url"] if job["status"] == "completed" else job["error"])
```

## Job errors

| `error.code` | What to do |
| - | - |
| `content_moderation` | Rephrase the prompt |
| `input_rejected` | Change the input file, see `message` |
| `invalid_request` | Fix the fields as `message` says |
| `generation_failed`, `job_expired` | Start a new job |

A failed job is not charged. Reference files must be reachable over https without signing in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.