跳转到内容

REST API

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": "BALANCED",
}
}'

您可以使用以下命令列出所有现有的智能体。project_id 可以从网页界面获取。

另请参阅项目API以通过编程方式创建/编辑项目。

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

你也可以通过名称获取特定的 agent_id

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

使用我们的上传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'

使用前几步中的 extraction_agent_idfile_id 来运行提取任务。

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}",
}'

作业是异步处理的。您可以使用以下端点轮询作业状态。

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"

如果任务成功完成,您将看到状态为 SUCCESS。然后您可以从以下端点获取结果。

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"

这只是可用端点的子集,旨在帮助您入门。

您可以在我们的完整API文档中查看所有可用的端点。