ComenzarEmpieza gratis

Prompting with Images from URLs

You're building an automated product cataloging system for an online marketplace. The system needs to analyze product images and generate accurate descriptions for the catalog. You'll use role-based messages to send an image URL to the model and request both a classification and a description.

A URL string to a photo of a winter jacket has been stored as image_url, and the visualize_image() function has been defined for you to compare the image with the generated description.

Este ejercicio forma parte del curso

Working with the OpenAI Responses API

Ver curso

Instrucciones del ejercicio

  • Add a user message containing both a text prompt asking to classify and describe the product, and the image URL (image_url) using the appropriate content types.
  • Create the request to the "gpt-5-mini" model using your messages list and extract the output text.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

messages = [{"role": "system", "content": "You are a product cataloging expert who provides concise classifications and descriptions."}]

# Add user message with text and image
messages.append({
    "role": "____",
    "content": [
        {"type": "____", "____": "Classify this product and write a brief but punchy description for our catalog."},
        {"type": "____", "image_url": "____"}
    ]
})

# Create the response
response = ____

print(response.output_text)
visualize_image(image_url)
Editar y ejecutar código