Managing processor versions

New versions are released for a variety of reasons, for example, to improve accuracy,increase availability, and support new document elements, such as selection marks.

Given that Document AI is powered by generative AI, future versions are usingnew foundation models so you can benefit from generative AI enhancements.

As we improve foundation models,earlier foundation models are deprecated.Similarly, processor versions are deprecated six months after new versions arereleased.

A processor can have one of the followingversions:

This page describes how processors are versioned, and how to view and selecta particular version.

managing-processor-versions-1

Processor versions overview

There are two categories of processor versions:

  • Google versions are either stable (for production use cases) or releasecandidates (experimental with latest functionality).
  • User versions are created by you to customize predictions for your documentsand have alphanumeric version IDs.

Google versions

Each Google version is identified by aVersion ID, for examplepretrained-TYPE-vX.X-YYYY-MM-DD.Each processor version Google offers is named eitherGoogle Stable orGoogle Release Candidate (RC).

Google stable versions

Stable versions are production-quality and ready for use.

  • Google prioritizes stability of the processor behaviour, but still includescritical fixes.
  • Earlier Google stable versions are deprecated six months after the newest stableversion is released as depicted in the following figure.

managing-processor-versions-2

Google release candidates (RC)

Release candidates are experimental and are upgraded regularly with the latestfeatures. These are not production-quality versions, and their stabilitymay vary.

Customized versions

Customized versions are the processor versions that you can create based on yourdocuments to customize predictions.Customized versions have aType, which shows the kind of model used for predictions.If you create a version using a foundation model (either by creating a version orfine tuning), then the type isGenerative AI. If you create a processor versionby training a smaller, custom model (either model or template based), then thetype isCustom. If you create processor versions, you decide the name and ID.

Base versions

If you create a processor version, the "base version" shows which Google version powersyour customized user version. The base version dictates the lifecycle of your user version.You need to make decisions about how to manage the lifecycle of your customized user version.

Available stable processor versions

You can review the available stable processor versions for the differentprocessor types in the following tables.

Custom ExtractorRelease dateDeprecation date
pretrained-foundation-model-v1.4-2025-02-05February 5, 2025March 31, 2026
pretrained-foundation-model-v1.5-2025-05-05May 5, 2025Not applicable
pretrained-foundation-model-v1.5-pro-2025-06-20June 20, 2025Not applicable
Form ParserRelease dateDeprecation date
pretrained-form-parser-v1.0-2020-09-23September 23, 2020Not applicable
pretrained-form-parser-v2.0-2022-11-10November 10, 2022Not applicable
Layout ParserRelease dateDeprecation date
pretrained-layout-parser-v1.0-2024-06-03June 3, 2024Not applicable
Bank Statement ParserRelease dateDeprecation date
pretrained-bankstatement-v1.0-2021-08-08August 8, 2021Not applicable
pretrained-bankstatement-v1.1-2021-08-13August 13, 2021Not applicable
pretrained-bankstatement-v2.0-2021-12-10December 10, 2021Not applicable
pretrained-bankstatement-v3.0-2022-05-16May 16, 2022Not applicable
pretrained-bankstatement-v5.0-2023-12-06December 6, 2023Not applicable
W2 ParserRelease dateDeprecation date
pretrained-w2-v1.0-2020-10-01October 1, 2020March 31, 2024
pretrained-w2-v1.1-2022-01-27January 27, 2022March 31, 2024
pretrained-w2-v1.2-2022-01-28January 28, 2022Not applicable
pretrained-w2-v2.1-2022-06-08June 8, 2022Not applicable
US Passport ParserRelease dateDeprecation date
pretrained-us-passport-v1.0-2021-06-14June 14, 2021June 30, 2026
Utility ParserRelease dateDeprecation date
pretrained-utility-v1.1-2021-04-09April 9, 2021June 30, 2026
Identity Document Proofing ParserRelease dateDeprecation date
pretrained-id-proofing-v1.0-2022-10-03October 3, 2022Not applicable
Pay Slip ParserRelease dateDeprecation date
pretrained-paystub-v1.0-2021-03-19March 19, 2021Not applicable
pretrained-paystub-v1.1-2021-08-13August 13, 2021Not applicable
pretrained-paystub-v1.2-2021-12-10December 10, 2021Not applicable
pretrained-paystub-v2.0-2022-07-22July 22, 2022Not applicable
pretrained-paystub-v3.0-2023-12-06December 6, 2023Not applicable
US Driver License ParserRelease dateDeprecation date
pretrained-us-driver-license-v1.0-2021-06-14June 14, 2021Not applicable
Expense ParserRelease dateDeprecation date
pretrained-expense-v1.1-2021-04-09April 9, 2024Not applicable
pretrained-expense-v1.4-2022-11-18November 18, 2022Not applicable
pretrained-expense-v1.4.2-2024-09-12September 12, 2024Not applicable
Invoice ParserRelease dateDeprecation date
pretrained-invoice-v1.1-2021-04-09April 9, 2024Not applicable
pretrained-invoice-v1.2-2022-02-18February 18, 2022Not applicable
pretrained-invoice-v1.3-2022-07-15July 15, 2022Not applicable
pretrained-invoice-v2.0-2023-12-06December 6, 2023Not applicable
SummarizerRelease dateDeprecation date
pretrained-foundation-model-v1.0-2023-08-22August 22, 2023June 30, 2026
Enterprise Document OCR (Optical Character Recognition)Release dateDeprecation date
pretrained-ocr-v1.2-2022-11-10November 10, 2022Not applicable
pretrained-ocr-v2.0-2023-06-02June 2, 2023Not applicable
pretrained-ocr-v2.1-2024-08-07August 7, 2024Not applicable

