[CRITICAL] Final Issue: Node.js SDK (predict) Fails with 3 INVALID_ARGUMENT on Imagen 3.0

Hi Team,

We are following up on our previous communication regarding issues calling the Vertex AI Imagen model. We have successfully resolved all initial setup issues and now require technical insight to overcome the final barrier—a persistent data formatting error.

1. Troubleshooting History and Current Status

We followed your previous advice regarding the model ID, but encountered contradictory behavior, which we have now stabilized:

Model ID Attempt Result Conclusion
imagen-3.0-generate (Your advice) 5 NOT_FOUND error occurred. This ID was not reachable in our project for the predict method.
imagen-3.0-generate-002 (Our fix) 5 NOT_FOUND was resolved, but 3 INVALID_ARGUMENT persists. We confirmed that imagen-3.0-generate-002 is the active model IDrequired for the PredictionService.predict method in our environment.

Sheets로 내보내기

  • Final Error Code: 3 INVALID_ARGUMENT (Details field is empty).

  • Authentication & Setup: All permissions, service account authentication, and billing are confirmed working.

  • Problem: The request reaches the server (and incurs cost), but fails validation due to incorrect parameter data types.

2. Final Failing Code Structure

We have exhausted all logical combinations of data types (string vs. integer, inclusion vs. exclusion) for the parameters. The error persists with this confirmed structure:

JavaScript

// Current Failing Code Structure (Model ID Confirmed)
const request = {
    endpoint: '.../models/imagen-3.0-generate-002', 
    instances: [
      {
        prompt: { text: 'A simple test image of a red cube' } // Confirmed correct structure
      }
    ],
    parameters: {
        sampleCount: 1, // Tested as Integer (1) and String ("1")
        aspectRatio: 1, // Tested as Integer (1) and String ("ASPECT_RATIO_1_1")
        // output_mime_type was included in previous tests and failed; now removed.
    }
};

3. Urgent Technical Information Request

Since all client-side troubleshooting is complete, we urgently require the exact Protobuf schema definition for these parameters as expected by the @google-cloud/aiplatform Node.js SDK:

  1. aspectRatio: What is the exact Protobuf data type expected? Should we use the Enum String ("ASPECT_RATIO_1_1"), the Integer Enum Index (1), or is it a wrapped type (e.g., inside a specific message)?

  2. sampleCount: Is this strictly an Integer (1) or a specific type of Protobuf Value?

Providing this precise type information will allow us to resolve the serialization conflict and complete our project immediately.

Thank you for your prompt technical support.

Hello @덩웅_잊,

I think that you’re calling the wrong endpoint. From Image generation API Example Syntax:

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \

https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL_VERSION}:predict \
-d '{
  "instances": [
    {
      "prompt": "..."
    }
  ],
  "parameters": {
    "sampleCount": ...
  }
}'

Which means that instead of calling:

  • .../models/imagen-3.0-generate-002

You should use:

  • https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-generate-002:predict

Another way is to use the NodeJS Google Gen AI libraries.