| name | llama-extract |
| description | Extract structured JSON from PDFs, DOCX, images, and other documents using a schema. Faster and more accurate than reading pages directly for tables, multi-page schedules, financial filings, invoices, contracts, and any document where a defined schema describes the expected output. |
| when_to_use | Use whenever the request involves a schema (Pydantic model or JSON Schema) plus a document. Trigger phrases include "extract these fields from", "pull the line items out of", "get the financials out of", "build a JSON record from", "match this schema against", "what does this invoice/10-K/contract/Call Report say about", "extract structured data from". |
| compatibility | Requires Python 3.9+ and `pip install 'llama-cloud>=2.7'`. Set `LLAMA_CLOUD_API_KEY` in the environment. |
| allowed-tools | Bash(python *), Write, Read |
| license | MIT |
| metadata | {"author":"LlamaIndex","version":"0.2.0"} |
LlamaExtract Skill
Extract structured JSON from documents using a schema. This skill ships a bundled CLI (scripts/extract.py) that handles upload, extraction, polling, and result writing. Your job is to (a) define the schema as JSON Schema, (b) invoke the CLI, (c) read the result.
When to use this skill
Use this skill whenever a request combines:
- A document (PDF, DOCX, PPTX, XLSX, image, or similar)
- A target schema (Pydantic model, JSON Schema, or a list of fields the user wants extracted)
Concrete triggers: extracting line items from an invoice, pulling fields from a 10-K / Call Report / contract / KYC doc / insurance claim, getting a structured record from a form. The bundled CLI is faster than reading PDF pages directly, especially for: multi-page tables, dense schedules, regulatory filings, scanned PDFs, and any document with a defined output schema.
Step 1 — Write the schema to a JSON file
Encode the target schema as JSON Schema. If the user provides a Pydantic model, convert it:
import json
from my_models import MyModel
open("./schema.json", "w").write(json.dumps(MyModel.model_json_schema(), indent=2))
If the user provides field names + descriptions in prose, build the JSON Schema directly:
{
"type": "object",
"title": "MySchema",
"description": "<one-sentence description of the document type>",
"properties": {
"invoice_number": {
"type"