parse_result source.
Method signature
Parameters
Returns
AJob. On success, result.units is one row per document or page range.
Confidence is the fraction of the unit assigned that label, not a calibrated
probability.
See Classify guide.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Label one file against classes you define
parse_result source.
import { NdiClient } from "ndi-sdk";
const client = new NdiClient();
const document = await client.documents.createUpload("invoice.pdf");
const job = await client.jobs.wait(
(
await client.documents.classify(document, {
classes: [{ id: "invoice", label: "Invoice", description: "A supplier invoice" }],
wait_seconds: 30,
})
).job_id,
);
if (job.result?.result_type === "classify" && "units" in job.result) {
for (const unit of job.result.units) {
console.log(unit.unknown, unit.labels);
}
}
classify(
source: UploadSource | UrlSource | WorkspaceFileSource | UploadResponse,
opts: {
classes: ClassifyClass[];
granularity?: "document" | "page";
page_ranges?: PageRange[];
unknown_policy?: "allow" | "force_best";
output?: ClassifyOutputOptions;
wait_seconds?: number;
idempotency_key?: string;
},
): Promise<Job>
| Parameter | Type | Required | Description |
|---|---|---|---|
source | upload, URL, workspace file | Yes | Original file — not a parse_result |
opts.classes | ClassifyClass[] | Yes | Labels to choose from |
opts.granularity | "document" / "page" | No | Default document |
opts.page_ranges | PageRange[] | No | Inclusive 1-indexed ranges |
opts.unknown_policy | "allow" / "force_best" | No | Default allow |
opts.output | ClassifyOutputOptions | No | Alternatives and reasons |
opts.wait_seconds | number | No | Hold the HTTP response open (max 300) |
Job. On success, result.units is one row per document or page range.
Confidence is the fraction of the unit assigned that label, not a calibrated
probability.
See Classify guide.