Course menuAI-901

Exams / AI-901 / Vision and image generation apps / Question 2

AI-901 practice question: Vision and image generation apps (2 of 4)

Implement AI solutions by using Microsoft Foundry A free question from our original AI-901 practice exam. Try it, then open the answer to see why each option is right or wrong.

Last verified against current Microsoft Learn ·How we write our questions

A dental clinic's marketing team wants a poster image for its waiting room, generated from a text prompt. The developer's code below requests the image, which comes back as base64 text, and decodes it into bytes.

img = client.images.generate(model=IMAGE_DEPLOYMENT, prompt="Calm blue waiting room poster", n=1, size="1024x1024") image_bytes = base64.b64decode(img.data[0].________)

Which attribute name should replace the blank?

Choose one answer.

  1. A. the url attribute
  2. B. the b64_json attribute
  3. C. the bytes attribute
  4. D. the revised_prompt attribute
Show the answer and explanation

Answer: B

  • A. Wrong: A url field would point to an image to download over HTTP. The decode step needs the encoded text that the response carries, not a link.
  • B. Right: Correct. Each item in the data list carries the base64 text in b64_json, which the code decodes into the image bytes before writing them to a file. Learn more: Lab: Computer vision (opens in a new tab)
  • C. Wrong: bytes is not a field of the response. The response carries base64 text, which must be decoded into bytes, so the attribute named here does not exist.
  • D. Wrong: revised_prompt holds the wording the service rewrote from the original prompt. It does not contain the encoded image.

Explanation

Image generation returns a list in data, and each item carries the image as base64 text in b64_json. The code decodes that text into bytes. The other fields do not hold the encoded image.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

Want more on Vision and image generation apps? The 5 full-length practice sets have 20 more Vision and image generation apps questions, 225 in all, none of them in the free exam. One payment of $9.99 $6.99, no subscription. Get the practice sets

Every exam starts with free questions. No account needed.