← Develop AI Apps and Agents o… Latent Shelf · Ch.25

Module Study Guide · Path 4 · Visual data

Generate Videos with Microsoft Foundry

Video generation doesn't answer in a single call. You submit a job, poll while Sora paints the frames, and download the clip when it's ready.

— the module's rhythm

Text-to-video with Sora 2. This module covers deploying the model and its capabilities, generating from a prompt with strong prompt-writing, and the asynchronous job pattern in Python — plus reference images and remixing.

Sora 2async job patternremix & reference15 quiz questions
01Deploy Sora 2

The model and what it does

Sora 2 is an OpenAI model that creates realistic and imaginative video from text, images, or existing videos. You deploy it from the Foundry portal's Models list (Build → Models → search "Sora-2" → Deploy).

Sora 2 capabilities.
FeatureDescription
Text to videoGenerate video from a natural-language prompt.
Image to videoTurn an existing image into video content.
Video remixMake targeted adjustments to an existing video without full regeneration.
Audio generationSupports audio in the output video.
ResolutionsPortrait 720×1280 and landscape 1280×720.
Duration4, 8, or 12 seconds.
02Prompting

Generation and good prompts

Generation is asynchronous: you submit a request and retrieve the finished video later. In the Video playground you set prompt, resolution, and duration, then Generate (typically 1–5 minutes); "View code" gives cURL samples. Content-moderation filters block harmful prompts.

Key concept · Anatomy of a strong prompt

Effective prompts specify camera framing (shot type/angle), subject details, action in beats (steps, gestures, pauses), lighting and palette, and style. "Wet asphalt, neon signs reflecting in puddles" beats "a beautiful street at night"; "cyclist pedals three times, brakes, and stops" beats "person moves quickly." Key tip: shorter clips perform better — for longer content, generate two 4-second clips and stitch them rather than one 8-second clip. Keep it to one camera move and one subject action per shot, use beats for timing, and iterate — small changes shift the outcome a lot.

03Python & variants

The job loop, references, and remix

In Python (OpenAI SDK against the Sora deployment) the pattern is three steps: create the job, poll for completion, then download the result.

Key concept · Create → poll → download

client.videos.create(model="sora-2", prompt=…, size="1280x720", seconds="4") returns a job; loop while video.status is not in ["completed","failed","cancelled"], sleeping between client.videos.retrieve(id) calls; on completion, client.videos.download_content(id, variant="video") and write the .mp4. Status values: queued, in_progress, completed, failed, cancelled.

Key concept · Reference images and remix

Reference image — pass input_reference to anchor the first frame; its resolution must match the target size exactly (JPEG/PNG/WebP), and human faces are rejected (use landscapes, objects, or animated characters). Remix — client.videos.remix(video_id=…, prompt=…) modifies an existing video while preserving structure; limit it to one clear change for best fidelity. Constraints: max two simultaneous jobs, and completed videos are available for 24 hours.

★Test yourself

Chapter 25 quiz

Fifteen questions on Sora 2, prompting, and the async job pattern. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

Which model does this module use for video generation?

  • A Sora 2
  • B FLUX.1
  • C gpt-image-1
  • D Phi-4
Show answer

A — Sora 2. An OpenAI video model in Foundry.

Q2

Video generation is best described as:

  • A Asynchronous — submit a job, retrieve when ready
  • B Instant, single-call
  • C Streaming only
  • D Impossible in code
Show answer

A. Create → poll → download.

Q3

What durations does Sora 2 support?

  • A 4, 8, or 12 seconds
  • B 1–60 minutes
  • C Exactly 30 seconds
  • D Unlimited
Show answer

A. Default 4; shorter clips perform better.

Q4

Which is a strong video prompt?

  • A "Wet asphalt, neon signs reflecting in puddles"
  • B "A beautiful street at night"
  • C "Cinematic look"
  • D "Person moves quickly"
Show answer

A. Specific framing, subject, and detail.

Q5

What must be true of a reference image?

  • A Its resolution must match the target video size exactly
  • B It must contain a human face
  • C It must be a GIF
  • D It must be 4K
Show answer

A. And human faces are rejected — use landscapes/objects/animated characters.

Q6

Which method modifies an existing video while preserving its structure?

  • A client.videos.remix
  • B client.videos.create
  • C client.images.generate
  • D client.videos.delete
Show answer

A — remix. With a video_id and a new prompt.

Q7

What are the two landscape/portrait resolutions?

  • A 1280×720 and 720×1280
  • B 1024×1024 and 512×512
  • C 1920×1080 and 3840×2160
  • D 640×480 only
Show answer

A. Landscape 1280×720, portrait 720×1280.

Part B · True or false

Q8

For a longer clip, it's often better to make two 4-second clips and stitch them.

Show answer

True. Shorter clips perform better.

Q9

Completed videos remain available indefinitely.

Show answer

False. They're available for 24 hours.

Q10

You can run at most two simultaneous video-creation jobs.

Show answer

True. A rate limit on concurrent jobs.

Q11

Sora 2 can generate audio in its output videos.

Show answer

True. Audio generation is a listed capability.

Q12

Prompts are subject to content-moderation filtering.

Show answer

True. Harmful-content prompts are blocked.

Part C · Short answer

Q13

Name the three steps of the Python video-generation pattern.

Show answer

Create the job, poll for completion, and download the result.

Q14

List the possible job status values.

Show answer

queued, in_progress, completed, failed, cancelled.

Q15

Name three elements of a strong video prompt.

Show answer

Any three: camera framing, subject, action (in beats), lighting/palette, and style.