Generate short videos from text prompts using the OpenDunes API from Go.
The video generation endpoint produces short clips from a text prompt. Generation is asynchronous — you submit a job and poll for the result. The OpenAI Go client has no video resource, so call the endpoint directly with net/http.
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "example-provider/video-model",
"prompt": "A lone camel walking across a vast sand dune at golden hour, cinematic wide shot.",
"duration": 6,
})
req, _ := http.NewRequest("POST", "https://opendunes.com/v1/videos", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENDUNES_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// Responds 202 with an id + polling_url
var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["id"]) // poll this
}req, _ := http.NewRequest("GET",
"https://opendunes.com/v1/videos/"+jobID,
nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENDUNES_API_KEY"))The response includes status (pending, in_progress, completed, failed) and, when completed, the clip's download link in unsigned_urls and its id in Files in file_ids. Download it with the same Authorization header; the link does not expire and the clip is kept until you delete it.
| Field | Description |
|---|---|
model | Video model slug, from GET /v1/videos/models |
prompt | Text description of the desired video |
duration | Seconds of video. The lengths a model takes are its supported_durations |
Billed per second of output in DA. Nothing is charged at submission: the wallet moves once, when the job completes. A failed or timed-out job charges nothing. See the video API reference.