Docling Reader
Convert Docling-supported documents, images, audio, and video into knowledge documents.
Pass DoclingReader to Knowledge.insert() to parse supported formats with Docling.
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.docling_reader import DoclingReader
from agno.models.openai import OpenAIResponses
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
vector_db=PgVector(
table_name="docling_documents",
db_url=db_url,
),
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
knowledge=knowledge,
search_knowledge=True,
)
if __name__ == "__main__":
knowledge.insert(
name="Thai Recipes",
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
reader=DoclingReader(output_format="markdown"),
)
agent.print_response(
"How do I make chicken and galangal in coconut milk soup?",
markdown=True,
)Supported Input Groups
| Group | Examples |
|---|---|
| Documents | PDF, DOCX, PPTX, Markdown, HTML, AsciiDoc, and LaTeX |
| Data | CSV, XLSX, XML, and Docling JSON |
| Images | PNG, JPEG, TIFF, BMP, and WebP |
| Audio | WAV, MP3, M4A, AAC, OGG, and FLAC |
| Video | MP4, AVI, and MOV |
Run the Agent
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U "agno[docling]" openai pgvector psycopg sqlalchemyAudio and video conversion also require:
uv pip install -U "docling[asr]" "docling-slim[format-video]"These extras enable the audio and video capability groups described in Docling media processing. Install ffmpeg with your operating system's package manager. See FFmpeg downloads for platform packages.
Export the API key
export OPENAI_API_KEY=your_openai_api_key_hereRun PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql \
-v pgvolume:/var/lib/postgresql \
-p 5532:5432 \
--name pgvector \
agnohq/pgvector:18Run the agent
python docling_reader.pyReader Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
output_format | str | "markdown" | Export format ("markdown", "text", "json", "yaml", "html", "html_split_page", "doctags", "vtt") |
converter | Optional[DocumentConverter] | None | Custom Docling converter configuration |
format_options | Optional[dict] | None | Format options dictionary for DocumentConverter |
chunking_strategy | Optional[ChunkingStrategy] | DocumentChunking() | Strategy for chunking the document |
allowed_hosts | Optional[List[str]] | None | Hostnames the reader is allowed to fetch from. See Restricting URL Fetches. |
In the current implementation, Knowledge.insert(url=..., reader=DoclingReader(allowed_hosts=...)) downloads extension-bearing URLs before calling the reader. Validate the URL before ingestion because the reader's allowlist does not guard this path.
DoclingReader.async_read() runs the synchronous conversion in a worker thread.
Next Steps
| Task | Guide |
|---|---|
| Compare available readers | Readers Overview |
| Configure chunking | Chunking |
| Parse PDFs with pypdf | PDF Reader |