Document AI Quick Start
This quick start takes one PDF from cloud storage to searchable passages in your application. You call the Document AI REST API from your application's Console, watch the run complete, and confirm the results. Expect it to take about ten minutes.
Before you begin
Confirm you have:
- Your target application is running on C3 AI Platform 8.10 or later. Document AI requires
presignedUrlsupport, which was introduced in platform 8.10. - Document AI is deployed on your cluster. Its base URL isn't a fixed path; look it up from your application's Console with
Microservice.Config.forName('DocAi')and append/docai/v1to the returnedserviceAppUrl. See Document AI REST API Developer Guide for details. - A PDF file at an absolute storage URL Document AI can read, such as
azure://<container>/<path>/report.pdfors3://<bucket>/<path>/report.pdf. - The ID of a retriever in your application. A retriever is the vector store that holds embedded passages for search, conventionally identified as
default-pg.
Submit the document
Open your application's Console and submit the file:
var BASE = Microservice.Config.forName('DocAi').serviceAppUrl + '/docai/v1';
fetch(BASE + '/process', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
source: { files: ['azure://<container>/<path>/report.pdf'] },
strategyName: 'passage_level',
retrieverId: 'default-pg',
}),
})
.then((r) => r.json())
.then((d) => {
window.docaiRunId = d.runs[0].runId;
return d;
});The response returns a jobId for the batch and a separate run for each file—a run is Document AI's unit of work for processing one file—each starting in PENDING. The snippet saves the run ID for the next step. Because you call from your application's Console, Document AI infers the target application from the referring Console URL, using the Referer header. If your Console runs on a vanity URL, or you call from a script, that inference fails at submission. Add "sourceApp": "<your-app-id>" to the request body instead.
You chose the passage_level strategy, which parses every page, splits the content into chunks, and embeds each chunk for retrieval.
Monitor the run
Poll the run until it reaches a terminal status:
fetch(BASE + '/runs/' + window.docaiRunId)
.then((r) => r.json())
.then((d) => d.status);The run moves through PENDING, DISPATCHED, PROCESSING, and COMPLETED. Because you supplied a retrieverId, Document AI then persists the results automatically, and the run ends in PERSISTED. A single small PDF typically finishes in under a minute. Document AI routes each file by size to a small, medium, or large processing fleet; files over 1 GiB are rejected at submission.
If the run ends in FAILED instead, read the response's errorMessage field. The most common cause is a file URL Document AI can't read; confirm the URL is absolute and correct, then resubmit. See the Troubleshoot common failures section of the Document AI REST API Developer Guide for more failure causes and fixes.
Confirm the results
Still in your application's Console, not Document AI's, fetch the newest source file records; the Genai types live in your application:
var files = Genai.SourceFile.fetch({
limit: 5,
order: 'descending(meta.created)',
}).objs;Your document appears as one Genai.SourceFile record. Document AI stores its chunks as Genai.Vector.SourcePassage records under the retriever, and any agent or search feature built on that retriever can now answer questions grounded in your document.
Next steps
You processed one document with default settings. From here you can:
- Submit whole folders, monitor batches, and diagnose failures. See Document AI REST API Developer Guide.
- Extract structured tags and typed entities during processing. See Configure Tag and Entity Extraction.
- Ask the Agentix assistant to run ingestion for you in plain language. See Document AI Overview.