Video generation
/v1/videos creates videos from a prompt and, for some models, from reference images or characters. Video generation is asynchronous, the create call returns a video object with a status, and you poll it until it is complete, then download the content. The gateway serves this format for OpenAI, RunwayML, Eden AI and self-hosted servers, and prices videos per second from the price map, so video spend is budgeted and reported like every other call.
Scenario
A social media team generates short clips from text briefs. Their tool creates a video, polls the gateway until it is complete and downloads the file. The team's key has a monthly budget, so the tool cannot run up an unexpected bill, and the Usage page shows how many seconds of video each campaign produced.
Steps
-
Register a video model. In the Admin UI open Models + Endpoints (
/ui/models-and-endpoints), click Add Model, pick the Provider, choose the model, set the Public Model Name tosora-2and set Mode to Video Generation - /videos, then click Add Model.model_list:- model_name: sora-2spanway_params:model: openai/sora-2api_key: os.environ/OPENAI_API_KEYmodel_info:mode: video_generation -
Create a key in Virtual Keys (
/ui/api-keys), pick the model under Models and set Max Budget (USD) under Optional Settings. -
Create a video.
curl -X POST http://localhost:4000/v1/videos \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "sora-2", "prompt": "A paper boat drifting down a rainy street at dusk", "seconds": "8", "size": "1280x720"}' -
Poll and download. Take
idfrom the answer.curl http://localhost:4000/v1/videos/video_7c2d4e1f -H "Authorization: Bearer $SPANWAY_API_KEY"curl http://localhost:4000/v1/videos/video_7c2d4e1f/content -H "Authorization: Bearer $SPANWAY_API_KEY" --output clip.mp4 -
Check the cost in Logs (
/ui/logs). The create request carries the cost of the requested seconds.
Expected result
{"id": "video_7c2d4e1f", "object": "video", "model": "sora-2", "status": "queued", "progress": 0, "seconds": "8", "size": "1280x720", "created_at": 1760441234}
Status moves from queued to in_progress to completed or failed. The content call returns the video bytes once the status is completed.
Endpoints
| Method | Path | Summary |
|---|---|---|
| GET | /v1/videos | List generated videos |
| POST | /v1/videos | Create a video from a prompt |
| GET | /v1/videos/{video_id} | Check the status of a video |
| GET | /v1/videos/{video_id}/content | Download a finished video |
| POST | /v1/videos/{video_id}/remix | Remix an existing video with a new prompt |
| POST | /v1/videos/characters | Create a reusable video character |
| GET | /v1/videos/characters/{character_id} | Read a video character |
| POST | /v1/videos/edits | Edit a video with a prompt |
| POST | /v1/videos/extensions | Extend a video |
Video ids returned by the gateway encode the deployment that created them, so polling and download are routed to the same provider account. POST /v1/videos/{video_id}/remix creates a new video from an existing one with a new prompt, and /v1/videos/edits, /v1/videos/extensions and /v1/videos/characters are available for providers that support editing, extending and character references.
Cost and access
Cost is recorded when the video is created, from the model's per-second price and the requested duration. Prompts are screened by pre_call guardrails, and video endpoints are subject to the key's model access and budget like every other call. Videos are not private to the key or team that created them. GET /v1/videos lists every video the provider account behind the deployment holds, including videos other teams created, and any key that may use the model can read the status and download the content of a video by its id. Give teams that must not see each other's videos separate deployments with separate provider accounts. See the RunwayML video page for that provider's models.
Errors
| Status | What it means | Fix |
|---|---|---|
400 BadRequestError | prompt is missing, or seconds or size is not offered by the model. | Use a duration and size the model supports. |
400 ContentPolicyViolationError | The provider refused the prompt. | Change the prompt. |
401 AuthenticationError | The key is missing, wrong or expired. | Use a live key. |
403 PermissionDeniedError | The key may not use the model. | Add the model to the key. |
404 NotFoundError on poll or download | The video id is unknown or belongs to another provider account. | Use the id the gateway returned. |
409 or status failed | The provider could not render the video. error on the video object says why. | Read error, change the prompt or the parameters and create again. |
429 RateLimitError | Budget or rate limit reached. | Raise the limit. |
Related
- Image generation for still images.
- RunwayML videos.
- Custom pricing for per-second prices.
Providers
The gateway's endpoint support matrix marks 3 provider integrations as supporting this endpoint: