Skip to content

Using the REST API

The LlamaReport API can be used with any language that can make HTTP requests.

You can see all the available endpoints in our full API documentation.

Here are some sample calls:

Create a report with template text:

Terminal window
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/reports/' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-F 'name=My Report' \
-F 'template_text=# Quarterly Report\n## Executive Summary\n...' \
-F 'files=@/path/to/data.pdf'

You could also use tempalate_file to point to a file instead of passing in the template text.

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"
Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/metadata' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

List all reports:

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/list' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

Filter by state and limit results:

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/list?state=completed&limit=10&offset=0' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

Approve the plan and kick off report generation:

Terminal window
curl -X 'PATCH' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/plan?action=approve' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

Edit the plan by passing in the serialized plan object. This updatest the plan in-place, so you’ll need to pass in the entire plan object, not just the changed blocks:

Terminal window
curl -X 'PATCH' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/plan?action=edit' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{
"blocks": [
{
"block": {
"idx": 0,
"template": "# Updated Report Title",
"sources": [...]
},
"queries": [],
"dependency": "none|all|prev|next"
},
...
]
}'
Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/events' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

Get events after a specific sequence number:

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/events?last_sequence=5' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"
Terminal window
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>/suggest_edits' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{
"user_query": "Make the executive summary more concise",
"chat_history": [
{"role": "user", "content": "Previous message"},
{"role": "assistant", "content": "Previous response"}
]
}'

This updates the content of the report in-place. You’ll need to pass in the entire content object, not just the changed blocks:

Terminal window
curl -X 'PATCH' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{
"content": {
"blocks": [
{
"idx": 0,
"template": "Updated content here",
"sources": [...]
},
...
]
}
}'
Terminal window
curl -X 'DELETE' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

You can see all the available endpoints in our full API documentation.