Skip to main content

Using the REST API

Quickstart​

Create a new agent​

curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/extraction-agents' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "resume_parser",
"data_schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Candidate name"
},
"experience": {
"type": "array",
"description": "Work history",
"items": {
"type": "object",
"properties": {
"company": {
"type": "string",
"description": "Company name"
},
"title": {
"type": "string",
"description": "Job title"
},
"start_date": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Start date of employment"
},
"end_date": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "End date of employment"
}
}
}
}
}
},
"config": {
"extraction_target": "PER_DOC",
"extraction_mode": "ACCURATE",
"handle_missing": false,
"system_prompt": "string"
}
}'

Upload a document​

Upload a document using our Upload API.

curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/files' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-F 'upload_file=@/path/to/your/file.pdf;type=application/pdf'

Run an extraction job​

Use the extraction_agent_id and file_id from the previous steps to run an extraction job.

curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/jobs' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{
"extraction_agent_id": "{$AGENT_ID}",
"file_id": "{$FILE_ID}",
}'

Get the results of an extraction job​

curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/jobs/{$JOB_ID}' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

Full API documentation​

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

warning

This is a beta release. We will try our best to keep the REST API stable and reduce disruptive changes, but recommend using the Python SDK if possible, to minimize breaking changes.