managing-processor-versions-3

Processor version lifecycle

As soon as a new Google version is available, you shouldcreate and evaluate new user versionswith the new base version. Then, deploy your new version and undeploy (or delete)earlier user versions that use the prior stable version as their base. Stableversions are discontinued after a new one is released. Google gives you at leastsix months' notice when this occurs.

What happens when a base version is deprecated?

User versions depending on earlier base versions stop returning predictions whenthe base version is deprecated.

How are processor versions selected for your requests?

When you call a processor endpoint without specifying the processor version, thedefault processor version is used. When the default processor version changes,you might need to update the code.

Endpoint usedExperience
If you do not specify a processor version IDRequests processed using a new default processor version.
If your default processor version is deprecated, the default updates to the most recently launched stable Google version when the older default version is deprecated.
If you specify the processor version IDThe response fails if you call a processor endpoint and specify a version ID which has been deprecated.

Note: We recommend you to not specify the processor version ID in your productionrequests to process documents. Instead, we recommend you to call the processor'sendpoint and rely on the default processor to control which version processesrequests. This helps you to upgrade and benefit from automatic default versionupdates. See how tochange the default version.

Deprecation example of a customized version

Consider the following scenario that describes the sequence of events in acustomized version deprecation:

  1. As a developer, you're using a Custom Extractor to get data from documents.Given the complexity and volume of documents you process, you fine tune thefoundation model to create a version namedfine-tune-A. You set thefine-tune-A version as the default version for your processor and use it toprocess documents. The base version that powers thefine-tune-A model is thepretrained-foundation-model-v1.0-2023-08-22 (v1.0) stable version.

  2. Google published a new stable version namedpretrained-foundation-model-v1.2-2024-05-10 (v1.2)and announced that thev1.0 stable version is to be deprecated on April 9, 2025.

  3. Since you kept your training and test documents in your processor's dataset,you fine-tune another version based on the newest Google stable version,v1.2,and name itfine-tune-B. After you evaluate its performance, you set thefine-tune-B version as the new default version for your processor anddecommission thefine-tune-A version. Your new version now uses the latest supported Google stable version.

On the other hand, had you not created and evaluated the customizedfine-tune-Bversion, then Google would have updated the default version of your processor tov1.2 on April 9, 2025. Because you are calling the processor's endpoint and notspecifying a processor version, the newv1.2 version is used as the new defaultto process your requests.

Deprecation and migration resources

For deprecated parsers and processors, you can consultDocument AI deprecations.

See the following resources for migrations:

Select a processor version

There are three ways to specify which processor version to use for online and batch processing:

  • If youdo not specify a version, the processor's default is used.

    • Example:projects/my-proj/locations/us/processors/my-processor:process
  • If youspecify a version, then that specific version is used. If thespecific version does not exist, the request fails with an error.

    • Example:projects/my-proj/locations/us/processors/my-processor/processorVersions/pretrained-invoice-v1.2-2022-02-18:process
  • If youspecify a channel then the latest version in that channel isused. (Options:stable,rc)

    • Example:projects/my-proj/locations/us/processors/my-processor/processorVersions/stable:process

View available version

Note: Some processors have only one version.

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to Processors

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. Select theManage Versions (orDeploy & use) tab, which will display all of the availableprocessor versions.

REST

This sample shows how to list the available processor versions for yourprocessor using theprocessorVersions.list method.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.

HTTP method and URL:

GET https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions" | Select-Object -Expand Content

The response contains a list ofProcessorVersions, which contains information about each processor version such as itsname,state, and other details.

