| **Most common position in a pipeline** | After [Converters](/docs/pipeline-components/converters.mdx) in an indexing pipeline to extract text from image-based documents |
| **Mandatory init variables** | "chat_generator": A ChatGenerator instance that supports vision-based input <br /> <br />"prompt": Instructional text for the LLM on how to extract content (no Jinja variables allowed) |
| **Mandatory run variables** | "documents": A list of documents with file paths in metadata |
| **Output variables** | "documents": Successfully processed documents with extracted content <br /> <br />"failed_documents": Documents that failed processing with error metadata |
`LLMDocumentContentExtractor` extracts textual content from image-based documents using a vision-enabled Large Language Model (LLM). This component is particularly useful for processing scanned documents, images containing text, or PDF pages that need to be converted to searchable text.
The component works by:
1. Converting each input document into an image using the `DocumentToImageContent` component,
2. Using a predefined prompt to instruct the LLM on how to extract content,
3. Processing the image through a vision-capable ChatGenerator to extract structured textual content.
The prompt must not contain Jinja variables; it should only include instructions for the LLM. Image data and the prompt are passed together to the LLM as a Chat Message.
Documents for which the LLM fails to extract content are returned in a separate `failed_documents` list with a `content_extraction_error` entry in their metadata for debugging or reprocessing.
## Usage
### On its own
Below is an example that uses the `LLMDocumentContentExtractor` to extract text from image-based documents:
```python
from haystack import Document
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.extractors.image import LLMDocumentContentExtractor
## Initialize the chat generator with vision capabilities