Generate Images with Generative Models
30-second answer
You create new visual output by deploying an image-generation model such as gpt-image-1 in Microsoft Foundry and sending it a text prompt, either in the images playground or from code with images.generate. You choose the size and quality, the model returns the picture as base64 data, and guardrails check the prompt and the image while content credentials mark the result as AI-generated.
Exam objective: 2.3.2 Create new visual outputs by using generative models. (Skills measured as of April 15, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Deploy an <strong>image-generation</strong> model: <strong>gpt-image-1</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Deploy an image-generation model: gpt-image-1.
- Describe the subject, style, colours, mood and layout. Specific prompts give better images.
- The result appears in the playground. You can edit it with a follow-up prompt.
- In code: images.generate returns the image as base64.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Image generation
Image-generation models work the other way round: a text prompt goes in and a brand-new image comes out. Guardrails block harmful requests, and generated images are marked with content credentials.
🤔 What happens if…
Read this tour as text
- Five workload lanes. Most AI apps fall into a few workloads: generative and agentic AI, text analysis, speech, computer vision and information extraction. Each lane here takes a different kind of input and turns it into something useful.
- Text analysis. A hotel review goes in. Azure Language returns the sentiment (positive, neutral, negative), key phrases, named entities (people, places, dates), PII and a short summary.
- Speech to text. Speech recognition turns spoken audio into text: live captions, call transcripts, voice commands. It can also translate speech into another language as you talk.
- Text to speech. Speech synthesis turns text into natural speech with a neural voice. SSML lets you control speed, pitch and pauses. Think audiobooks, voice assistants and accessibility readers.
- Computer vision. A photo goes in. Vision models return a caption, tags, objects with boxes, and any printed or handwritten text (OCR). A multimodal chat model can also answer questions about the picture.
- Image generation. Image-generation models work the other way round: a text prompt goes in and a brand-new image comes out. Guardrails block harmful requests, and generated images are marked with content credentials.
- Extract from documents. Azure Content Understanding reads an invoice and returns fields you defined (vendor, date, total) with a confidence score for each, so low-confidence values can go to a person.
- Extract from audio and video. The same service handles media: an audio call becomes a transcript with speakers and a summary; a video is split into segments with key frames, descriptions and chapters.
Ask a multimodal model about a photo, generate a brand-new image from a prompt, then do both from a Python app.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Marketing needs 50 festival banners by Friday.
😊 THE SOLUTION
Generate drafts from text prompts, then polish the best.
- Designers overloaded✓ Generate first drafts
- Is it AI-made?✓ Content credentials
- Risky requests✓ Guardrails screen prompts
Start with a question
Can I get a festival poster made in a minute without hiring a designer?
Priya runs a small sweet shop in Madurai. Diwali is two weeks away and she wants a poster with a plate of laddoos, diyas and the words “Diwali Specials”. A designer would take a few days.
She types one sentence describing the poster, and a few seconds later there’s a brand-new picture that never existed before. That’s an image-generation model at work, and in Microsoft Foundry the one you’ll use is gpt-image-1.
Explain it like I’m 10
The technical explanation
An image-generation model turns a text prompt into a new image. In Foundry the main choice is gpt-image-1 from OpenAI (DALL-E 3 is the older model you may still see). It’s a different job from vision: a multimodal model reads an image you give it, while an image model creates one.
Step 1: try it in the images playground
- In your Foundry project, open the model catalog, find gpt-image-1 and deploy it. Some image models need an access request before the deploy button works.
- Open the Images playground, pick your deployment and type a prompt.
- Set the size and quality, then generate. Change one thing at a time and compare.
- Use View code to see the same request as Python.
| Setting | What it does | Values you’ll see |
|---|---|---|
| Size | Shape and resolution of the picture | 1024x1024 (square), 1536x1024 (landscape), 1024x1536 (portrait), auto |
| Quality | Detail level, which affects time and cost | low, medium, high (or auto) |
| Number of images | How many variations per request | n in code |
Step 2: generate from code
You use the same Foundry SDK as for chat. The model value is your deployment name.
# pip install "azure-ai-projects>=2.3.0" azure-identity
import base64, os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
project = AIProjectClient(
endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
credential=DefaultAzureCredential(), # uses your az login
)
openai = project.get_openai_client()
result = openai.images.generate(
model="gpt-image-1", # your deployment name
prompt="A festive poster: a brass plate of laddoos surrounded by glowing diyas, "
"warm golden light, the words 'Diwali Specials' in bold at the top",
size="1024x1536", # portrait poster
quality="medium",
)
# gpt-image-1 returns base64 data, so decode it and save a PNG
with open("poster.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))
Writing prompts that work
- Subject first, then setting, style, lighting and camera angle: “close-up product photo, white background, soft studio light”.
- Spell out any text you want on the image and keep it short. Long sentences in images still go wrong sometimes.
- Say the layout: “logo in the top-left corner, empty space on the right for a price”.
- Iterate. Keep the prompt that worked and change one detail per try.
Editing an existing image
gpt-image-1 can also edit. You send an image plus an instruction such as “replace the background with a beach at sunset”, and you can add a mask so only part of the picture changes (often called inpainting). In code that’s images.edit instead of images.generate; in the playground you upload an image and describe the change.
-
1 Prompt
Your text, size and quality go to the deployment.
-
2 Prompt check
Guardrails check the prompt for harmful content.
-
3 Generate
gpt-image-1 creates the image.
-
4 Output check
Guardrails check the image itself.
-
5 Credentials
C2PA content credentials are attached, then the image is returned.
Guardrails and content credentials
Foundry guardrails (content filters) check image prompts and the generated images for hate, sexual, violence and self-harm content. If something’s blocked, the request fails with a content-filter error instead of returning an image, and your app should show a friendly message. Every generated image also carries content credentials: signed C2PA metadata saying it was made with AI, so a newspaper or a customer can check where it came from.
Architect level Cost and speed trade-offs
Image generation is billed per image, and the price depends on size and quality, so high quality at a large size costs the most. A sensible pattern is to draft at low or medium quality, pick the best prompt, then generate the final at high. Generation takes a few seconds to tens of seconds, so web apps usually show a spinner or run the request in the background rather than blocking the page.
Real-world business scenario
Fabrikam Travels, a Bengaluru travel agency
- The problem
- The team needed fresh banner images for 40 holiday packages every season, and stock photos looked the same as every competitor's.
- What they used
- Deployed gpt-image-1 in a Foundry project and built a small script that fills a prompt template with each destination, season and layout, generating drafts at medium quality and finals at high quality.
- Why that choice
- A prompt template keeps the brand style consistent, guardrails block unsafe requests, and content credentials keep the agency honest about AI-made images.
- The result
- Banner drafts that used to take a designer a week now take an afternoon, and the designer spends that time picking and polishing the best ones.
When to use it and when not to
✓ Use it when…
- Marketing drafts, posters, social images and concept art where a new picture is needed.
- Product mock-ups and storyboards to show an idea before paying for a photo shoot.
- Quick edits to an existing image, like swapping a background, using image editing.
✕ Think twice when…
- Understanding or describing an existing photo. Use a multimodal model or Azure Vision instead.
- Images that must be factually exact, like a real person, a real product label or a technical diagram.
- Anything published without human review.
↔ Alternatives to consider
- **A multimodal model** (GPT-4.1, GPT-4o) to read and describe images.
- **Azure Vision in Foundry Tools** for captions, tags and text (OCR) from images.
Test yourself with exercises
5 original practice questions in the AI-901 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner How do you generate an image with Microsoft Foundry?
Model answer
I deploy an image model like gpt-image-1 in my Foundry project, open the images playground and type a prompt describing the picture. From code I call images.generate on the OpenAI client I get from the project, passing the deployment name, the prompt and a size.
Interviewer follows up
What comes back from the API?
You
A list of images, each as base64 data in b64_json. I decode it and save it as a PNG file.
Intermediate What makes a good image prompt?
Model answer
Be specific about the subject, setting, style, lighting and layout, and say what text should appear if any. "A watercolour poster of a Chennai beach at sunrise, wide shot, soft orange light, the words Marina Run 2026 at the top" works far better than "beach poster". If the first result is close, I tweak one detail at a time.
Experienced developer How do responsible AI controls apply to image generation?
Model answer
Foundry guardrails check the prompt before generation and the image after it, for categories like hate, sexual, violence and self-harm, and the request fails with a content-filter error if something is blocked. Generated images also carry content credentials, so people downstream can see the image was AI-generated. I'd still add human review before anything goes into a public campaign.
Scenario A marketing team wants 20 banner variations for a festival sale but keeps getting images with the wrong layout. What do you suggest?
Model answer
I'd fix the size to the banner shape, like 1536x1024 for landscape, and write a prompt template that spells out layout, colours and text placement, changing only the product and offer per variation. For small fixes on an image they like, I'd use image editing instead of regenerating from scratch.
Quick revision
Key points
- Image-generation models create new images from text prompts; gpt-image-1 is the current OpenAI model in Foundry.
- Test in the images playground first, then call images.generate from code with the deployment name.
- Size and quality are the main settings; higher quality takes longer and costs more.
- gpt-image-1 can also edit an existing image from an instruction, optionally with a mask.
- Guardrails filter harmful prompts and outputs, and content credentials label images as AI-generated.
Important terminology
- Image-generation model
- A generative model that creates a new image from a text prompt, such as gpt-image-1.
- gpt-image-1
- An OpenAI image model in Foundry that generates new images and edits existing ones from text instructions.
- Images playground
- The Foundry portal page where you type a prompt, pick size and quality, and see generated images without writing code.
- Image editing (inpainting)
- Changing part of an existing image from a text instruction, optionally limited to a masked area.
- Content credentials
- Signed C2PA provenance metadata added to generated images so anyone can check they were made with AI.
Common mistakes
- Sending an image-generation request to a chat model deployment. You need an image model deployment.
- Thinking a vision model creates images. Vision models read images; image-generation models make them.
Exam tips
- "Create a new image from a description" = an image-generation model such as gpt-image-1.
- "Prove an image was AI-generated" = content credentials (C2PA provenance).
Five quick revision questions
-
1.Which model creates images from text in Foundry?Show
gpt-image-1 (DALL-E 3 is the older option).
-
2.Which method generates an image in Python?Show
images.generate on the OpenAI client from the project.
-
3.How is the generated image returned?Show
As base64 data in data[0].b64_json.
-
4.What checks harmful image prompts?Show
Foundry guardrails (content filters).
-
5.What marks an image as AI-generated?Show
Content credentials (C2PA provenance metadata).
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Build an App with Vision Capabilities
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.