{  "processorVersions": [    {      "name": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/pretrained-ocr-v1.1-2022-09-12",      "displayName": "Google Release Candidate",      "state": "DEPLOYED",      "createTime": "2022-09-13T23:39:12.156648Z",      "googleManaged": true    },    {      "name": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/pretrained-ocr-v1.0-2020-09-23",      "displayName": "Google Stable",      "state": "DEPLOYED",      "createTime": "2022-09-12T23:35:09.829557Z",      "googleManaged": true,      "deprecationInfo": {        "deprecationTime": "1970-01-01T00:00:00Z"      }    }  ]}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Api.Gax;usingGoogle.Cloud.DocumentAI.V1;usingSystem;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for ListProcessorVersions</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidListProcessorVersionsRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)ListProcessorVersionsRequestrequest=newListProcessorVersionsRequest{ParentAsProcessorName=ProcessorName.FromProjectLocationProcessor("[PROJECT]","[LOCATION]","[PROCESSOR]"),};// Make the requestPagedEnumerable<ListProcessorVersionsResponse,ProcessorVersion>response=documentProcessorServiceClient.ListProcessorVersions(request);// Iterate over all response items, lazily performing RPCs as requiredforeach(ProcessorVersioniteminresponse){// Do something with each itemConsole.WriteLine(item);}// Or iterate over pages (of server-defined size), performing one RPC per pageforeach(ListProcessorVersionsResponsepageinresponse.AsRawResponses()){// Do something with each page of itemsConsole.WriteLine("A page of results:");foreach(ProcessorVersioniteminpage){// Do something with each itemConsole.WriteLine(item);}}// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as requiredintpageSize=10;Page<ProcessorVersion>singlePage=response.ReadPage(pageSize);// Do something with the page of itemsConsole.WriteLine($"A page of {pageSize} results (unless it's the final page):");foreach(ProcessorVersioniteminsinglePage){// Do something with each itemConsole.WriteLine(item);}// Store the pageToken, for when the next page is required.stringnextPageToken=singlePage.NextPageToken;}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.ListProcessorVersionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#ListProcessorVersionsRequest.}it:=c.ListProcessorVersions(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*documentaipb.ListProcessorVersionsResponse)}}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.ListProcessorVersionsRequest;importcom.google.cloud.documentai.v1.ProcessorName;importcom.google.cloud.documentai.v1.ProcessorVersion;publicclassSyncListProcessorVersions{publicstaticvoidmain(String[]args)throwsException{syncListProcessorVersions();}publicstaticvoidsyncListProcessorVersions()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){ListProcessorVersionsRequestrequest=ListProcessorVersionsRequest.newBuilder().setParent(ProcessorName.of("[PROJECT]","[LOCATION]","[PROCESSOR]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();for(ProcessorVersionelement:documentProcessorServiceClient.listProcessorVersions(request).iterateAll()){// doThingsWith(element);}}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sampledeflist_processor_versions_sample(project_id:str,location:str,processor_id:str)->None:# You must set the `api_endpoint` if you use a location other than "us".opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor# e.g.: projects/project_id/locations/location/processors/processor_idparent=client.processor_path(project_id,location,processor_id)# Make ListProcessorVersions requestprocessor_versions=client.list_processor_versions(parent=parent)# Print the processor version informationforprocessor_versioninprocessor_versions:processor_version_id=client.parse_processor_version_path(processor_version.name)["processor_version"]print(f"Processor Version:{processor_version_id}")print(f"Display Name:{processor_version.display_name}")print(f"DEPLOYED:{processor_version.state}")print("")

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the list_processor_versions call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#list_processor_versions.#deflist_processor_versions# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::ListProcessorVersionsRequest.new# Call the list_processor_versions method.result=client.list_processor_versionsrequest# The returned object is of type Gapic::PagedEnumerable. You can iterate# over elements, and API calls will be issued to fetch pages as needed.result.eachdo|item|# Each element is of type ::Google::Cloud::DocumentAI::V1::ProcessorVersion.pitemendend

View details about a version

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to Processors

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. Select theManage Versions (orDeploy & use) tab, which will displayall of the available processor versions and their details.

REST

This sample shows how to get details about a processor version for yourprocessor using theprocessorVersions.getmethod.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.
  • PROCESSOR_VERSION: the processor version identifier. Refer toSelect a processor version for more information. For example:
    • pretrained-TYPE-vX.X-YYYY-MM-DD
    • stable
    • rc

HTTP method and URL:

GET https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION" | Select-Object -Expand Content

The response is aProcessorVersion, which contains information about the processor version such as itsname,state, and other details.

{  "name": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/pretrained-ocr-v1.1-2022-09-12",  "displayName": "Google Release Candidate",  "state": "DEPLOYED",  "createTime": "2022-09-13T23:39:12.156648Z",  "googleManaged": true}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Cloud.DocumentAI.V1;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for GetProcessorVersion</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidGetProcessorVersionRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)GetProcessorVersionRequestrequest=newGetProcessorVersionRequest{ProcessorVersionName=ProcessorVersionName.FromProjectLocationProcessorProcessorVersion("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]"),};// Make the requestProcessorVersionresponse=documentProcessorServiceClient.GetProcessorVersion(request);}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.GetProcessorVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#GetProcessorVersionRequest.}resp,err:=c.GetProcessorVersion(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.GetProcessorVersionRequest;importcom.google.cloud.documentai.v1.ProcessorVersion;importcom.google.cloud.documentai.v1.ProcessorVersionName;publicclassSyncGetProcessorVersion{publicstaticvoidmain(String[]args)throwsException{syncGetProcessorVersion();}publicstaticvoidsyncGetProcessorVersion()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){GetProcessorVersionRequestrequest=GetProcessorVersionRequest.newBuilder().setName(ProcessorVersionName.of("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]").toString()).build();ProcessorVersionresponse=documentProcessorServiceClient.getProcessorVersion(request);}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sample# processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'defget_processor_version_sample(project_id:str,location:str,processor_id:str,processor_version_id:str)->None:# You must set the api_endpoint if you use a location other than 'us'.opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor version# e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_idname=client.processor_version_path(project_id,location,processor_id,processor_version_id)# Make GetProcessorVersion requestprocessor_version=client.get_processor_version(name=name)# Print the processor version informationprint(f"Processor Version:{processor_version_id}")print(f"Display Name:{processor_version.display_name}")print(f"DEPLOYED:{processor_version.state}")

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the get_processor_version call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#get_processor_version.#defget_processor_version# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::GetProcessorVersionRequest.new# Call the get_processor_version method.result=client.get_processor_versionrequest# The returned object is of type Google::Cloud::DocumentAI::V1::ProcessorVersion.presultend

