Skip to main content

Structured Output (Beta)



About Structured Output

Structured output allows you to extract structured data (such as JSON) from a document directly at the parsing stage, reducing cost and time needed.

Structured output is currently only compatible with our default parsing mode and can be activated by setting structured_output=True in the API.

parser = LlamaParse(
structured_output=True
)


You then need to provide either:

  • a JSON schema in the structured_output_json_schema API variable, which will be used to extract data in the desired format
  • or the name of one of our pre-defined schemas in the variable structured_output_json_schema_name
parser = LlamaParse(
structured_output_json_schema='A JSON SCHEMA'
)


Supported Pre-defined Schemas



imFeelingLucky

Wildcard schema that lets LlamaParse infer output format
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/parsing/upload' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
--form 'structured_output_json_schema_name="imFeelingLucky"' \
-F 'file=@/path/to/your/file.pdf;type=application/pdf'


Invoice

Standard invoice schema for line items, tax, and totals
  curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/parsing/upload' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
--form 'structured_output_json_schema_name="invoice"' \
-F 'file=@/path/to/your/file.pdf;type=application/pdf'


Resume

Follows the JSON Resume standard
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/parsing/upload' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
--form 'structured_output_json_schema_name="resume"' \
-F 'file=@/path/to/your/file.pdf;type=application/pdf'