Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error js imagen 3 generation

Hello, 

Trying to Run this code:

const project = 'PPPPPPPPP';  
const location = 'us-central1';

// Import the Vertex AI library
const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1;

// Set up the client
const client = new PredictionServiceClient();

async function generateImage() {

// Full endpoint for the model
const endpoint = `projects/${project}/locations/${location}/publishers/google/models/imagen-3.0-generate-001`;

// Create the request with the prompt
const request = {
endpoint: endpoint,
   instances: [
         {prompt: 'A futuristic cityscape at sunset'}
    ]
};

// Call the API to generate an image
try {
   const [response] = await client.predict(request);
    console.log('Generated Image:', response.predictions);
} catch (error) {
     console.error('Error generating image:', error);
}

}

generateImage();

===

I get the error:

Error generating image: Error: 12 UNIMPLEMENTED: Received HTTP status code 404

    at callErrorFromStatus (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/call.js:31:19)

    at Object.onReceiveStatus (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/client.js:193:76)

    at Object.onReceiveStatus (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)

    at Object.onReceiveStatus (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)

    at /Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78

    at processTicksAndRejections (node:internal/process/task_queues:78:11)

for call at

    at ServiceClientImpl.makeUnaryRequest (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/client.js:161:32)

    at ServiceClientImpl.<anonymous> (/Users/uuuuu/vertexai/vertex_js_api/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)

    at /Users/uuuuu/vertexai/vertex_js_api/node_modules/@google-cloud/aiplatform/build/src/v1/prediction_service_client.js:277:29

    at /Users/uuuuu/vertexai/vertex_js_api/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16

    at OngoingCallPromise.call (/Users/uuuuu/vertexai/vertex_js_api/node_modules/google-gax/build/src/call.js:67:27)

    at NormalApiCaller.call (/Users/uuuuu/vertexai/vertex_js_api/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)

    at /Users/uuuuu/vertexai/vertex_js_api/node_modules/google-gax/build/src/createApiCall.js:112:30

    at processTicksAndRejections (node:internal/process/task_queues:96:5) {

  code: 12,

  details: 'Received HTTP status code 404',

  metadata: Metadata { internalRepr: Map(0) {}, options: {} }

}

thanks! 

0 1 288
1 REPLY 1

Hi @tronycoder ,

Welcome to Google Cloud Community!

The error message Received HTTP status code 404 you encountered indicates that no valid object is found from the designated URL. 

Here are workarounds that might help you resolve the error: 

  • Endpoint URL - Ensure that the endpoint URL is correct and that the model exists at that location. Double check the model ID and project/region details. 
  • Validate Region - Check the region in your code and ensure it matches the region where your Vertex AI service is deployed.
  • Model Availability - Ensure that the model is deployed and available for predictions.
  • Permissions - Verify that your service account has the necessary permissions to access the model and make predictions.

If the error persists, I suggest contacting Google Cloud Support as they can provide more insights to see if the behavior you've encountered is a known issue or specific to your project.

I hope the above information is helpful.