Change the default version

A processor'sdefault version specifies the version that is used toprocess documents when you don't specify a specific version.When youcreate a processor, the initialdefault version is the latest version in the stable channel.

If you change the default version, incoming requests are processed using the newlyselected version. If you change the default version while the processor is in themiddle of a request, the request will continue to use the previously selected version.

To change the default version:

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to the Processors page

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. In the processor'sManage Versions (orDeploy & use) tab, in theDefault versiondropdown menu, choose a version of the processor that you want to use asthe default version.

REST

This sample shows how to set the default processor version for yourprocessor using theprocessors.setDefaultProcessorVersionmethod.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.
  • PROCESSOR_VERSION: the processor version identifier. Refer toSelect a processor version for more information. For example:
    • pretrained-TYPE-vX.X-YYYY-MM-DD
    • stable
    • rc

HTTP method and URL:

POST https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID:setDefaultProcessorVersion

Request JSON body:

{  "defaultProcessorVersion": "PROCESSOR_VERSION"}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID:setDefaultProcessorVersion"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID:setDefaultProcessorVersion" | Select-Object -Expand Content

The response is along running operation. To poll the long-running operation, calloperations.get

TheSetDefaultProcessorVersionMetadata in the response indicates the state of the operation.

{  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION",  "metadata": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.SetDefaultProcessorVersionMetadata",    "commonMetadata": {      "state": "SUCCEEDED",      "createTime": "2022-03-02T22:52:49.957096Z",      "updateTime": "2022-03-02T22:52:50.175976Z",      "resource": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"    }  },  "done": true,  "response": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.SetDefaultProcessorVersionResponse"  }}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Cloud.DocumentAI.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for SetDefaultProcessorVersion</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidSetDefaultProcessorVersionRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)SetDefaultProcessorVersionRequestrequest=newSetDefaultProcessorVersionRequest{ProcessorAsProcessorName=ProcessorName.FromProjectLocationProcessor("[PROJECT]","[LOCATION]","[PROCESSOR]"),DefaultProcessorVersionAsProcessorVersionName=ProcessorVersionName.FromProjectLocationProcessorProcessorVersion("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]"),};// Make the requestOperation<SetDefaultProcessorVersionResponse,SetDefaultProcessorVersionMetadata>response=documentProcessorServiceClient.SetDefaultProcessorVersion(request);// Poll until the returned long-running operation is completeOperation<SetDefaultProcessorVersionResponse,SetDefaultProcessorVersionMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultSetDefaultProcessorVersionResponseresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<SetDefaultProcessorVersionResponse,SetDefaultProcessorVersionMetadata>retrievedResponse=documentProcessorServiceClient.PollOnceSetDefaultProcessorVersion(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultSetDefaultProcessorVersionResponseretrievedResult=retrievedResponse.Result;}}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.SetDefaultProcessorVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#SetDefaultProcessorVersionRequest.}op,err:=c.SetDefaultProcessorVersion(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.ProcessorName;importcom.google.cloud.documentai.v1.ProcessorVersionName;importcom.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest;importcom.google.cloud.documentai.v1.SetDefaultProcessorVersionResponse;publicclassSyncSetDefaultProcessorVersion{publicstaticvoidmain(String[]args)throwsException{syncSetDefaultProcessorVersion();}publicstaticvoidsyncSetDefaultProcessorVersion()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){SetDefaultProcessorVersionRequestrequest=SetDefaultProcessorVersionRequest.newBuilder().setProcessor(ProcessorName.of("[PROJECT]","[LOCATION]","[PROCESSOR]").toString()).setDefaultProcessorVersion(ProcessorVersionName.of("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]").toString()).build();SetDefaultProcessorVersionResponseresponse=documentProcessorServiceClient.setDefaultProcessorVersionAsync(request).get();}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.api_core.exceptionsimportNotFoundfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sample# processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'defset_default_processor_version_sample(project_id:str,location:str,processor_id:str,processor_version_id:str)->None:# You must set the api_endpoint if you use a location other than 'us'.opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor# e.g.: projects/project_id/locations/location/processors/processor_idprocessor=client.processor_path(project_id,location,processor_id)# The full resource name of the processor version# e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_idprocessor_version=client.processor_version_path(project_id,location,processor_id,processor_version_id)request=documentai.SetDefaultProcessorVersionRequest(processor=processor,default_processor_version=processor_version)# Make SetDefaultProcessorVersion requesttry:operation=client.set_default_processor_version(request)# Print operation detailsprint(operation.operation.name)# Wait for operation to completeoperation.result()exceptNotFoundase:print(e.message)

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the set_default_processor_version call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#set_default_processor_version.#defset_default_processor_version# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::SetDefaultProcessorVersionRequest.new# Call the set_default_processor_version method.result=client.set_default_processor_versionrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend

