opendunes
Video
Copy page ▾

Text to video

Make a clip from words alone, and save it.

  1. Write the prompt: what is seen, what moves, where, how it is filmed.
  2. Run the job: send it, ask until it ends, save the clip.
  3. Read how it ended.
  4. Read what it cost.

1. Write the prompt

A video model reads the prompt as a shot list. Name each of these, and the clip comes back closer to what you had in mind.

PartSaysExample
Subjectwho or what is in the framea baker in Tlemcen
Actionwhat moveslifts a tray of makrout from a wood oven
Settingthe place, the hour, the lightwarm morning light
Camerathe shot and its movementclose-up, slow push-in
Stylethe lookdocumentary, natural colour
Don't

Send a bakery. The model fills every gap on its own, and each run fills them differently.

Send A baker in Tlemcen lifts a tray of makrout from a wood oven, close-up, warm morning light, slow push-in.

2. Run the job

A clip takes minutes to make, so POST /v1/videos answers at once with a job, not the clip. The code below sends the job, asks every ten seconds until it ends, then saves the clip as makrout.mp4 or prints why there is none.

The model is alibaba/wan-3.0, asked for 6 seconds at 720p in 9:16 with sound: a phone story. Another model takes other values: Choose a video model.

import json
import os
import time
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/videos"
MODEL = "alibaba/wan-3.0"
PROMPT = (
    "A baker in Tlemcen lifts a tray of makrout from a wood oven, "
    "close-up, warm morning light, slow push-in"
)


def call(url, body=None):
    request = urllib.request.Request(
        url,
        data=json.dumps(body).encode() if body else None,
        headers={
            "Authorization": "Bearer " + API_KEY,
            "Content-Type": "application/json",
        },
    )
    return urllib.request.urlopen(request)


with call(
    ADDRESS,
    {
        "model": MODEL,
        "prompt": PROMPT,
        "duration": 6,
        "resolution": "720p",
        "aspect_ratio": "9:16",
        "generate_audio": True,
    },
) as response:
    job = json.load(response)

while job["status"] in ("pending", "in_progress"):
    time.sleep(10)
    with call(ADDRESS + "/" + job["id"]) as response:
        job = json.load(response)

if job["status"] == "completed":
    print("charged", job["usage"]["cost"], "DA")
    clip_address = ADDRESS + "/" + job["id"] + "/content?index=0"
    with call(clip_address) as response:
        with open("makrout.mp4", "wb") as clip:
            clip.write(response.read())
else:
    print(job["status"], job.get("error"))
You sendHolds
modela video model's ID
promptthe words from step 1
durationthe seconds of video, a whole number the model lists
resolutionthe size, as the model offers
aspect_ratiothe frame's shape, as the model offers
generate_audiotrue for a clip with sound, on a model that makes it

The clip's address is not a public link: call it with your API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →, as the code does. Asking and fetching are free, however often. Each route in full: Clip status · Clip download.

Good to know

Asking every ten seconds is one way to wait. A callback_url gets the job's end posted to your server instead: Video webhooks.

3. Read how it ended

pending and in_progress mean the job is still running. The other four are the end, and the job never moves again.

StatusYou get
completedthe clip, at /v1/videos/{id}/content?index=0, and the charge in usage.cost
failedno clip; error holds the provider's reason
cancelledno clip: the job was cancelled
expiredno clip: the job lapsed before a clip was made

On failed, read error, change what it names, and send the job again: the failed one charged nothing.

4. Read what it cost

The clip is charged in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges → from your balanceBalanceWhat you can spend, in DA.More on Balance and charges → once, when the job reports completed: its seconds, at the rate of the variant the request picked, its resolution and, on some models, generate_audio. The completed answer's usage.cost carries the charge, the number the code prints.

Sending the job holds its most from that moment, and the charge is taken when the clip is delivered. A job that ends failed, cancelled or expired charges nothing and gives the hold back. The model's rate per second is on its page in Models. How a charge leaves your balance: Balance and charges.

Last modified on