QuestionQ32

VerifiedImplement AI solutions by using Microsoft Foundry

You have a Microsoft Foundry project containing a model deployment.

You are developing an application that sends an image and a user question to the model. You need to send text and image content in the same request so that the model can return an answer.

Complete the Python code. Values may be used once, more than once, or not at all.

Drag & Drop
import os
from openai import OpenAI

...

response = client.responses.create(
    model=os.getenv("MODEL"),
    input=[
        {
            "role": "user",
            "content": [
                {"type": "", "text": "What is in this image? Provide 3 bullet points."},
                {"type": "", "image_url": image_url}
            ]
        }
    ],
)

print(response.output_text)
Explanation

The Responses API accepts multimodal user input as a content list. A text prompt uses {"type": "input_text", "text": ...}, while an image URL uses {"type": "input_image", "image_url": ...}. output_text is returned by the API and is not an input-content type.

Community Discussion

No comments yet. Be the first to start the discussion!