Deploy a processor version

Aftercreating a new processor versionwith Document AI, you will need to deploy it before you can process documentswith this version.

Note: You cannot change the deployment status for pretrained processor versionsor the current default version.

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to the Processors page

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. In the processor'sManage Versions (orDeploy & use) tab, select thecheckbox next to the processor version you want to deploy.

  4. ClickDeploy, then again clickDeploy on the dialog window. Thisprocess takes a few minutes.

REST

This sample shows how to deploy a processor version for yourprocessor using theprocessorVersions.deploymethod.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.
  • PROCESSOR_VERSION: the processor version identifier.

HTTP method and URL:

POST https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:deploy

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:deploy"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:deploy" | Select-Object -Expand Content

The response is along running operation. To poll the long-running operation, calloperations.get

TheDeployProcessorVersionMetadata in the response indicates the state of the operation.

{  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION",  "metadata": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.DeployProcessorVersionMetadata",    "commonMetadata": {      "state": "SUCCEEDED",      "createTime": "2022-08-29T16:27:00.195539Z",      "updateTime": "2022-08-29T16:32:01.963962Z",      "resource": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"    }  },  "done": true,  "response": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.DeployProcessorVersionResponse"  }}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Cloud.DocumentAI.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for DeployProcessorVersion</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidDeployProcessorVersionRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)DeployProcessorVersionRequestrequest=newDeployProcessorVersionRequest{ProcessorVersionName=ProcessorVersionName.FromProjectLocationProcessorProcessorVersion("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]"),};// Make the requestOperation<DeployProcessorVersionResponse,DeployProcessorVersionMetadata>response=documentProcessorServiceClient.DeployProcessorVersion(request);// Poll until the returned long-running operation is completeOperation<DeployProcessorVersionResponse,DeployProcessorVersionMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultDeployProcessorVersionResponseresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<DeployProcessorVersionResponse,DeployProcessorVersionMetadata>retrievedResponse=documentProcessorServiceClient.PollOnceDeployProcessorVersion(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultDeployProcessorVersionResponseretrievedResult=retrievedResponse.Result;}}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.DeployProcessorVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#DeployProcessorVersionRequest.}op,err:=c.DeployProcessorVersion(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DeployProcessorVersionRequest;importcom.google.cloud.documentai.v1.DeployProcessorVersionResponse;importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.ProcessorVersionName;publicclassSyncDeployProcessorVersion{publicstaticvoidmain(String[]args)throwsException{syncDeployProcessorVersion();}publicstaticvoidsyncDeployProcessorVersion()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){DeployProcessorVersionRequestrequest=DeployProcessorVersionRequest.newBuilder().setName(ProcessorVersionName.of("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]").toString()).build();DeployProcessorVersionResponseresponse=documentProcessorServiceClient.deployProcessorVersionAsync(request).get();}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.api_core.exceptionsimportFailedPreconditionfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID'# processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'defdeploy_processor_version_sample(project_id:str,location:str,processor_id:str,processor_version_id:str)->None:# You must set the api_endpoint if you use a location other than 'us'.opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor version# e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_idname=client.processor_version_path(project_id,location,processor_id,processor_version_id)# Make DeployProcessorVersion requesttry:operation=client.deploy_processor_version(name=name)# Print operation detailsprint(operation.operation.name)# Wait for operation to completeoperation.result()# Deploy request will fail if the# processor version is already deployedexceptFailedPreconditionase:print(e.message)

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the deploy_processor_version call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#deploy_processor_version.#defdeploy_processor_version# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::DeployProcessorVersionRequest.new# Call the deploy_processor_version method.result=client.deploy_processor_versionrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend

Undeploy a processor version

Aftercreating a new processor versionwith Document AI and deploying it, you can undeploy it if you don't want theprocessor version to be able to handle processing requests.

Note: You cannot change the deployment status for pretrained processor versionsor the current default version.

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to the Processors page

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. In the processor'sManage Versions (orDeploy & use) tab, select thecheckbox next to the processor version you want to undeploy.

  4. ClickUndeploy, then again clickUndeploy on the dialog window.This process takes a few minutes.

REST

This sample shows how to undeploy a processor version for your processor using theprocessorVersions.undeploymethod.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.
  • PROCESSOR_VERSION: the processor version identifier.

HTTP method and URL:

POST https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:undeploy

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:undeploy"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION:undeploy" | Select-Object -Expand Content

The response is along running operation. To poll the long-running operation, calloperations.get

TheUndeployProcessorVersionMetadata in the response indicates the state of the operation.

