Skip to content
LlamaIndex Framework
Component Guides
Querying
Structured Outputs

Pydantic Programs

A pydantic program is a generic abstraction that takes in an input string and converts it to a structured Pydantic object type.

Because this abstraction is so generic, it encompasses a broad range of LLM workflows. The programs are composable and be for more generic or specific use cases.

There’s a few general types of Pydantic Programs:

  • Text Completion Pydantic Programs: These convert input text into a user-specified structured object through a text completion API + output parsing.
  • Function Calling Pydantic Programs: These convert input text into a user-specified structured object through an LLM function calling API.
  • Prepackaged Pydantic Programs: These convert input text into prespecified structured objects.

See the example notebook on LLM Text Completion programs

Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/python/shared/mcp/