Skip to main content

Scenario

Use Mavera to generate a video script, feed it to OpenAI’s Sora to generate video, then loop results through Mavera’s Mave Agent for quality assessment — brand alignment, narrative coherence, visual impact — and iterate until quality thresholds are met. Flow: Mavera POST /generations (script) → OpenAI Sora POST /images/generations → Mavera POST /mave/chat (analyze) → Iterate
Sora’s API is actively evolving. The example below uses the images.generate endpoint with model="sora", which reflects the current API surface. Check OpenAI’s Sora documentation for the latest endpoint details.

Code

Example Output

Error Handling

Sora access may require a specific tier. If you get a 404 or model-not-found error, verify access at platform.openai.com/settings. Fall back to DALL-E 3 for static frames if unavailable.
Video generation can take 30-120 seconds. Set HTTP client timeout to at least 180 seconds. The OpenAI SDK handles this automatically, but raw requests calls need timeout=180.
The loop caps at 3 iterations to prevent runaway costs. Each iteration consumes Sora credits plus Mavera credits. If scores plateau, review the base script rather than continuing to refine.