{  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION",  "metadata": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.UndeployProcessorVersionMetadata",    "commonMetadata": {      "state": "SUCCEEDED",      "createTime": "2022-08-29T16:27:00.195539Z",      "updateTime": "2022-08-29T16:32:01.963962Z",      "resource": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"    }  },  "done": true,  "response": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.UndeployProcessorVersionResponse"  }}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Cloud.DocumentAI.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for UndeployProcessorVersion</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidUndeployProcessorVersionRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)UndeployProcessorVersionRequestrequest=newUndeployProcessorVersionRequest{ProcessorVersionName=ProcessorVersionName.FromProjectLocationProcessorProcessorVersion("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]"),};// Make the requestOperation<UndeployProcessorVersionResponse,UndeployProcessorVersionMetadata>response=documentProcessorServiceClient.UndeployProcessorVersion(request);// Poll until the returned long-running operation is completeOperation<UndeployProcessorVersionResponse,UndeployProcessorVersionMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultUndeployProcessorVersionResponseresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<UndeployProcessorVersionResponse,UndeployProcessorVersionMetadata>retrievedResponse=documentProcessorServiceClient.PollOnceUndeployProcessorVersion(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultUndeployProcessorVersionResponseretrievedResult=retrievedResponse.Result;}}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.UndeployProcessorVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#UndeployProcessorVersionRequest.}op,err:=c.UndeployProcessorVersion(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.ProcessorVersionName;importcom.google.cloud.documentai.v1.UndeployProcessorVersionRequest;importcom.google.cloud.documentai.v1.UndeployProcessorVersionResponse;publicclassSyncUndeployProcessorVersion{publicstaticvoidmain(String[]args)throwsException{syncUndeployProcessorVersion();}publicstaticvoidsyncUndeployProcessorVersion()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){UndeployProcessorVersionRequestrequest=UndeployProcessorVersionRequest.newBuilder().setName(ProcessorVersionName.of("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]").toString()).build();UndeployProcessorVersionResponseresponse=documentProcessorServiceClient.undeployProcessorVersionAsync(request).get();}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.api_core.exceptionsimportFailedPreconditionfromgoogle.api_core.exceptionsimportInvalidArgumentfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sample# processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'defundeploy_processor_version_sample(project_id:str,location:str,processor_id:str,processor_version_id:str)->None:# You must set the api_endpoint if you use a location other than 'us'.opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor version# e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_idname=client.processor_version_path(project_id,location,processor_id,processor_version_id)# Make UndeployProcessorVersion requesttry:operation=client.undeploy_processor_version(name=name)# Print operation detailsprint(operation.operation.name)# Wait for operation to completeoperation.result()# Undeploy request will fail if the# processor version is already undeployed# or if a request is made on a pretrained processor versionexcept(FailedPrecondition,InvalidArgument)ase:print(e.message)

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the undeploy_processor_version call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#undeploy_processor_version.#defundeploy_processor_version# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::UndeployProcessorVersionRequest.new# Call the undeploy_processor_version method.result=client.undeploy_processor_versionrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend

Delete a processor version

Aftercreating a new processor versionwith Document AI, you can delete it if you have no further use for the processorversion.

Note: You cannot delete pretrained processor versions or the current default version.

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to the Processors page

  2. From the list of processors, click the name of the processor that youwant to view details for.

  3. In the processor'sManage Versions (orDeploy & use) tab, click theaction menu next to the processor version you want to delete.

  4. ClickDelete, then again clickDelete on the dialog window.

REST

This sample shows how to delete a processor version for your processor using theprocessorVersions.deletemethod.

Before using any of the request data, make the following replacements:

  • LOCATION: your processor'slocation, for example:
    • us - United States
    • eu - European Union
  • PROJECT_ID: Your Google Cloud project ID.
  • PROCESSOR_ID: the ID of your custom processor.
  • PROCESSOR_VERSION: the processor version identifier.

HTTP method and URL:

DELETE https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION" | Select-Object -Expand Content

The response is along running operation. To poll the long-running operation, calloperations.get

TheDeleteProcessorVersionMetadata in the response indicates the state of the operation.

{  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION",  "metadata": {    "@type": "type.googleapis.com/google.cloud.documentai.v1.DeleteProcessorVersionMetadata",    "commonMetadata": {      "state": "SUCCEEDED",      "createTime": "2022-08-29T16:27:00.195539Z",      "updateTime": "2022-08-29T16:32:01.963962Z",      "resource": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION"    }  },  "done": true,  "response": {    "@type": "type.googleapis.com/google.protobuf.Empty"  }}

C#

For more information, see theDocument AIC# API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

