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

Module Study Guide · Path 4 · Visual data

Generate Images with AI

It isn't search. The model doesn't find a picture of "a robot eating spaghetti" — it paints one that never existed.

— the module's distinction

Text-to-image. This module covers what image-generation models are and how they differ from search, exploring them in the Foundry Images playground, and building a client application that generates and saves an image.

text-to-imagegpt-image-1 & FLUXimages.generate14 quiz questions
01What they are

Generation, not retrieval

Image-generation models create graphical data from a natural-language text prompt. The key point: the image is original — generated by the model from its training, not retrieved from a database or catalog. It is not a search system.

Key concept · Models in Foundry

Foundry supports several image-generation models, including the OpenAI gpt-image-1 series and the Black Forest Labs FLUX series. Find them in the Model Catalog by filtering the inference task to "text to image." Input is everyday descriptive language — e.g. "A robot eating spaghetti" yields an original illustration of that scene.

02The playground

Experiment before you code

After creating a Foundry project, the Images playground lets you experiment with a deployed model: submit prompts, view the generated images, set the resolution/size, and — where the model supports it — provide a reference image the model uses as a basis for its output.

Key concept · Model-dependent features

Capabilities like image size/resolution control and reference-image input are subject to model support — not every model exposes every option. The playground is where you confirm what a given model offers before wiring it into an app, and it can surface sample code for the client.

03Client app

Generate and save in code

Developers build image apps with language-specific SDKs (OpenAI Python SDK, Azure OpenAI .NET SDK).

Key concept · images.generate and its parameters

Call client.images.generate(model=…, prompt=…, n=1, size="1024x1024"). Parameters: model (e.g. "FLUX.1-Kontext-pro"), prompt (the description), n (how many images), and size (dimensions). The API returns a binary stream — typically Base64-encoded in data[0].b64_json — which you Base64-decode and write to a file such as image.png.

★Test yourself

Chapter 24 quiz

Fourteen questions on image models, the playground, and the client app. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

How does an image-generation model produce its output?

  • A It generates an original image from the prompt
  • B It searches a catalog for a matching photo
  • C It edits a stock image
  • D It downloads from the web
Show answer

A. Original generation, not retrieval or search.

Q2

Which model series are available for image generation in Foundry?

  • A gpt-image-1 and FLUX
  • B Sora-2 and gpt-4o-tts
  • C Phi-4 and Whisper
  • D DALL·E only
Show answer

A. OpenAI gpt-image-1 and Black Forest Labs FLUX.

Q3

How do you find image-generation models in the Model Catalog?

  • A Filter the inference task to "text to image"
  • B Search "audio"
  • C Filter by "embeddings"
  • D They aren't in the catalog
Show answer

A — "text to image."

Q4

What can the Images playground let you provide as a basis for output (model permitting)?

  • A A reference image
  • B A SAS URL
  • C An SSML document
  • D A vector index
Show answer

A — a reference image. Plus prompt and resolution.

Q5

Which method generates an image in the OpenAI Python SDK?

  • A client.images.generate
  • B client.videos.create
  • C client.audio.speech.create
  • D client.responses.create
Show answer

A — client.images.generate.

Q6

Which parameter sets how many images to generate?

  • A n
  • B size
  • C seconds
  • D voice
Show answer

A — n. size sets the dimensions.

Part B · True or false

Q7

Image-generation models retrieve existing images that match the prompt.

Show answer

False. They generate new, original images.

Q8

Features like resolution control and reference images are model-dependent.

Show answer

True. Not every model exposes every option.

Q9

The API returns the generated image as a binary stream you decode and save.

Show answer

True. Base64-decode data[0].b64_json, then write to a file.

Q10

You can use the Azure OpenAI .NET SDK to build an image-generation app.

Show answer

True. Or the OpenAI Python SDK.

Q11

The prompt for image generation must be written in a special code syntax.

Show answer

False. It's natural, descriptive language.

Part C · Short answer

Q12

Name the four parameters of images.generate shown in the module.

Show answer

model, prompt, n, and size.

Q13

Where in the API response is the encoded image found?

Show answer

data[0].b64_json — Base64, decoded before saving.

Q14

What's the core distinction between an image-generation model and image search?

Show answer

Generation creates a new original image; search retrieves an existing one.