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
Create a report with template text:
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.
Get Report Status and Content
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/reports/<report_id>' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"
Get Report Metadata
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 Reports
List all reports:
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:
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"
Update Report Plan
Approve the plan and kick off report generation:
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:
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"
},
...
]
}'
Get Report Events
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:
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"
Suggest Edits
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"}
]
}'
Update Report Content
This updates the content of the report in-place. You'll need to pass in the entire content object, not just the changed blocks:
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": [...]
},
...
]
}
}'
Delete a Report
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.