Skip to content

Parse with Additional Prompts

Steer LlamaParse output with a natural-language custom prompt, narrowing a receipt parse down to only line-item prices and the total.

Custom prompts allow you to guide the Parse agentic model in the same way you would instruct an LLM.

These prompts can be useful for improving the parser’s performance on complex document layouts, extracting data in a specific format, or transforming the document in other ways.

In this example, we showcase how providing additional instructions (prompts) to Parse can be used to shape the way an LLM parses information from unstructured documents. Using a McDonald’s Receipt, we show how to ignore parts of the document and only parse the price of each order and the final amount to be paid.

Set your LlamaCloud API key so the SDKs pick it up automatically:

Terminal window
export LLAMA_CLOUD_API_KEY="llx-..."

For this example, we’re using the following McDonald’s receipt. Download it and save it with the name mcdonalds_receipt.png:

We start off by parsing the receipt with no special instructions — just a default agentic parse:

Terminal window
pip install "llama-cloud>=2.8"
from llama_cloud import LlamaCloud
client = LlamaCloud() # reads LLAMA_CLOUD_API_KEY from the environment
# Upload the receipt
file = client.files.create(file="mcdonalds_receipt.png", purpose="parse")
# Parse with no special instructions
vanilla_result = client.parsing.parse(
file_id=file.id,
tier="agentic",
version="latest",
expand=["markdown"],
output_options={
"markdown": {"tables": {"output_tables_as_markdown": True}},
},
)
print(vanilla_result.markdown.pages[0].markdown)

The result is the full markdown Parse reconstructed from the receipt:

> Rate us HIGHLY SATISFIED and
> Receive ONE FREE ITEM
> Purchase any sandwich and receive an item of equal or lesser value
> Go to www.mcdvoice.com within 7 days and tell us about your visit.
> Validation Code:
> Expires 30 days after receipt date.
> Valid at participating US McDonald's.
> Survey Code:
> 31278-01121-21018-20481-00081-0
## McDonald's Restaurant #31278
2378 PINE RD NW
RICE, MN 56367-9740
TEL# 320 393 4600
| KS# 1 | 12/08/2022 08:48 PM |
|-----------------|---------------------|
| Side1 | Order 12 |
| Item | Price |
|--------------------------|-------|
| 1 Happy Meal 6 Pc | 4.89 |
| - 1 Creamy Ranch Cup | |
| - 1 Extra Kids Fry | |
| - 1 Wreck It Ralph 2 | |
| - 1 S Coke | |
| 1 Snack Oreo McFlurry | 2.69 |
| Subtotal | 7.58 |
| Tax | 0.52 |
| Take-Out Total | 8.10 |
| Cash Tendered | 10.00 |
| Change | 1.90 |
> McDonalds Restaurant Rice
> ***NOW ACCEPTING APPLICATIONS***
> text to #36453
> apply31278

Now let’s change the output by providing an additional prompt. The custom prompt goes in agentic_options — available on the cost_effective, agentic, and agentic_plus tiers. Each tab below reuses the client and uploaded file from the previous step:

parsing_instruction = (
"The provided document is a McDonald's receipt. "
"Provide ONLY each line item (item name and price) and the final amount to be paid."
)
result_with_prompt = client.parsing.parse(
file_id=file.id,
tier="agentic",
version="latest",
expand=["markdown"],
output_options={
"markdown": {"tables": {"output_tables_as_markdown": True}},
},
agentic_options={"custom_prompt": parsing_instruction},
)
print(result_with_prompt.markdown.pages[0].markdown)

The prompt narrows the output down to just the line items and the total:

* Happy Meal 6 Pc 4.89
* Snack Oreo McFlurry 2.69
Take-Out Total 8.10
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/for-agents/mcp/ - Other LlamaIndex tooling for agents — the LlamaParse Platform MCP server, agent skills and plugins, and the n8n node — is mapped at https://developers.llamaindex.ai/for-agents/