Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions sdk/openai/azure-openai/samples/images_aoai_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@ def images_aoai_quickstart() -> None:
image_path = os.path.join(image_dir, 'generated_image.png')

# Retrieve the generated image
image_url = result.data[0].url # extract image URL from response
if image_url:
generated_image = httpx.get(image_url).content # download the image

with open(image_path, "wb") as image_file:
image_file.write(generated_image)

# Display the image in the default image viewer
image = Image.open(image_path)
image.show()
if result.data and len(result.data) > 0:
image_url = result.data[0].url # extract image URL from response
if image_url:
generated_image = httpx.get(image_url).content # download the image

with open(image_path, "wb") as image_file:
image_file.write(generated_image)

# Display the image in the default image viewer
image = Image.open(image_path)
image.show()
else:
print("No image data received from the API.")

if __name__ == "__main__":
images_aoai_quickstart()