diff --git a/documentai/snippets/batch_process_documents_sample_v1beta3.py b/documentai/snippets/batch_process_documents_sample_v1beta3.py index 134b9355ab9a..b1ed32262000 100644 --- a/documentai/snippets/batch_process_documents_sample_v1beta3.py +++ b/documentai/snippets/batch_process_documents_sample_v1beta3.py @@ -38,7 +38,12 @@ def batch_process_documents( timeout: int = 300, ): - client = documentai.DocumentProcessorServiceClient() + # You must set the api_endpoint if you use a location other than 'us', e.g.: + opts = {} + if location == "eu": + opts = {"api_endpoint": "eu-documentai.googleapis.com"} + + client = documentai.DocumentProcessorServiceClient(client_options=opts) destination_uri = f"{gcs_output_uri}/{gcs_output_uri_prefix}/" diff --git a/documentai/snippets/process_document_sample_v1beta3.py b/documentai/snippets/process_document_sample_v1beta3.py index 5b04570863c8..ab69d073e6d6 100644 --- a/documentai/snippets/process_document_sample_v1beta3.py +++ b/documentai/snippets/process_document_sample_v1beta3.py @@ -27,8 +27,12 @@ def process_document_sample( ): from google.cloud import documentai_v1beta3 as documentai - # Instantiates a client - client = documentai.DocumentProcessorServiceClient() + # You must set the api_endpoint if you use a location other than 'us', e.g.: + opts = {} + if location == "eu": + opts = {"api_endpoint": "eu-documentai.googleapis.com"} + + client = documentai.DocumentProcessorServiceClient(client_options=opts) # The full resource name of the processor, e.g.: # projects/project-id/locations/location/processor/processor-id diff --git a/documentai/snippets/quickstart_sample_v1beta3.py b/documentai/snippets/quickstart_sample_v1beta3.py index 37d44bb03fbe..884b412cf63c 100644 --- a/documentai/snippets/quickstart_sample_v1beta3.py +++ b/documentai/snippets/quickstart_sample_v1beta3.py @@ -25,7 +25,13 @@ def quickstart(project_id: str, location: str, processor_id: str, file_path: str): - client = documentai.DocumentProcessorServiceClient() + + # You must set the api_endpoint if you use a location other than 'us', e.g.: + opts = {} + if location == "eu": + opts = {"api_endpoint": "eu-documentai.googleapis.com"} + + client = documentai.DocumentProcessorServiceClient(client_options=opts) # The full resource name of the processor, e.g.: # projects/project-id/locations/location/processor/processor-id