Document AI Warehouse client libraries

This page shows how to get started with the Cloud Client Libraries for the Document AI Warehouse API. Read more about the client libraries for Cloud APIs, including the older Google API Client Libraries, in Client Libraries Explained.

Install the client library


For more information, see Setting Up a Java Development Environment.

If you are using Maven, add this to your pom.xml file:


If you are using Gradle, add this to your dependencies:

compile ''

If you are using SBT, add this to your dependencies:

libraryDependencies += "" % "google-cloud" % "0.3.0"


For more information, see Setting Up a Node.js Development Environment.

npm install @google-cloud/contentwarehouse


For more information, see Setting Up a Python Development Environment.

pip install --upgrade google-cloud-contentwarehouse

Set up authentication

When you use client libraries, you use Application Default Credentials (ADC) to authenticate. For information about setting up ADC, see Provide credentials for Application Default Credentials. For information about using ADC with client libraries, see Authenticate using client libraries.

Use the client library

The following example shows how to use the client library.


For more information, see the Document AI Warehouse Python API reference documentation.

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

from import contentwarehouse

# TODO(developer): Uncomment these variables before running the sample.
# project_number = 'YOUR_PROJECT_NUMBER'
# location = 'YOUR_PROJECT_LOCATION' # Format is 'us' or 'eu'
# user_id = "" # Format is ""

def quickstart(project_number: str, location: str, user_id: str) -> None:
    # Create a Schema Service client
    document_schema_client = contentwarehouse.DocumentSchemaServiceClient()

    # The full resource name of the location, e.g.:
    # projects/{project_number}/locations/{location}
    parent = document_schema_client.common_location_path(
        project=project_number, location=location

    # Define Schema Property of Text Type
    property_definition = contentwarehouse.PropertyDefinition(
        name="stock_symbol",  # Must be unique within a document schema (case insensitive)
        display_name="Searchable text",

    # Define Document Schema Request
    create_document_schema_request = contentwarehouse.CreateDocumentSchemaRequest(
            display_name="My Test Schema",

    # Create a Document schema
    document_schema = document_schema_client.create_document_schema(

    # Create a Document Service client
    document_client = contentwarehouse.DocumentServiceClient()

    # The full resource name of the location, e.g.:
    # projects/{project_number}/locations/{location}
    parent = document_client.common_location_path(
        project=project_number, location=location

    # Define Document Property Value
    document_property = contentwarehouse.Property(

    # Define Document
    document = contentwarehouse.Document(
        display_name="My Test Document",,
        plain_text="This is a sample of a document's text.",

    # Define Request
    create_document_request = contentwarehouse.CreateDocumentRequest(

    # Create a Document for the given schema
    response = document_client.create_document(request=create_document_request)

    # Read the output
    print(f"Rule Engine Output: {response.rule_engine_output}")
    print(f"Document Created: {response.document}")

Additional resources