Package vision is an auto-generated package for the
Cloud Vision API.
Integrates Google Vision features, including image labeling, face, logo,
and landmark detection, optical character recognition (OCR), and detection
of explicit content, into applications.
The client will use your default application credentials. Clients should be reused instead of created as needed.
The methods of Client are safe for concurrent use by multiple goroutines.
The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client.
ctx:=context.Background()c,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.BatchAnnotateImagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1#BatchAnnotateImagesRequest.}resp,err:=c.BatchAnnotateImages(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp
Use of Context
The ctx passed to NewClient is used for authentication requests and
for creating the underlying connection, but is not used for subsequent calls.
Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
ImageAnnotatorCallOptions contains the retry settings for each method of ImageAnnotatorClient.
ImageAnnotatorClient
typeImageAnnotatorClientstruct{// The call options for this service.CallOptions*ImageAnnotatorCallOptions// contains filtered or unexported fields}
ImageAnnotatorClient is a client for interacting with Cloud Vision API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service that performs Google Cloud Vision API detection tasks over client
images, such as face, landmark, logo, label, and text detection. The
ImageAnnotator service returns detected entities from the images.
NewImageAnnotatorClient creates a new image annotator client based on gRPC.
The returned client must be Closed when it is done being used to clean up its underlying connections.
Service that performs Google Cloud Vision API detection tasks over client
images, such as face, landmark, logo, label, and text detection. The
ImageAnnotator service returns detected entities from the images.
Example
packagemainimport("context"vision"cloud.google.com/go/vision/apiv1p1beta1")funcmain(){ctx:=context.Background()c,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}
[[["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-09-04 UTC."],[[["\u003cp\u003eThe package \u003ccode\u003evision\u003c/code\u003e is an auto-generated Go package for the Cloud Vision API, enabling features like image labeling, face, logo, and landmark detection, OCR, and explicit content detection.\u003c/p\u003e\n"],["\u003cp\u003eThis is a beta package, version 1.2.0 being the latest, which means it is not stable and is subject to changes, potentially incompatible with other pre-GA versions.\u003c/p\u003e\n"],["\u003cp\u003eTo use the package, you need to create a \u003ccode\u003eNewImageAnnotatorClient\u003c/code\u003e, which should be reused across your application and closed using \u003ccode\u003eClose()\u003c/code\u003e when finished, and the methods of the client are safe for concurrent use.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBatchAnnotateImages\u003c/code\u003e method allows you to run detection and annotation tasks on multiple images by providing a \u003ccode\u003eBatchAnnotateImagesRequest\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eImageAnnotatorClient\u003c/code\u003e interacts with the Cloud Vision API service to perform tasks such as face, landmark, logo, label, and text detection, with the \u003ccode\u003eDefaultAuthScopes\u003c/code\u003e function providing the default authentication scopes.\u003c/p\u003e\n"]]],[],null,["# Package cloud.google.com/go/vision/apiv1p1beta1 (v1.2.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.0 (latest)](/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1)\n- [1.1.0](/go/docs/reference/cloud.google.com/go/vision/1.1.0/apiv1p1beta1)\n- [1.0.0](/go/docs/reference/cloud.google.com/go/vision/1.0.0/apiv1p1beta1)\n- [0.1.0](/go/docs/reference/cloud.google.com/go/vision/0.1.0/apiv1p1beta1) \n| **Beta**\n|\n|\n| This library is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1)\n| of the Terms of Service. Pre-GA libraries might have limited support,\n| and changes to pre-GA libraries might not be compatible with other pre-GA versions.\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/cloud.google.com/go/vision/apiv1p1beta1). \n\u003cbr /\u003e\n\nPackage vision is an auto-generated package for the\nCloud Vision API.\n\nIntegrates Google Vision features, including image labeling, face, logo,\nand landmark detection, optical character recognition (OCR), and detection\nof explicit content, into applications. \n\n```go\nNOTE: This package is in beta. It is not stable, and may be subject to changes.\n```\n\n\u003cbr /\u003e\n\nExample usage\n-------------\n\nTo get started with this package, create a client. \n\n```go\nctx := context.Background()\nc, err := vision.NewImageAnnotatorClient(ctx)\nif err != nil {\n // TODO: Handle error.\n}\ndefer c.Close()\n```\n\n\u003cbr /\u003e\n\nThe client will use your default application credentials. Clients should be reused instead of created as needed.\nThe methods of Client are safe for concurrent use by multiple goroutines.\nThe returned client must be Closed when it is done being used.\n\nUsing the Client\n----------------\n\nThe following is an example of making an API call with the newly created client. \n\n```go\nctx := context.Background()\nc, err := vision.NewImageAnnotatorClient(ctx)\nif err != nil {\n // TODO: Handle error.\n}\ndefer c.Close()\n\nreq := &visionpb.BatchAnnotateImagesRequest{\n // TODO: Fill request struct fields.\n // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1#BatchAnnotateImagesRequest.\n}\nresp, err := c.BatchAnnotateImages(ctx, req)\nif err != nil {\n // TODO: Handle error.\n}\n// TODO: Use resp.\n_ = resp\n```\n\n\u003cbr /\u003e\n\nUse of Context\n--------------\n\nThe ctx passed to NewClient is used for authentication requests and\nfor creating the underlying connection, but is not used for subsequent calls.\nIndividual methods on the client use the ctx given to them.\n\nTo close the open connection, use the Close() method.\n\nFor information about setting deadlines, reusing contexts, and more\nplease visit \u003chttps://pkg.go.dev/cloud.google.com/go\u003e. \n\nFunctions\n---------\n\n### func DefaultAuthScopes\n\n func DefaultAuthScopes() []https://pkg.go.dev/builtin#string\n\nDefaultAuthScopes reports the default set of authentication scopes to use with this package. \n\nImageAnnotatorCallOptions\n-------------------------\n\n type ImageAnnotatorCallOptions struct {\n \tBatchAnnotateImages []https://pkg.go.dev/github.com/googleapis/gax-go/v2.https://pkg.go.dev/github.com/googleapis/gax-go/v2#CallOption\n }\n\nImageAnnotatorCallOptions contains the retry settings for each method of ImageAnnotatorClient. \n\nImageAnnotatorClient\n--------------------\n\n type ImageAnnotatorClient struct {\n\n \t// The call options for this service.\n \tCallOptions *#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorCallOptions\n \t// contains filtered or unexported fields\n }\n\nImageAnnotatorClient is a client for interacting with Cloud Vision API.\nMethods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.\n\nService that performs Google Cloud Vision API detection tasks over client\nimages, such as face, landmark, logo, label, and text detection. The\nImageAnnotator service returns detected entities from the images. \n\n### func NewImageAnnotatorClient\n\n func NewImageAnnotatorClient(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, opts ...option.ClientOption) (*#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient, https://pkg.go.dev/builtin#error)\n\nNewImageAnnotatorClient creates a new image annotator client based on gRPC.\nThe returned client must be Closed when it is done being used to clean up its underlying connections.\n\nService that performs Google Cloud Vision API detection tasks over client\nimages, such as face, landmark, logo, label, and text detection. The\nImageAnnotator service returns detected entities from the images. \n\n#### Example\n\n package main\n\n import (\n \t\"context\"\n\n \tvision \"cloud.google.com/go/vision/apiv1p1beta1\"\n )\n\n func main() {\n \tctx := context.Background()\n \tc, err := vision.https://cloud.google.com/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1.html#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient_NewImageAnnotatorClient(ctx)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \tdefer c.https://cloud.google.com/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1.html#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient_Close()\n\n \t// TODO: Use client.\n \t_ = c\n }\n\n### func (\\*ImageAnnotatorClient) BatchAnnotateImages\n\n func (c *#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient) BatchAnnotateImages(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, req *https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1.https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1#BatchAnnotateImagesRequest, opts ...https://pkg.go.dev/github.com/googleapis/gax-go/v2.https://pkg.go.dev/github.com/googleapis/gax-go/v2#CallOption) (*https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1.https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1#BatchAnnotateImagesResponse, https://pkg.go.dev/builtin#error)\n\nBatchAnnotateImages run image detection and annotation for a batch of images. \n\n#### Example\n\n package main\n\n import (\n \t\"context\"\n\n \tvision \"cloud.google.com/go/vision/apiv1p1beta1\"\n \tvisionpb \"google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1\"\n )\n\n func main() {\n \tctx := context.Background()\n \tc, err := vision.https://cloud.google.com/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1.html#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient_NewImageAnnotatorClient(ctx)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \tdefer c.https://cloud.google.com/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1.html#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient_Close()\n\n \treq := &visionpb.BatchAnnotateImagesRequest{\n \t\t// TODO: Fill request struct fields.\n \t\t// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1#BatchAnnotateImagesRequest.\n \t}\n \tresp, err := c.https://cloud.google.com/go/docs/reference/cloud.google.com/go/vision/latest/apiv1p1beta1.html#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient_BatchAnnotateImages(ctx, req)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \t// TODO: Use resp.\n \t_ = resp\n }\n\n### func (\\*ImageAnnotatorClient) Close\n\n func (c *#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient) Close() https://pkg.go.dev/builtin#error\n\nClose closes the connection to the API service. The user should invoke this when\nthe client is no longer required. \n\n### func (\\*ImageAnnotatorClient) Connection\n\n func (c *#cloud_google_com_go_vision_apiv1p1beta1_ImageAnnotatorClient) Connection() *grpc.ClientConn\n\nConnection returns a connection to the API service.\n\nDeprecated."]]