Skip to content

Commit 7187ac5

Browse files
authored
Merge pull request #6793 from PatrickFarley/imagen
Sora updates
2 parents 527037e + a8f50cb commit 7187ac5

File tree

6 files changed

+102
-46
lines changed

6 files changed

+102
-46
lines changed

articles/ai-foundry/openai/concepts/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Sora is an AI model from OpenAI that can create realistic and imaginative video
283283

284284
| Model | Region |
285285
|---|---|
286-
|`sora` | East US 2|
286+
|`sora` | East US 2 (Global Standard)<br>Sweden Central(Global Standard)|
287287

288288
## Audio models
289289

articles/ai-foundry/openai/concepts/video-generation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ Sora is an AI model from OpenAI that can create realistic and imaginative video
1515

1616
## Supported features
1717

18-
Sora can generate complex scenes with multiple characters, diverse motions, and detailed backgrounds. The model interprets prompts with contextual and physical world understanding, enabling accurate scene composition and character persistence across multiple shots. Sora demonstrates strong language comprehension for prompt interpretation and emotional character generation.
18+
Sora can generate complex scenes with multiple characters, diverse motions, and detailed backgrounds.
19+
20+
**Text to video**: The model interprets prompts with contextual and physical world understanding, enabling accurate scene composition and character persistence across multiple shots. Sora demonstrates strong language comprehension for prompt interpretation and emotional character generation.
21+
22+
**Image to video**: Sora can generate video content from a still image. You can specify where in the generated video the image appears (it doesn't need to be the first frame) and which region of the image to use.
23+
24+
1925

2026
## How it works
2127

articles/ai-foundry/openai/includes/azure-openai-models-list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ Azure OpenAI is powered by a diverse set of models with different capabilities a
2323
| [GPT-3.5](../concepts/models.md#gpt-35) | A set of models that improve on GPT-3 and can understand and generate natural language and code. |
2424
| [Embeddings](../concepts/models.md#embeddings) | A set of models that can convert text into numerical vector form to facilitate text similarity. |
2525
| [Image generation](../concepts/models.md#image-generation-models) | A series of models that can generate original images from natural language. |
26+
| [`Video generation`](../concepts/models.md#video-generation-models) | A model that can generate original video scenes from text instructions. |
2627
| [Audio](../concepts/models.md#audio-models) | A series of models for speech to text, translation, and text to speech. GPT-4o audio models support either low latency *speech in, speech out* conversational interactions or audio generation. |

articles/ai-foundry/openai/includes/video-generation-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ ms.topic: include
77
ms.date: 5/29/2025
88
---
99

10-
In this quickstart, you generate video clips using the Azure OpenAI service. The example uses the Sora model, which is a video generation model that creates realistic and imaginative video scenes from text instructions. This guide shows you how to create a video generation job, poll for its status, and retrieve the generated video.
10+
In this quickstart, you generate video clips using the Azure OpenAI service. The example uses the Sora model, which is a video generation model that creates realistic and imaginative video scenes from text instructions and/or image inputs. This guide shows you how to create a video generation job, poll for its status, and retrieve the generated video.
1111

1212
For more information on video generation, see [Video generation concepts](../concepts/video-generation.md).

articles/ai-foundry/openai/includes/video-generation-rest.md

Lines changed: 84 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ For the recommended keyless authentication with Microsoft Entra ID, you need to:
7171
7272
[!INCLUDE [resource authentication](resource-authentication.md)]
7373
74-
7574
## Generate video with Sora
75+
7676
You can generate a video with the Sora model by creating a video generation job, polling for its status, and retrieving the generated video. The following code shows how to do this via the REST API using Python.
7777
78-
## [Microsoft Entra ID](#tab/keyless)
78+
1. Create the `sora-quickstart.py` file and add the following code to authenticate your resource:
7979
80-
1. Create the `sora-quickstart.py` file with the following code:
80+
## [Microsoft Entra ID](#tab/keyless)
8181
8282
```python
8383
import requests
@@ -91,10 +91,33 @@ You can generate a video with the Sora model by creating a video generation job,
9191
# Keyless authentication
9292
credential = DefaultAzureCredential()
9393
token = credential.get_token("https://cognitiveservices.azure.com/.default")
94-
94+
9595
api_version = 'preview'
9696
headers= { "Authorization": f"Bearer {token.token}", "Content-Type": "application/json" }
97-
97+
```
98+
99+
## [API key](#tab/api-key)
100+
101+
```python
102+
import requests
103+
import base64
104+
import os
105+
from azure.identity import DefaultAzureCredential
106+
107+
# Set environment variables or edit the corresponding values here.
108+
endpoint = os.environ['AZURE_OPENAI_ENDPOINT']
109+
api_key = os.environ['AZURE_OPENAI_API_KEY']
110+
111+
api_version = 'preview'
112+
headers= { "api-key": api_key, "Content-Type": "application/json" }
113+
```
114+
---
115+
116+
1. Create the video generation job. You can create it from a text prompt only, or from an input image and text prompt.
117+
118+
## [Text prompt](#tab/text-prompt)
119+
120+
```python
98121
# 1. Create a video generation job
99122
create_url = f"{endpoint}/openai/v1/video/generations/jobs?api-version={api_version}"
100123
body = {
@@ -138,86 +161,104 @@ You can generate a video with the Sora model by creating a video generation job,
138161
raise Exception(f"Job didn't succeed. Status: {status}")
139162
```
140163
141-
1. Run the Python file.
164+
## [Image prompt](#tab/image-prompt)
142165
143-
```shell
144-
python sora-quickstart.py
145-
```
166+
Replace the `"file_name"` field in `"inpaint_items"` with the name of your input image file. Also replace the construction of the `files` array, which associates the path to the actual file with the filename that the API uses.
146167
147-
## [API key](#tab/api-key)
168+
Use the `"crop_bounds"` data (image crop distances, from each direction, as a fraction of the total image dimensions) to specify which part of the image should be used in video generation.
169+
170+
You can optionally set the `"frame_index"` to the frame in the generated video where your image should appear (the default is 0, the start of the video).
148171
149-
1. Create the `sora-quickstart.py` file with the following code:
150172
151173
```python
152-
import requests
153-
import base64
154-
import os
174+
# 1. Create a video generation job with image inpainting (multipart upload)
175+
create_url = f"{endpoint}/openai/v1/video/generations/jobs?api-version=preview"
155176
156-
# Set environment variables or edit the corresponding values here.
157-
endpoint = os.environ['AZURE_OPENAI_ENDPOINT']
158-
api_key = os.environ['AZURE_OPENAI_API_KEY']
159-
160-
api_version = 'preview'
161-
headers= { "api-key": api_key, "Content-Type": "application/json" }
162-
163-
# 1. Create a video generation job
164-
create_url = f"{endpoint}/openai/v1/video/generations/jobs?api-version={api_version}"
165-
body = {
166-
"prompt": "A cat playing piano in a jazz bar.",
167-
"width": 480,
168-
"height": 480,
169-
"n_seconds": 5,
170-
"model": "sora"
177+
# Flatten the body for multipart/form-data
178+
data = {
179+
"prompt": "A serene forest scene transitioning into autumn",
180+
"height": str(1080),
181+
"width": str(1920),
182+
"n_seconds": str(10),
183+
"n_variants": str(1),
184+
"model": "sora",
185+
# inpaint_items must be JSON string
186+
"inpaint_items": json.dumps([
187+
{
188+
"frame_index": 0,
189+
"type": "image",
190+
"file_name": "dog_swimming.jpg",
191+
"crop_bounds": {
192+
"left_fraction": 0.1,
193+
"top_fraction": 0.1,
194+
"right_fraction": 0.9,
195+
"bottom_fraction": 0.9
196+
}
197+
}
198+
])
171199
}
172-
response = requests.post(create_url, headers=headers, json=body)
173-
response.raise_for_status()
200+
201+
# Replace with your own image file path
202+
with open("dog_swimming.jpg", "rb") as image_file:
203+
files = [
204+
("files", ("dog_swimming.jpg", image_file, "image/jpeg"))
205+
]
206+
multipart_headers = {k: v for k, v in headers.items() if k.lower() != "content-type"}
207+
response = requests.post(
208+
create_url,
209+
headers=multipart_headers,
210+
data=data,
211+
files=files
212+
)
213+
214+
if not response.ok:
215+
print("Error response:", response.status_code, response.text)
216+
response.raise_for_status()
174217
print("Full response JSON:", response.json())
175218
job_id = response.json()["id"]
176219
print(f"Job created: {job_id}")
177220
178221
# 2. Poll for job status
179-
status_url = f"{endpoint}/openai/v1/video/generations/jobs/{job_id}?api-version={api_version}"
180-
status=None
222+
status_url = f"{endpoint}/openai/v1/video/generations/jobs/{job_id}?api-version=preview"
223+
status = None
181224
while status not in ("succeeded", "failed", "cancelled"):
182-
time.sleep(5) # Wait before polling again
225+
time.sleep(5)
183226
status_response = requests.get(status_url, headers=headers).json()
184227
status = status_response.get("status")
185228
print(f"Job status: {status}")
186-
187-
# 3. Retrieve generated video
229+
230+
# 3. Retrieve generated video
188231
if status == "succeeded":
189232
generations = status_response.get("generations", [])
190233
if generations:
191-
print(f"✅ Video generation succeeded.")
192234
generation_id = generations[0].get("id")
193-
video_url = f"{endpoint}/openai/v1/video/generations/{generation_id}/content/video?api-version={api_version}"
235+
video_url = f"{endpoint}/openai/v1/video/generations/{generation_id}/content/video?api-version=preview"
194236
video_response = requests.get(video_url, headers=headers)
195237
if video_response.ok:
196238
output_filename = "output.mp4"
197239
with open(output_filename, "wb") as file:
198240
file.write(video_response.content)
199-
print(f'Generated video saved as "{output_filename}"')
241+
print(f'Generated video saved as "{output_filename}"')
200242
else:
201243
raise Exception("No generations found in job result.")
202244
else:
203245
raise Exception(f"Job didn't succeed. Status: {status}")
204246
```
247+
---
248+
205249
206250
1. Run the Python file.
207251
208252
```shell
209253
python sora-quickstart.py
210254
```
211255
212-
---
213-
214-
Wait a few moments to get the response.
256+
Wait a few moments to get the response.
215257
216258
### Output
217259
218260
The output will show the full response JSON from the video generation job creation request, including the job ID and status.
219261
220-
```json
221262
```json
222263
{
223264
"object": "video.generation.job",

articles/ai-foundry/openai/whats-new.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ This article provides a summary of the latest releases and major documentation u
2020

2121
## August 2025
2222

23+
### Sora image-to-video support
24+
25+
The Sora model from OpenAI now supports image-to-video generation. You can provide an image as input to the model to generate a video that incorporates the content of the image. You can also specify the frame of the video in which the image should appear: it doesn't need to be the beginning.
26+
27+
28+
Sora is now available in the Sweden Central region as well as East US 2.
29+
30+
2331
### Realtime API audio model GA
2432

2533
OpenAI's GPT RealTime and Audio models are now generally available on Azure AI Foundry Direct Models.

0 commit comments

Comments
 (0)