OpenAI -> Describe an Image from a URL
Action summary
OpenAI -> Describe an Image from a URL
Function Documentation: OpenAI -> Describe an Image from a URL
Overview
This function generates a description of an image using the OpenAI API based on the provided image URL. It requires parameters such as the image URL & model. The function ensures necessary environment variables are set and verifies conditions before making the API request and processing the response.
Inputs
openai_api_key (registry|text) Required Sensitive data
- Description: The API key for your OpenAI account.
image_url (text) Required
- Description: The URL of the image that will be sent to the OpenAI API for generating the description.
model (enum) Required
- Description: Specifies the model to be used for generating the image description.
- Options:
gpt-4o-mini
(default)gpt-4o
Function Stack
1. OpenAI API Request
API Request to
https://api.openai.com
- Purpose: Sends a request to the OpenAI API using the specified model and image URL.
Precondition:
openai_api_response.status == 200
- Purpose: Confirms that the API request was successful (HTTP status code 200).
2. OpenAI API Response
- Create Variable:
response
- Purpose: Stores the response from the OpenAI API.
Response
- The function returns the generated image description, optionally including token usage details if the
show_token_usage
flag is set to true.
Success response
{
"The image depicts a model or miniature of a fortified castle or walled city. It features a large structure at the top, resembling a castle, with walls and towers surrounding smaller buildings that likely represent a village or town inside the fortifications. The overall layout suggests a historical or fantasy setting, commonly seen in architectural models or films."
}
Error response
{
"message":"Invalid image."
}
Example
Input
{
"image_url": "https://upload.wikimedia.org/wikipedia/commons/b/b7/Medieval_Durr%C3%ABs.jpg",
"model": "gpt-4o-mini",
}
Response
{
"The image depicts a model or miniature of a fortified castle or walled city. It features a large structure at the top, resembling a castle, with walls and towers surrounding smaller buildings that likely represent a village or town inside the fortifications. The overall layout suggests a historical or fantasy setting, commonly seen in architectural models or films."
}
Version notes
2024-10-04 14:41:57
Current