Overview
When an LLM client is configured, MarkItDown:- Extracts image metadata using ExifTool (if available)
- Encodes the image as a base64 data URI
- Sends the image to the LLM with a prompt
- Includes the AI-generated description in the Markdown output
LLM integration is currently supported for JPEG and PNG images only.
Prerequisites
1
Install OpenAI Package
openai package is not included in MarkItDown’s dependencies and must be installed separately.2
Get API Key
Obtain an API key from OpenAI or your LLM provider
3
Optional: Install ExifTool
For enhanced image metadata extraction:
Basic Usage
Python API
Configuration Options
LLM Client
Any OpenAI-compatible client that supports the chat completions API:LLM Model
Specify the model to use for image descriptions:gpt-4o- Recommended, high qualitygpt-4o-mini- Faster, more cost-effectivegpt-4-turbo- Previous generationgpt-4-vision-preview- Legacy
Custom Prompt
Customize the prompt sent to the LLM:Per-Conversion Override
Override settings for individual conversions:Implementation Details
Image Processing
The LLM integration in_image_converter.py:
Supported Image Types
LLM descriptions are generated for:.jpg,.jpeg(JPEG images).png(PNG images)
Advanced Examples
Multiple Images with Different Prompts
Accessibility Captions
Content Moderation
Custom OpenAI Client Configuration
Azure OpenAI
Alternative LLM Providers
Any OpenAI-compatible API:Cost Considerations
Cost factors:- Model choice:
gpt-4o-miniis more cost-effective thangpt-4o - Image size: Larger images consume more tokens
- Prompt length: Longer prompts increase costs
- Frequency: Each image conversion = one API call
gpt-4o: ~$0.01-0.02 per imagegpt-4o-mini: ~$0.001-0.002 per image
Minimize Costs
Error Handling
Without LLM Integration
If no LLM client is configured, image conversion includes only metadata:Troubleshooting
OpenAI Package Not Installed
Invalid API Key
- API key is correct
- API key has not expired
- Account has available credits
Model Not Found
- Model name is correct
- Your account has access to the model
- Using correct API endpoint (OpenAI vs Azure)