Generate and edit
Generate images, videos and speech inside a library; every result is stored as an asset of the library. The shape follows the OpenAI Images and Videos APIs: a prompt, n outputs, edits of an existing asset, an asynchronous job you poll. This page covers only where Praxis differs and what is easiest to get wrong.
1. Pick a model and a mode
Read GET /media/v1/generation/capabilities first. Each model lists its modes, prices and limits; a request whose mode the model does not list is refused before any job (INVALID_PARAMS or OPERATION_NOT_SUPPORTED) and costs nothing.
| Goal | Operation and mode | Notes |
|---|---|---|
| Text to image, several candidates | POST …/images/generations, n 1–10 | |
| New picture of a known character (new expression, two characters together) | same, references with role: subject | Only image models whose modes include image take references |
| Change an existing picture | same, references with role: edit_target | as above |
| Text to video, drawing takes | POST …/videos/generations, mode: text, n 1–4 | 480p is the cheapest way to compare |
| First frame / first and last frame | mode: image / first_last | first_frame and last_frame are image assets of the library |
| New video from reference pictures or videos | mode: reference | pictures take role subject or style; a video asset with role video gives the camera and motion |
| Keep a video and replace its person or add/remove objects | mode: edit, source is the video | source at least 4 s; the output has its length and shape; send no duration_seconds |
In the prompt, call the inputs @video1, @image1, @image2… in request order, for example “replace the person in @video1 with @image1”.
2. Read results, failures and charges
A submission answers 202 with a queued Job. Read GET /media/v1/libraries/{library_id}/jobs/{job_id} every few seconds until it ends: completed (all succeeded), completed_with_errors (some did), failed (none did) or canceled.
- Results: a succeeded outputs[i] is already a library asset with asset_id and viewer_url (give viewer_url to the person).
- Failures: a failed outputs[i] has its reason in the failures entry with the same index: code is the error to branch on, detail_code the model’s finer reason, message the model’s own words for a person to read (do not branch on it), model_request_id the model call to trace. Branch on code: CONTENT_REJECTED means the model’s moderation refused an input or the result (a real human face in a reference is one cause): change the prompt or the reference, since retrying unchanged fails again. INVALID_PARAMS means the model did not accept the parameters or an input (a reference too large or in an unsupported format): change the request, since retrying unchanged fails again. UPSTREAM_FAILED means the model service timed out or was unavailable and RATE_LIMITED that it throttled: retry the same request later. GENERATION_FAILED is any other failure (for example fewer results than asked, with detail_code SHORT_DELIVERY), and a retry may succeed. None of these failures is charged.
- Charges: usage is what the job has cost so far, in US dollars with six decimals, final when the job ends. Failed and refused outputs are not charged, so usage counts succeeded outputs only, and it is absent when nothing was charged. Images are priced per image and videos per output second, at the model API prices; a job with an input video is metered by the model on input plus output seconds, so it costs more than output seconds × price: a 5 s edit of a 5 s source bills about 6 s.
- Seed: when the model reports one, outputs[i].seed carries it; send it back with an adjusted prompt. Doubao Seedance 2.x neither takes nor reports a seed.
3. Drawing takes of one shot
- Ask for several outputs with n (up to 4 videos, 10 images) instead of many single requests: one job, one usage, per-output results and failures.
- Results land in the library and never expire; delete the ones you do not keep. One asset_folder per shot makes the clean-up a single folder.
- Cancel when the direction is wrong:
POST …/jobs/{job_id}/cancel. Queued outputs are not charged; produced outputs stay and stay charged; a video that has started cannot be stopped (409 JOB_INVALID_STATE) and finishes and is charged. - Concurrency: a library runs at most 5 jobs of each kind (image, video, speech) at once; more wait (status queued, queue_reason concurrency, queue_position their place), and past 50 waiting the request answers 429 with Retry-After.
4. AI-generated label
Images and videos generated on the platform carry the implicit label of GB 45438—2025 Appendix E as metadata, which is the machine-readable “AI generated” marking platforms ask for: a PNG carries it in an AIGC text chunk, a JPEG or WebP in XMP, and an MP4 in its own uuid box; the pixels are untouched. When the library reads the label, the asset’s ai_generated is true.
Keep in mind:
- The platform draws no visible label. Some models add their own: Doubao Seedream images carry an “AI生成” watermark in the bottom-right corner. When a publishing platform asks for a visible mark and the model added none, add a text layer in the edit, for example with the label-strip template.
- A video re-encoded by an edit does not keep this metadata: Cut does not write it on export.
5. Not available yet
- A candidate area: results always land in the library.
- A cost estimate before submitting and a budget cap for a batch: estimate from the prices in capabilities.
- Re-using a seed on Doubao Seedance.
- Editing part of a source video (source_in / source_out): cut the shot into its own asset first.
Next steps
- Limits and errors: upload, search and understanding limits, and error codes.
- Media API reference: request and response fields of every operation.
- Cut quickstart: cut generated or uploaded assets into a video.