Skip to content
LlamaParse 文档版本 跟随上游 源快照 8c136532 更新于 2026-10-16

已弃用

本页记录的是已弃用的 Extract v1 API。新的接入请使用 Extract v2;改造已有的 v1 代码请见v1 到 v2 迁移指南。

快速开始

创建一个新的智能体

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 可从网页界面 取得。

以编程方式创建/编辑 project,还可参考 Projects 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"

上传文档

用我们的 Upload API 上传一个文档。

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

运行一个抽取任务

用上一步得到的 extraction_agent_id 与 file_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 文档

这里只是帮助你上手的部分端点。

全部可用端点见我们的完整 API 文档。

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。