Docling Reader

Convert Docling-supported documents, images, audio, and video into knowledge documents.

Pass DoclingReader to Knowledge.insert() to parse supported formats with Docling.

docling_reader.py
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

GroupExamples
DocumentsPDF, DOCX, PPTX, Markdown, HTML, AsciiDoc, and LaTeX
DataCSV, XLSX, XML, and Docling JSON
ImagesPNG, JPEG, TIFF, BMP, and WebP
AudioWAV, MP3, M4A, AAC, OGG, and FLAC
VideoMP4, AVI, and MOV

Run the Agent

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U "agno[docling]" openai pgvector psycopg sqlalchemy

Audio 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_here

Run 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:18

Run the agent

python docling_reader.py

Reader Parameters

ParameterTypeDefaultDescription
output_formatstr"markdown"Export format ("markdown", "text", "json", "yaml", "html", "html_split_page", "doctags", "vtt")
converterOptional[DocumentConverter]NoneCustom Docling converter configuration
format_optionsOptional[dict]NoneFormat options dictionary for DocumentConverter
chunking_strategyOptional[ChunkingStrategy]DocumentChunking()Strategy for chunking the document
allowed_hostsOptional[List[str]]NoneHostnames 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

TaskGuide
Compare available readersReaders Overview
Configure chunkingChunking
Parse PDFs with pypdfPDF Reader