Se você ainda não tiver feito isso, use as instruções a seguir para configurar o projeto e criar um bucket do Cloud Storage.
Crie o projeto
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
On the Create a bucket page, enter your bucket information. To go to the next
step, click Continue.
For Name your bucket, enter a unique bucket name. Don't include sensitive
information in the bucket name, because the bucket namespace is global and publicly
visible.
For Choose where to store your data, do the following:
Select a Location type option.
Select a Location option.
For Choose a default storage class for your data, select the following:
Standard.
For Choose how to control access to objects, select an Access control option.
Na seção Testar este método, preencha o modelo interativo do API Explorer substituindo cloud-samples-data/vision no campo image.source.imageUri pelo nome do bucket do Cloud Storage no qual foi feito upload do arquivo demo-img.jpg. O corpo da solicitação deve ter a seguinte aparência:
Clique em Executar para enviar a solicitação ao serviço. A resposta JSON aparece após o corpo da solicitação.
Parabéns! Você fez sua primeira solicitação images.annotate ao Cloud Vision.
Limpar
Para evitar cobranças desnecessárias do Google Cloud, use o console do Google Cloud para excluir o bucket do Cloud Storage e seu projeto se não precisar deles.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[],[],null,["# Quickstart: Detect labels in an image by using the Cloud Vision API\n\nDetect labels in an image by using the Cloud Vision API\n=======================================================\n\nThis quickstart shows you how to:\n\n- Create a Cloud Storage bucket.\n- Upload your image to Cloud Storage and make the file publicly accessible.\n- Make a request to the Vision API with that image.\n\nThese steps should take about five minutes to complete. You can [store up to\n5 GB of data in Cloud Storage for no\ncharge](/storage/pricing#cloud-storage-always-free) and make up to [1000 feature\nrequests](/vision/docs/pricing) per month to the Vision API for no\ncharge.\n\nBefore you begin\n----------------\n\nIf you haven't done so already, use the following instructions to set up your\nproject and create a Cloud Storage bucket.\n\n### Set up your project\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Vision API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com&redirect=https://console.cloud.google.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Vision API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com&redirect=https://console.cloud.google.com)\n\n\u003cbr /\u003e\n\n### Create a Cloud Storage bucket\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page.\n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. Click add_box **Create**.\n3. On the **Create a bucket** page, enter your bucket information. To go to the next step, click **Continue** .\n 1. For **Name your bucket**, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.\n 2. In the **Choose where to store your data** section, do the following:\n 1. Select a [Location type](/storage/docs/locations).\n 2. Choose a location where your bucket's data is permanently stored from the **[Location type](/storage/docs/locations#available-locations)** drop-down menu.\n - If you select the [dual-region](/storage/docs/locations#location-dr) location type, you can also choose to enable [turbo replication](/storage/docs/availability-durability#turbo-replication) by using the relevant checkbox.\n 3. To set up [cross-bucket replication](/storage/docs/availability-durability#cross-bucket-replication), select **Add cross-bucket replication via Storage Transfer Service** and follow these steps: \n\n #### Set up cross-bucket replication\n\n 1. In the **Bucket** menu, select a bucket.\n 2. In the **Replication settings** section,\n click **Configure** to configure settings for the\n replication job.\n\n The **Configure cross-bucket replication** pane\n appears.\n - To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click add **Add a prefix**.\n - To set a storage class for the replicated objects, select a storage class from the **Storage class** menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.\n - Click **Done**.\n 3. In the **Choose how to store your data** section, do the following:\n 1. In the **Set a default class** section, select the following: **Standard**.\n 2. To enable [hierarchical namespace](/storage/docs/hns-overview), in the **Optimize storage for data-intensive workloads** section, select **Enable hierarchical namespace on this bucket** . **Note:** You cannot enable hierarchical namespace in existing buckets.\n 4. In the **Choose how to control access to objects** section, select whether or not your bucket enforces [public access prevention](/storage/docs/public-access-prevention), and select an [access control method](/storage/docs/access-control) for your bucket's objects. **Note:** You cannot change the **Prevent public access** setting if this setting is enforced at an [organization policy](/storage/docs/org-policy-constraints#public-access-prevention).\n 5. In the **Choose how to protect object data** section, do the following:\n - Select any of the options under **Data protection** that you want to set for your bucket.\n - To enable [soft delete](/storage/docs/soft-delete), click the **Soft delete policy (For data recovery)** checkbox, and specify the number of days you want to retain objects after deletion.\n - To set [Object Versioning](/storage/docs/object-versioning), click the **Object versioning (For version control)** checkbox, and specify the maximum number of versions per object and the number of days after which the noncurrent versions expire.\n - To enable the retention policy on objects and buckets, click the **Retention (For compliance)** checkbox, and then do the following:\n - To enable [Object Retention Lock](/storage/docs/object-lock), click the **Enable object retention** checkbox.\n - To enable [Bucket Lock](/storage/docs/bucket-lock), click the **Set bucket retention policy** checkbox, and choose a unit of time and a length of time for your retention period.\n - To choose how your object data will be encrypted, expand the **Data encryption** section (expand_more), and select a [**Data encryption** method](/storage/docs/encryption).\n4. Click **Create**.\n\n\u003cbr /\u003e\n\nMake a request to Cloud Vision\n------------------------------\n\n1. Save a local version of the sample image file ([`demo-img.jpg`](/static/vision/docs/images/demo-img.jpg)).\n\n2. In the Google Cloud console, go to the Cloud Storage **Buckets** page.\n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n3. Select the bucket you created in the previous section.\n\n4. Click **Upload Files** and select the local version of the `demo-img.jpg`\n file to upload to your Cloud Storage bucket.\n\n This is the image file that you just uploaded: *Image credit* : [Rohiim Ariful](https://unsplash.com/photos/Iz2cMcT6BzU) on [Unsplash](https://unsplash.com/).\n\n \u003cbr /\u003e\n\n5. After the file is uploaded and appears in the Cloud Storage bucket,\n [share the image publicly](/storage/docs/access-control/making-data-public).\n\n6. In the [Try this method](#apis-explorer-try-this-method) section, complete\n the interactive API Explorer template by replacing\n `cloud-samples-data/vision` in the `image.source.imageUri` field with the\n name of the Cloud Storage bucket where you uploaded the `demo-img.jpg`\n file. The request body should look like the following:\n\n ```\n {\n \"requests\": [\n {\n \"features\": [\n {\n \"type\": \"LABEL_DETECTION\"\n }\n ],\n \"image\": {\n \"source\": {\n \"imageUri\": \"gs://cloud-samples-data/vision/demo-img.jpg\"\n }\n }\n }\n ]\n }\n ``` \n\n \u003cbr /\u003e\n\n7. Click **Execute** to send the request to the service. The JSON response\n appears after the request body.\n\nCongratulations! You've made your first `images.annotate` request to\nCloud Vision.\n\nClean up\n--------\n\nTo avoid unnecessary Google Cloud charges, use the Google Cloud console to\ndelete your Cloud Storage bucket (and your project) if you don't need them.\n\nWhat's next\n-----------\n\n- See a list of [all feature types](/vision/docs/features-list) and their uses.\n- Get started with the Vision API in your language of choice by using a [Vision API Client\n Library](/vision/docs/quickstart-client-libraries).\n- Use the [How-to guides](/vision/docs/how-to) to learn more about specific features, see example annotations, and get annotations for an individual file or image.\n- Learn about batch [image](/vision/docs/batch) and [file](/vision/docs/file-small-batch) (PDF/TIFF/GIF) annotation.\n- Browse through a comprehensive list of client library code [samples](/vision/docs/samples)."]]