Document processing
Read the text out of a PDF, Word or Excel file — Lao included — and, if you ask, have it summarized, reduced to key points, translated, or turned into structured fields. It runs as an asynchronous job: enqueue it, then poll the job.
POST
/v1/docproc/jobs API key Fields
file * file | A PDF, Word (.docx) or Excel (.xlsx) file. Over 10 MB: upload it first with POST /v1/docproc/uploads, then pass sourceKey in a JSON body. |
task extract | summarize | key_points | translate | structured | What to do with the text. Default: extract (the text only, no model). |
targetLanguage string | For translate: the language to translate into, e.g. "English" or "Lao". |
schemaHint string | For structured: the fields you want, e.g. "invoice number, date, total". |
Enqueue a job
curl -X POST https://ai-api.vanguardinitiative.com/v1/docproc/jobs \
-H "authorization: Bearer $API_KEY" \
-F file=@report.pdf -F task=summarizeconst form = new FormData();
form.append('file', file);
form.append('task', 'summarize');
const res = await fetch('https://ai-api.vanguardinitiative.com/v1/docproc/jobs', {
method: 'POST',
headers: { authorization: 'Bearer ' + API_KEY },
body: form,
});
const { jobId } = await res.json();import requests
with open('report.pdf', 'rb') as f:
job_id = requests.post(
'https://ai-api.vanguardinitiative.com/v1/docproc/jobs',
headers={'authorization': f'Bearer {API_KEY}'},
files={'file': f},
data={'task': 'summarize'},
).json()['jobId']Poll for the result
Poll GET /v1/jobs/{id} until status is success or error. The text is in result.text; the task’s answer (summary, key points, translation, fields) is in summary.markdown.
curl https://ai-api.vanguardinitiative.com/v1/jobs/$JOB_ID \
-H "authorization: Bearer $API_KEY"200 Finished job
{
"status": "success",
"job": {
"id": "6d0b…",
"serviceId": "docproc",
"status": "success",
"result": { "text": "…", "charCount": 18234, "pageCount": 12, "task": "summarize" },
"summary": { "markdown": "## Summary\n…" }
}
}