Stay organized with collections
Save and categorize content based on your preferences.
Custom metadata labels
Document AI supports adding user-defined labels or key-value pairs (KVPs) as metadata
sent to the processor to ProcessDocument, BatchProcessDocuments
requests.
This metadata about the request (along with the usage data, like number of pages)
is forwarded to the Cloud Billing system. It's populated in the billing
system, where you can break down your billing charges by filtering using these metadata labels.
Use case
An important use case for labels involves customers who provide document processing
services to many clients. A single project can be used for multiple clients.
For billing purposes, it's important to associate specific requests with their
respective clients. That's where these metadata labels come in. They're for filtering
reports in Google Cloud.
Requirements for labels
The labels applied to a request must meet the following requirements:
Each request can have multiple labels, up to a maximum of 64.
Each label must be a KVP.
Keys have a minimum length of 1 character and maximum 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.
Keys and values contain only lowercase letters, numeric characters, underscores,
and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
The key portion of a label must be unique within a single request (for example, {'country':'india'} is fine, but {'country':'india','country':'sweden'} is not allowed).
Keys must start with a lowercase letter or international character.
Usage with API
The Sync Process code sample shows you how to send a request to a processor using a label.
From the console, select the Menu at the upper left, and select Billing from the drop-down. If you have multiple billing accounts
a page appears that asks you to make a selection. Select Go to linked billing account.
From the billing page, select Reports in the left-hand navigation pane.
Use the filters in the right-hand pane to check usage of requests.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eDocument AI allows adding custom metadata labels (key-value pairs) to \u003ccode\u003eProcessDocument\u003c/code\u003e and \u003ccode\u003eBatchProcessDocuments\u003c/code\u003e requests.\u003c/p\u003e\n"],["\u003cp\u003eThese metadata labels are forwarded to the Cloud Billing system, enabling users to filter and break down billing charges based on these labels.\u003c/p\u003e\n"],["\u003cp\u003eEach request can have up to 64 labels, and each label consists of a key and a value, both of which have character and length constraints.\u003c/p\u003e\n"],["\u003cp\u003eLabels are particularly useful for customers managing document processing services for multiple clients within a single project, as they facilitate the association of specific requests with their respective clients for billing purposes.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Billing console allows for filtering usage reports using these metadata labels, enabling detailed analysis of request activity.\u003c/p\u003e\n"]]],[],null,["# Custom metadata labels\n======================\n\nDocument AI supports adding user-defined labels or key-value pairs (KVPs) as metadata\nsent to the processor to [`ProcessDocument`](/document-ai/docs/reference/rest/v1/projects.locations.processors/process), [`BatchProcessDocuments`](/document-ai/docs/reference/rest/v1/projects.locations.processors/batchProcess)\nrequests.\nThis metadata about the request (along with the usage data, like number of pages)\nis forwarded to the Cloud Billing system. It's populated in the billing\nsystem, where you can break down your billing charges by filtering using these metadata labels.\n\nUse case\n--------\n\nAn important use case for labels involves customers who provide document processing\nservices to many clients. A single project can be used for multiple clients.\nFor billing purposes, it's important to associate specific requests with their\nrespective clients. That's where these metadata labels come in. They're for filtering\nreports in Google Cloud.\n\nRequirements for labels\n-----------------------\n\nThe labels applied to a request must meet the following requirements:\n\n- Each request can have multiple labels, up to a maximum of 64.\n- Each label must be a KVP.\n- Keys have a minimum length of 1 character and maximum 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.\n- Keys and values contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.\n- The key portion of a label must be unique within a single request (for example, `{'country':'india'}` is fine, but `{'country':'india','country':'sweden'}` is not allowed).\n- Keys must start with a lowercase letter or international character.\n\nUsage with API\n--------------\n\nThe `Sync Process` code sample shows you how to send a request to a processor using a label. \n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @docai_request.json \\\n \"https://us-documentai.googleapis.com/v1/projects/514064100333/locations/us/processors/3bb61571a9731982:process\"\n\nSample Request \n\n {\n \"skipHumanReview\": true,\n \"rawDocument\": {\n \"mimeType\": \"application/pdf\",\n \"content\" : \"PDF/IMAGE CONTENT\"\n },\n \"labels\": {\"country\": \"india\" },\n \"processOptions\": {\n \"individualPageSelector\" : {\n \"pages\": [1]\n }\n }\n }\n\nThe `Async Process` code sample shows you how to send a request to a processor using a label. \n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @batch_docai_request.json \\\n \"https://us-documentai.googleapis.com/v1/projects/514064100333/locations/us/processors/3bb61571a9731982:batchProcess\"\n\nSample Request \n\n {\n \"inputDocuments\": {\n \"gcsPrefix\": {\n \"gcsUriPrefix\": \"gs://atul_dai_test/ravi/GCS_DWH_work_flows_docs/Small_pdf/\"\n }\n },\n \"documentOutputConfig\": {\n \"gcsOutputConfig\": {\n \"gcsUri\": \"gs://atul_dai_test/ravi/GCS_DWH_work_flows_docs/test/docai_config/\"\n }\n },\n \"labels\": {\"country\": \"india\" },\n \"skipHumanReview\": true\n }\n\n### Pricing report\n\nYou can use these labels to view request usage.\n\n1. Go to the [Cloud Billing console](https://console.cloud.google.com/billing).\n\n2. From the console, select the **Menu** at the upper left, and select **Billing** from the drop-down. If you have multiple billing accounts\n a page appears that asks you to make a selection. Select **Go to linked billing account**.\n\n3. From the billing page, select **Reports** in the left-hand navigation pane.\n\n4. Use the filters in the right-hand pane to check usage of requests."]]