Using the REST API
If you prefer to use the LlamaExtract API directly, that's great! You can use it in any language that can make HTTP requests. Here are some sample calls:
Upload the files
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'
Infer and create a schema
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/schemas/infer' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{"name":"Schema Name","file_ids":["<file_id_1>", "<file_id_2>"]}'
Start 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 '{"schema_id":"<schema_id>","file_id":"<file_id_1>"}'
Or in batch:
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/jobs/batch' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{"schema_id":"<schema_id>","file_ids":["<file_id_1>", "<file_id_2>"]}'
Check the status of the 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"
Get the results
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v1/extraction/jobs/<job_id>/result' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"
You can see all the available endpoints in our full API documentation -->