usingGoogle.Cloud.DocumentAI.V1;usingGoogle.LongRunning;usingGoogle.Protobuf.WellKnownTypes;publicsealedpartialclassGeneratedDocumentProcessorServiceClientSnippets{/// <summary>Snippet for DeleteProcessorVersion</summary>/// <remarks>/// This snippet has been automatically generated and should be regarded as a code template only./// It will require modifications to work:/// - It may require correct/in-range values for request initialization./// - It may require specifying regional endpoints when creating the service client as shown in///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint./// </remarks>publicvoidDeleteProcessorVersionRequestObject(){// Create clientDocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.Create();// Initialize request argument(s)DeleteProcessorVersionRequestrequest=newDeleteProcessorVersionRequest{ProcessorVersionName=ProcessorVersionName.FromProjectLocationProcessorProcessorVersion("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]"),};// Make the requestOperation<Empty,DeleteProcessorVersionMetadata>response=documentProcessorServiceClient.DeleteProcessorVersion(request);// Poll until the returned long-running operation is completeOperation<Empty,DeleteProcessorVersionMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultEmptyresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<Empty,DeleteProcessorVersionMetadata>retrievedResponse=documentProcessorServiceClient.PollOnceDeleteProcessorVersion(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultEmptyretrievedResult=retrievedResponse.Result;}}}

Go

For more information, see theDocument AIGo API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

packagemainimport("context"documentai"cloud.google.com/go/documentai/apiv1"documentaipb"cloud.google.com/go/documentai/apiv1/documentaipb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=documentai.NewDocumentProcessorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&documentaipb.DeleteProcessorVersionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/documentai/apiv1/documentaipb#DeleteProcessorVersionRequest.}op,err:=c.DeleteProcessorVersion(ctx,req)iferr!=nil{// TODO: Handle error.}err=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}}

Java

For more information, see theDocument AIJava API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

importcom.google.cloud.documentai.v1.DeleteProcessorVersionRequest;importcom.google.cloud.documentai.v1.DocumentProcessorServiceClient;importcom.google.cloud.documentai.v1.ProcessorVersionName;importcom.google.protobuf.Empty;publicclassSyncDeleteProcessorVersion{publicstaticvoidmain(String[]args)throwsException{syncDeleteProcessorVersion();}publicstaticvoidsyncDeleteProcessorVersion()throwsException{// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DocumentProcessorServiceClientdocumentProcessorServiceClient=DocumentProcessorServiceClient.create()){DeleteProcessorVersionRequestrequest=DeleteProcessorVersionRequest.newBuilder().setName(ProcessorVersionName.of("[PROJECT]","[LOCATION]","[PROCESSOR]","[PROCESSOR_VERSION]").toString()).build();documentProcessorServiceClient.deleteProcessorVersionAsync(request).get();}}}

Python

For more information, see theDocument AIPython API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

fromgoogle.api_core.client_optionsimportClientOptionsfromgoogle.api_core.exceptionsimportFailedPreconditionfromgoogle.api_core.exceptionsimportInvalidArgumentfromgoogle.cloudimportdocumentai# type: ignore# TODO(developer): Uncomment these variables before running the sample.# project_id = 'YOUR_PROJECT_ID'# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'# processor_id = 'YOUR_PROCESSOR_ID' # Create processor before running sample# processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'defdelete_processor_version_sample(project_id:str,location:str,processor_id:str,processor_version_id:str)->None:# You must set the api_endpoint if you use a location other than 'us'.opts=ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")client=documentai.DocumentProcessorServiceClient(client_options=opts)# The full resource name of the processor version# e.g.: projects/project_id/locations/location/processors/processor_id/processorVersions/processor_version_idname=client.processor_version_path(project_id,location,processor_id,processor_version_id)# Make DeleteProcessorVersion requesttry:operation=client.delete_processor_version(name=name)# Print operation detailsprint(operation.operation.name)# Wait for operation to completeoperation.result()# Delete request will fail if the# processor version doesn't exist# or if a request is made on a pretrained processor version# or the default processor versionexcept(FailedPrecondition,InvalidArgument)ase:print(e.message)

Ruby

For more information, see theDocument AIRuby API reference documentation.

To authenticate to Document AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.

require"google/cloud/document_ai/v1"### Snippet for the delete_processor_version call in the DocumentProcessorService service## This snippet has been automatically generated and should be regarded as a code# template only. It will require modifications to work:# - It may require correct/in-range values for request initialization.# - It may require specifying regional endpoints when creating the service# client as shown in https://cloud.google.com/ruby/docs/reference.## This is an auto-generated example demonstrating basic usage of# Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client#delete_processor_version.#defdelete_processor_version# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::DocumentAI::V1::DeleteProcessorVersionRequest.new# Call the delete_processor_version method.result=client.delete_processor_versionrequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend

Import a processor version

Aftercreating a new processor with Document AI, you can import aprocessor version from the same or a different project.

Thedestination project is where you begin the import and where the processor version becomes available after the import.

Thesource project is where the source processor version lives.

Note: Processor version import is not supported for destination projects operatinginsingle-region locations, except forasia-south1,andnorthamerica-northeast1.

The source or destination processors must meet the following requirements to import:

  • Processor types must match. Examples:CUSTOM_EXTRACTION_PROCESSOR orINVOICE_PROCESSOR
  • Processor schemas must not conflict.
  • Destination processor can have existing datasets and versions.
  • Destination processor must be inENABLED state.
  • Source processor version must be in one of the following states:
    • DEPLOYED
    • DEPLOYING
    • UNDEPLOYED
    • UNDEPLOYING

You must grant theDocumentAI Core Service Agent ofthe destination projectDocument AI Editorpermission on the source project to avoid a permission denied error.

Note: This applies if importing processor versions within the same project orbetween separate projects.

For processor versions based on Gemini 1.5 and later, such ascustom extractorspretrained-foundation-model-v1.2-2024-05-10, you can import fine-tunedprocessor versions.

Complete the following steps to set up permission before importing a processor version:

Console

  1. Look upDocumentAI Core Service Agent and fill inyour destination project number. The DocumentAI Core Service Agent is formattedlike an email address. For example:service-123@gcp-sa-prod-dai-core.iam.gserviceaccount.com

  2. Open the IAM page in the Google Cloud console.

    Openthe IAM page

  3. Select your source project.

  4. Click grant access.

  5. Add the destination project's DocumentAI Core Service Agent as a new principal,and assignDocument AI Editor role.

gcloud

Use the followinggcloud command to grant the necessary permissions:

gcloudprojectsadd-iam-policy-bindingSOURCE_PROJECT\--member=serviceAccount:service-DESTINATION_PROJECTNUMBER@gcp-sa-prod-dai-core.iam.gserviceaccount.com\--role=roles/documentai.editor

Provide the following values:

  • SOURCE_PROJECT: The source project number or project id.
  • DESTINATION_PROJECT NUMBER: The destination projectnumber.

After updating the permissions, use the following steps to import a processor version:

Console

  1. In the Google Cloud console, in the Document AI section, go to theProcessors page.

    Go to the Processors page

  2. From the list of processors, click the name of the processor that youwant to import a processor version to as a destination processor.

  3. Go to theManage Versions (orDeploy & use) tab, and clickImport.

  4. Choose the project, the processor, and the processor version as the sourceprocessor version in the window.

  5. ClickIMPORT button in the window, and the import operation will start.

REST

This sample shows you how to use theprocessorVersions.importProcessorVersionmethod to import a processor version.

Before using any of the request data, make the following replacements:

  • Destination Project
    • DESTINATION_PROJECT_ID: your destination Google Cloud project ID.
    • DESTINATION_LOCATION: your destination processor'slocation.
    • DESTINATION_PROCESSOR_ID: the ID of your destination processor.
  • Source Project
    • SOURCE_PROJECT_ID: your source Google Cloud project ID.
    • SOURCE_LOCATION: the source processor's location.
    • SOURCE_PROCESSOR_ID: the ID of your source processor.
    • SOURCE_PROCESSOR_VERSION: the source processor version to import.

HTTP method and URL:

POST https://DESTINATION_LOCATION-documentai.googleapis.com/v1beta3/projects/DESTINATION_PROJECT_ID/locations/DESTINATION_LOCATION/processors/DESTINATION_PROCESSOR_ID/processorVersions:importProcessorVersion

Request JSON body:

{  "processorVersionSource": "projects/SOURCE_PROJECT_ID/locations/SOURCE_LOCATION/processors/SOURCE_PROCESSOR_ID/processorVersions/SOURCE_PROCESSOR_VERSION"}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://DESTINATION_LOCATION-documentai.googleapis.com/v1beta3/projects/DESTINATION_PROJECT_ID/locations/DESTINATION_LOCATION/processors/DESTINATION_PROCESSOR_ID/processorVersions:importProcessorVersion"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://DESTINATION_LOCATION-documentai.googleapis.com/v1beta3/projects/DESTINATION_PROJECT_ID/locations/DESTINATION_LOCATION/processors/DESTINATION_PROCESSOR_ID/processorVersions:importProcessorVersion" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "name": "projects/DESTINATION_PROJECT_ID/locations/DESTINATION_LOCATION/operations/OPERATION_ID"}

If you're importing across a Virtual Private Cloud service controls (VPC-SC) perimeter,reviewconfiguring ingress and egress policiesandset up a VPC Service Controls perimeter,then set the following rules.

Note: You must run a dummy fine tuning in the destination processor before importinga processor version. This will initialize the necessary resources for a fresh processor.

Provide the following values foringress:

  • DESTINATION_PROJECT: The destination project number.
  • SOURCE_PROJECT: The source project number.
- ingressFrom:    identities:    - ANY_SERVICE_ACCOUNT    sources:    - resource:DESTINATION_PROJECT  ingressTo:    operations:    - serviceName: aiplatform.googleapis.com      methodSelectors:      - method: all actions    - serviceName: documentai.googleapis.com      methodSelectors:      - method: all actions    resources:    - projects/SOURCE_PROJECT

Provide the following values foregress:

- egressTo:    operations:    - serviceName: storage.googleapis.com      methodSelectors:      - method: google.storage.objects.create      - method: google.storage.buckets.testIamPermissions    resources:    - projects/DESTINATION_PROJECT  egressFrom:    identities:    - ANY_SERVICE_ACCOUNT

Set up a VPC destination perimeter with the following values.

- egressTo:    operations:    - serviceName: aiplatform.googleapis.com      methodSelectors:      - method: all actions    - serviceName: documentai.googleapis.com      methodSelectors:      - method: all actions    - serviceName: storage.googleapis.com      methodSelectors:      - method: google.storage.buckets.testIamPermissions      - method: google.storage.objects.get      - method: google.storage.objects.create    resources:    - projects/SOURCE_PROJECT  egressFrom:    identities:    - ANY_SERVICE_ACCOUNT    sourceRestriction: DISABLED

What's next?

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.