Image Description and Captioning Prompts
Directing model focus: objects, relationships, mood, and technical details.
Image Description and Captioning Prompts is a free AI Prompt Engineering lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Prompt Engineering learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Vision Models and Prompting
Vision language models (VLMs) like GPT-4o and Claude can process images alongside text. The prompt you send with an image dramatically affects the quality, focus, and format of the model's description.
Without a guiding prompt, the model decides what to describe — which may not match what you need. A structured description prompt tells the model exactly which elements to attend to and how to organize its output.
Sending an Image with a Prompt
The Anthropic API accepts images as base64-encoded content or URLs. Here is the basic structure:
import anthropic, base64
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
with open('image.jpg', 'rb') as f:
image_data = base64.standard_b64encode(f.read()).decode('utf-8')
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=500,
messages=[{
'role': 'user',
'content': [
{
'type': 'image',
'source': {
'type': 'base64',
'media_type': 'image/jpeg',
'data': image_data
}
},
{
'type': 'text',
'text': 'Describe this image in detail.'
}
]
}]
)
print(response.content[0].text)The Unstructured Description Prompt
The simplest prompt — Describe this image — produces an output shaped entirely by the model's priorities. For many use cases, this is insufficient:
- The model may focus on the most visually striking element, not the most relevant one
- Descriptions may vary widely in length and organization across similar images
- Important details (text, small objects, background context) are often omitted
Structured description prompts solve all of these issues.
Structured Description: Directing Attention
A structured description prompt explicitly directs the model's attention to specific visual elements:
structured_prompt = '''
Describe this image in detail, addressing each of the following aspects:
1. FOREGROUND: Main subjects and objects in the foreground
2. BACKGROUND: Setting, environment, and background elements
3. COLORS: Dominant color palette and notable color contrasts
4. MOOD: Emotional tone, atmosphere, and lighting
5. TEXT: Any visible text, signs, labels, or written content
6. PEOPLE: If people are present — count, approximate age, pose, expression
Organize your response using these exact section headers.
Be specific and descriptive. Avoid vague terms like "some" or "various".
'''
print(structured_prompt)Controlling Description Length
The same image may need different description lengths for different use cases. Control length explicitly in the prompt:
# For image captions in a product catalog
short_prompt = '''
Write a 1-sentence product image caption (under 15 words).
Focus on the product, its key feature, and setting.
'''
# For accessibility alt-text
alt_text_prompt = '''
Write an image alt-text description for a visually impaired user.
Limit: 125 characters.
Include: what the image shows, any text visible in the image, the most important action or emotion.
'''
# For detailed analysis
detailed_prompt = '''
Write a detailed image analysis of 200-300 words.
Cover: composition, subjects, setting, colors, mood, and any notable technical or artistic elements.
Structure as a single flowing paragraph.
'''
print('Three length-controlled description prompts defined.')Domain-Specific Description Prompts
Different domains require different descriptive vocabulary and focus areas:
# Medical imaging description
medical_prompt = '''
Describe the key visual findings in this medical image.
Focus on: anatomical structures visible, any abnormalities or anomalies,
location using standard anatomical terms (left/right, superior/inferior, medial/lateral),
and image quality or artifacts.
Note: this description is for informational purposes only, not diagnostic.
'''
# Architecture / real estate
architecture_prompt = '''
Describe this property image for a real estate listing.
Cover: room type, approximate size, key features (flooring, ceiling, natural light),
condition, notable fixtures or finishes, and overall style.
Tone: professional, appealing, factual.
'''
# Security / surveillance
security_prompt = '''
Describe this security camera image.
Note: number of people, approximate location in frame, clothing colors,
any objects being carried, direction of movement, and time of day if discernible.
'''
print('Domain-specific prompts defined.')Structured Output from Image Descriptions
For automated pipelines, request structured JSON output from the image description rather than prose:
json_description_prompt = '''
Analyze this product image and return a JSON description:
{
"product_name": "inferred product name or null",
"category": "electronics|clothing|furniture|food|other",
"colors": ["primary color", "secondary color"],
"condition": "new|used|unclear",
"background": "white|lifestyle|outdoor|studio|other",
"people_visible": true | false,
"text_visible": "extracted text or null",
"quality_score": 1-10,
"caption": "one sentence product caption"
}
Return only the JSON object.
'''
print(json_description_prompt)Accessibility-Focused Description
Writing image descriptions for accessibility requires a specific prompt style that prioritizes information for visually impaired users:
accessibility_prompt = '''
Write an image description optimized for screen reader accessibility.
Guidelines:
- Start with the most important content (what is this image about?)
- Describe spatial relationships (the man on the left, the building in the background)
- Include all visible text verbatim
- Describe faces and expressions if relevant to the content
- Skip decorative descriptions unless they convey meaning
- End with: if this is a graph or chart, include the key data it shows
- Maximum 250 characters for alt-text. If more is needed, write a 1-sentence alt-text plus a longer caption.
'''
print(accessibility_prompt)Avoiding Common Description Prompt Mistakes
Common mistakes in image description prompts and how to fix them:
- Too vague: Describe the image → Fix: specify which elements to describe
- No format: Model writes prose when you need JSON → Fix: specify output format explicitly
- No length limit: Model writes 1000 words → Fix: specify target length
- No focus: All elements described equally → Fix: specify which element is primary
- No domain context: Generic description for specialist image → Fix: include domain vocabulary and focus criteria
Batch Image Description Pipeline
For processing multiple images in an automated pipeline:
import anthropic, base64, json
from pathlib import Path
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
DESCRIPTION_PROMPT = '''
Describe this image for a product catalog.
Return JSON: {"caption": str, "colors": [str], "category": str, "alt_text": str}
'''
def describe_image(image_path):
with open(image_path, 'rb') as f:
img_b64 = base64.standard_b64encode(f.read()).decode('utf-8')
r = client.messages.create(
model='claude-opus-4-5', max_tokens=200,
messages=[{'role': 'user', 'content': [
{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': img_b64}},
{'type': 'text', 'text': DESCRIPTION_PROMPT}
]}]
)
return json.loads(r.content[0].text)
print('Batch image description pipeline defined.')Testing Description Prompt Quality
Test description prompts on a diverse set of images to ensure coverage and consistency:
- Simple product on white background
- Lifestyle photo with multiple people
- Dense text document or sign
- Dark or low-quality image
- Abstract or ambiguous content
For each test image, verify the output covers all required elements, respects length constraints, and uses the required format. Adjust the prompt when any category systematically fails.
Quick Check
What is the primary benefit of a structured image description prompt over a simple 'Describe this image' prompt?
Image Description Prompts — Key Takeaways
Structured image description prompts are essential for consistent, useful visual AI outputs:
- Explicitly list which visual elements to describe (foreground, background, colors, mood, text, people)
- Specify output format — prose, JSON, or specific section headers
- Control length explicitly — match length to use case (15-word caption vs 250-word analysis)
- Domain-specific prompts (medical, real estate, security) require domain vocabulary and focus criteria
- For accessibility, prioritize information over aesthetics and include all visible text verbatim
- Test on diverse image types: product, lifestyle, text-heavy, low-quality, abstract
Frequently asked questions
Is the “Image Description and Captioning Prompts” lesson free?
Yes — the full text of “Image Description and Captioning Prompts” is free to read here on the web, and the AI Prompt Engineering course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Prompt Engineering course, upgrade to CoddyKit PRO.
What will I learn in “Image Description and Captioning Prompts”?
Directing model focus: objects, relationships, mood, and technical details. You practise AI Prompt Engineering with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AI Prompt Engineering?
No prior experience is required. AI Prompt Engineering on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Image Description and Captioning Prompts” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AI Prompt Engineering lesson?
Yes. Every AI Prompt Engineering lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Image Description and Captioning Prompts
- Visual Question Answering
- Multi-Image Comparison Prompts
- OCR and Document Analysis Prompts