Reputation: 31
I'm running the following code from the cloud-vision API examples repo. I have followed the instructions here: https://cloud.google.com/vision/docs/quickstart-client-libraries?refresh=1 to set up a service account and authentication, but I still can't successfully execute this function.
async function detectLabels() {
// [START vision_label_detection]
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
const fileName = './src/img/wakeupcat.jpg';
// Performs label detection on the local file
const [result] = await client.labelDetection(fileName);
const labels = result.labelAnnotations;
console.log('Labels:');
labels.forEach(label => console.log(label.description));
// [END vision_label_detection]
}
detectLabels();
This gives the following error:
Error: 8 RESOURCE_EXHAUSTED: Quota exceeded for quota metric 'Requests' and limit 'Requests per minute' of service 'vision.googleapis.com' for consumer 'project_number:6579173653'.
The wakupcat.jpg image I'm using is 14kb so it's not the size that's an issue.
Upvotes: 0
Views: 961
Reputation: 40296
The error you're receiving is for the number of requests that you're making (and I think not the file size).
You may review your current quote usage for a specific project and API using the following URL:
You'll need to use the Project ID not the Project # (6579173653)
If as I suspect, you're exceeding your (daily? hourly?) quota, you may wait (until these reset) or apply for more:
You should be able to determine the Project ID using:
PROJECT_ID=$(\
gcloud projects list \
--filter="projectNumber~6579173653" \
--format=value(projectId)") && echo ${PROJECT_ID}
NB It's unclear to me why this only works with ~
rather than =
Upvotes: 0
Reputation: 1060
Make sure to do this step: export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
Upvotes: 0