Text and Image
Combining text and images is the most common form of multimodal AI. You can provide an image and ask questions about it, ask the AI to analyze, describe, or extract information from images, or generate images from text.
12 min•By Priygop Team•Updated 2026
What Text and Image AI Can Do
- Describe an image in detail: 'What is in this photo?'
- Answer questions about an image: 'How many people are in this meeting room photo?'
- Read text from images (OCR): extract printed or handwritten text from a photo
- Analyze charts and graphs: 'What trend does this chart show?'
- Identify objects in images: recognize products, landmarks, animals, or plants
- Compare two images: 'What is different between these two product designs?'
- Generate images from text descriptions (as you learned in Module 5)
Practical Code Example
Practical Code Example
# Using OpenAI's GPT-4o to analyze an image (concept illustration)
# In practice, you would use the OpenAI API with a real image URL or base64 data
# IMPORTANT: Never hardcode API keys. Always use environment variables.
import os
# The API key is read from an environment variable, never from code
# Set this in your terminal: set OPENAI_API_KEY=your_key_here (Windows)
# Or in .env file if using python-dotenv
API_KEY = os.environ.get("OPENAI_API_KEY")
def describe_image_concept():
"""
Illustrates how you would send an image to GPT-4o for analysis.
This is a concept illustration - real usage requires openai package.
"""
# The request structure for a multimodal GPT-4o API call
request_structure = {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Describe the main elements."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/your-image.jpg"
# Or use base64: "data:image/jpeg;base64,..."
}
}
]
}
],
"max_tokens": 300
}
print("Request structure for GPT-4o image analysis:")
import json
print(json.dumps(request_structure, indent=2))
print()
print("Note: Replace the image URL with your actual image URL")
print("The API returns a text description of what it sees in the image")
print()
print("SECURITY: Store your API key in an environment variable:")
print(" Windows: set OPENAI_API_KEY=your_key_here")
print(" Mac/Linux: export OPENAI_API_KEY=your_key_here")
print(" Python: import os; key = os.environ.get('OPENAI_API_KEY')")
describe_image_concept()Diagram
Loading diagram…
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Key Takeaways
- Combining text and images is the most common form of multimodal AI.
- Describe an image in detail: 'What is in this photo?'
- Answer questions about an image: 'How many people are in this meeting room photo?'
- Read text from images (OCR): extract printed or handwritten text from a photo