Skip to content

Python API

Basic usage

from markitdown import MarkItDown

md = MarkItDown(enable_plugins=False)  # Set to True to enable plugins
result = md.convert("test.xlsx")
print(result.markdown)

Document Intelligence conversion

from markitdown import MarkItDown

md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
result = md.convert("test.pdf")
print(result.markdown)

See Azure Document Intelligence for more details.

Image descriptions with an LLM

To use Large Language Models for image descriptions (currently only for pptx and image files), provide llm_client and llm_model:

from markitdown import MarkItDown
from openai import OpenAI

client = OpenAI(max_retries=5)
md = MarkItDown(llm_client=client, llm_model="gpt-4o", llm_prompt="optional custom prompt")
result = md.convert("example.jpg")
print(result.markdown)

max_retries controls the OpenAI client's automatic retries for retryable errors (the default is 2); 5 allows up to six attempts with backoff. See the OpenAI SDK retry documentation.

If any attempt succeeds, image conversion continues normally. If the client raises an error after exhausting its retries, or encounters a non-retryable error, MarkItDown tries other applicable converters and raises FileConversionException only if none succeeds.

Need documentation like this for your own product?

This site was built by Sonicar Tech LLC — we help SaaS, B2B, Enterprise, FinTech, and AI companies launch professional, docs-as-code documentation 60% faster and cheaper than building an in-house team, with first drafts delivered in 1 week.

Visit sonicar.tech