Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured with a vision-capable
LLM_MODEL— the transcription step calls it - Install the OCR engine:
pip install "cognee[rapidocr]" - Read Loaders for how Cognee picks a loader per file and for the full set of image environment variables
- Have an image file on disk. The script reads
revenue_chart.pngfrom the example’smultimedia_audio_image_processing_example_data/directory in the Cognee repo — download it from there to reproduce the run exactly, or pointimage_pathat your own file to check that one instead
Code in Action
What Just Happened
Step 1: Enable Extraction and OCR
ImageLoader is the loader remember() would pick for an image, imported directly here so you can call it on its own. IMAGE_EXTRACTION_ENABLED asks the vision model for entities, relationships, and verbatim text rather than a short caption; IMAGE_OCR_ENABLED adds a local OCR pass on top. Both are read when the image loads, and setdefault leaves any value you already set in the environment or .env untouched.
Step 2: Point at an Image File
Step 3: Load the Image and Print the Text
load() runs the transcription and, when OCR is on, appends the recognized text to it. persist=False returns that text directly; the default persist=True writes it into Cognee’s data directory and returns the file path instead — useful in a pipeline, unhelpful when you just want to read the result.
Advanced Usage
Reading the two halves of the output
Reading the two halves of the output
The vision transcription comes first. If the OCR pass recognized anything, it follows under an
[OCR extracted text] heading, so you can tell which half produced which text. OCR output is truncated at 8000 characters, and a failing OCR pass is logged and skipped rather than raising — so a result with no [OCR extracted text] block means OCR found nothing, was disabled, or failed.Checking one flag at a time
Checking one flag at a time
To see what each stage contributes, run the script twice.
IMAGE_OCR_ENABLED="false" gives the vision transcription alone; IMAGE_EXTRACTION_ENABLED="false" restores the legacy short-caption prompt. Both flags, and the transcription prompt and token-cap settings around them, are documented in Loaders.From check to ingestion
From check to ingestion
Nothing here writes to memory. Once the extracted text looks right, pass the same image path to
remember() — it selects ImageLoader for you and reads the same environment variables, so the text you just printed is the text that gets chunked and turned into graph memory.Loaders
See every format Cognee reads and each image transcription setting
Remember
Ingest the image once its extracted text looks right