Skip to content

GCP.DocumentAI reference

Source: src/GCP/DocumentAI/GetProcessor.ts

Runtime binding for Document AI processors.get.

Bind this operation to a Processor in a Function/Action init phase. Provide GetProcessorHttp.

const getProcessor = yield* GCP.DocumentAI.GetProcessor(processor);
const live = yield* getProcessor();

Source: src/GCP/DocumentAI/GetProcessorHttp.ts Kind: Layer · Provides: GCP.DocumentAI.GetProcessor

HTTP implementation of GetProcessor.

Source: src/GCP/DocumentAI/GetSchema.ts

Runtime binding for Document AI schemas.get.

Bind this operation to a Schema in a Function/Action init phase. Provide GetSchemaHttp.

const getSchema = yield* GCP.DocumentAI.GetSchema(schema);
const live = yield* getSchema();

Source: src/GCP/DocumentAI/GetSchemaHttp.ts Kind: Layer · Provides: GCP.DocumentAI.GetSchema

HTTP implementation of GetSchema.

Source: src/GCP/DocumentAI/GetSchemaVersion.ts

Runtime binding for Document AI schemaVersions.get.

Bind this operation to a SchemasSchemaVersion in a Function/Action init phase. Provide GetSchemaVersionHttp.

GetSchemaVersion: Reading a Schema Version

Section titled “GetSchemaVersion: Reading a Schema Version”
const getVersion = yield* GCP.DocumentAI.GetSchemaVersion(version);
const live = yield* getVersion();

Source: src/GCP/DocumentAI/GetSchemaVersionHttp.ts Kind: Layer · Provides: GCP.DocumentAI.GetSchemaVersion

HTTP implementation of GetSchemaVersion.

Source: src/GCP/DocumentAI/Process.ts

Runtime binding for Document AI processors.process.

Bind this operation to a Processor in a Function/Action init phase. Provide ProcessHttp.

const process = yield* GCP.DocumentAI.Process(processor);
const result = yield* process({
body: {
rawDocument: {
content: pdfBase64,
mimeType: "application/pdf",
},
skipHumanReview: true,
},
});

Source: src/GCP/DocumentAI/ProcessHttp.ts Kind: Layer · Provides: GCP.DocumentAI.Process

HTTP implementation of Process.

Source: src/GCP/DocumentAI/Processor.ts

A Document AI processor that extracts structure from documents.

Processors are location-scoped. The API assigns the processor id. Type, location, KMS key, and display name are immutable (there is no processor patch RPC). Enable / disable and the default processor version update in place. Processors have no labels, so Alchemy stamps ownership into displayName for list / nuke.

OCR processor

const processor = yield* GCP.DocumentAI.Processor("Ocr", {
type: "OCR_PROCESSOR",
displayName: "ocr",
});

Explicit location

const processor = yield* GCP.DocumentAI.Processor("Ocr", {
location: "us",
type: "OCR_PROCESSOR",
});
// Same logical id, changed props: the engine updates it in place.
const processor = yield* GCP.DocumentAI.Processor("Ocr", {
location: "us",
type: "OCR_PROCESSOR",
enabled: false,
});

Source: src/GCP/DocumentAI/Schema.ts

A Document AI schema — a collection of schema versions describing extraction output.

Schemas are location-scoped. The API assigns the schema id. Location is immutable; display name and labels update in place.

const schema = yield* GCP.DocumentAI.Schema("Invoice", {
displayName: "invoice",
labels: { env: "test" },
});
// Same logical id, changed props: the engine updates it in place.
const schema = yield* GCP.DocumentAI.Schema("Invoice", {
displayName: "invoice-v2",
labels: { env: "prod" },
});

Source: src/GCP/DocumentAI/SchemasSchemaVersion.ts

A Document AI schema version — an immutable snapshot of a document schema under a Schema.

Parent schema, version id, and the document schema body are immutable. Display name and labels update in place.

SchemasSchemaVersion: Creating a Schema Version

Section titled “SchemasSchemaVersion: Creating a Schema Version”
const version = yield* GCP.DocumentAI.SchemasSchemaVersion("V1", {
schema: schema.name,
displayName: "v1",
documentSchema: {
displayName: "invoice",
entityTypes: [
{
name: "invoice",
baseTypes: ["document"],
properties: [
{
name: "invoice_id",
valueType: "string",
occurrenceType: "OPTIONAL_ONCE",
},
],
},
],
},
});