Home › Studies › AI-103 › Computer Vision › Image & Video Generation

Image & Video Generation

gpt-image models · Image API · edits and masks · Sora 2 · video jobs · remix · content controls

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Models and ways to call them

NeedWhat Microsoft Learn showsNotes
Text to imageGPT-image family (for example GPT-Image-1, GPT-Image-1-Mini, GPT-Image-1.5) deployed in a Foundry (Azure OpenAI) resourceTest in the Foundry playground, or call the image generation API or the Responses API
Image to image and editsThe same GPT-image models take text plus image inputsEdits go to the image edit API
Text, image or video to videoSora 2 (text to video, image to video, video to video remix)Uses the Azure OpenAI v1 API; audio can be generated
Third-party image and video modelsFLUX (image) and a model family from Fal (video) are available in FoundryNamed on the training module
RetiredThe dall-e-3 model was retired on March 4, 2026Existing deployments are non-functional; use a gpt-image series model

Generate images from text and reference media

Two paths: the image generation API (client.images.generate, or a POST to /openai/v1/images/generations) and the Responses API with the image_generation tool.

SettingWhat it doesStated values
modelYour deployment nameFor example gpt-image-1.5 in the sample
sizeOutput dimensionsGPT-image-1 series: 1024x1024, 1024x1536, 1536x1024; square is faster. gpt-image-2: arbitrary sizes, both edges a multiple of 16, long edge up to 3840 px, aspect ratio up to 3:1
nImages per call1 to 10, default 1
qualityQuality against speedLower quality images can be generated faster
output_formatFile formatPNG or JPEG, default PNG; WEBP is not supported
output_compressionCompression level0 to 100, default 100
backgroundTransparent backgroundSet to transparent with PNG output
userUnique user identifier for tracking and monitoring usageAny string
stream, partial_imagesGet partial images while generatingUse the image generation API; the Responses API tool does not stream

Edit images: inpainting, masks and prompts

ItemRule
Endpoint.../openai/deployments/<deployment>/images/edits (an input image is required)
Body typemultipart/form-data, not JSON
Input imagesUp to 16; each under 50 MB; PNG or JPG
maskPNG with the same dimensions as the input image; fully transparent pixels (alpha of zero) mark the area to edit
input_fidelityMatches style and features, especially faces, of the input; not supported by gpt-image-1-mini
Without a maskSend the image and a prompt that describes the change (prompt-driven edit)

Mask-based edit = edits endpoint + PNG mask + same size as the image. A JSON body or a different-size mask is the usual wrong answer.

Generate and edit video with Sora 2

Video generation is an asynchronous job: create the job, poll its status, download the video once it is completed. It typically takes 1 to 5 minutes.

  1. Create: client.videos.create(model=..., prompt=...) (REST: POST to /openai/v1/videos). The response has a video id and a queued status.
  2. Poll: client.videos.retrieve(video.id). Expected states: queued, in_progress, completed, failed.
  3. Download: client.videos.download_content(video_id, variant="video"), then write_to_file (REST: GET /videos/{video_id}/content?variant=video).
ControlMeaning
promptShot type, subject, action, setting, lighting, camera motion; keep it single-purpose
size, secondsOutput resolution and length (also settable in the Video playground)
input_referenceOne reference image used as a visual anchor for the first frame; its resolution must match the output size
remix_video_id / client.videos.remixChange a completed video: keeps its framework, scene transitions and layout; limit each remix to one clearly stated adjustment

Safety rules on generation

CLI and PowerShell

TaskAzure CLIPowerShell
Generate an image (Python, OpenAI client)client.images.generate(model="gpt-image-1.5", prompt="A cute baby sea otter", n=1, size="1024x1024", stream=True, partial_images = 2)-
Generate an image with the Responses API tool (Python)response = client.responses.create( model="MODEL_NAME", input="Generate an image of a gray tabby cat hugging an otter with an orange scarf.", tools=[{"type": "image_generation"}], )-
Create a Sora 2 video job (Python)video = client.videos.create( model="sora-2", # Replace with Sora 2 model deployment name prompt="A video of a cool cat on a motorcycle in the night", )-
Poll a video job (Python)client.videos.retrieve(video.id)-
Download the finished video (Python)client.videos.download_content(video_id, variant="video")-
Remix a completed video (Python)video = client.videos.remix( video_id="<previous_video_id>", prompt="Shift the color palette to teal, sand, and rust, with a warm backlight." )-

Exam Tips

Tick each tip once you can answer it without looking.

“App still calls a dall-e-3 deployment and fails” → The model was retired on March 4, 2026: deploy a gpt-image series model and use its deployment name. Trap: Quota or API changes do not revive a retired model.

“Image result: URL or bytes?” → GPT-image-1 series always returns base64 in b64_json; response_format is not supported. Trap: Do not plan on a downloadable link.

“Several candidate images from one request” → Set n (1 to 10, default 1). Trap: partial_images is for streaming; user is an identifier.

“Change part of a picture, keep the rest” → Image edit API (/images/edits) with multipart form data, the image, a prompt and a PNG mask. Trap: The generations endpoint creates a new image from JSON.

“Which pixels does the mask edit?” → Fully transparent pixels (alpha of zero); PNG, same dimensions as the input image. Trap: A JPEG or different-size mask does not meet the rule.

“Edit request limits” → Up to 16 input images, each under 50 MB, PNG or JPG. Trap: WEBP is not an accepted input type on the page.

“Keep faces close to the original in an edit” → input_fidelity; not supported by gpt-image-1-mini. Trap: quality trades quality against speed (low, medium, high); it is a different setting.

“Show partial images while generating” → Image generation API with stream true and partial_images. Trap: The Responses API image tool does not stream.

“Logo with a transparent background” → background = transparent with PNG output. Trap: WEBP is unsupported; JPEG is not the stated pairing.

“429 from the image API” → Rate limit exceeded: back off and retry, or request more quota (default 5 images per minute). Trap: It is not an authentication error; 401 is.

“Video from Sora 2: how does the call work?” → Async job: create, poll until completed, then download the MP4. Trap: Download works only after the status is completed; create returns a video id and a queued status.

“Sora 2 job states” → queued, in_progress, completed, failed. Trap: The older job API shows succeeded; use the v1 Sora 2 states here.

“Animate a still image with Sora 2” → input_reference: one image, first-frame anchor, resolution must match the output size. Trap: A mismatched size is the common wrong setup.

“Tweak a finished video (palette, mood) and keep the layout” → client.videos.remix with the completed video id and a new prompt. Trap: A fresh create regenerates from scratch; keep each remix to one adjustment.

“Prompt names a real public figure or uses a face photo (Sora 2)” → Rejected: real people cannot be generated and face input images are rejected. Trap: Copyrighted characters and music are rejected as well.

“Prompt flagged by the filter on an image call” → Error with error.code = contentFilter; change the prompt. Trap: The output image can be filtered too, with a different message.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Computer Vision overviewMultimodal Understanding →