Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Gemini cannot be accessed through Vertex Predict/RawPredict API. #29264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hakunin opened this issue Mar 3, 2025 · 0 comments
Open

Gemini cannot be accessed through Vertex Predict/RawPredict API. #29264

hakunin opened this issue Mar 3, 2025 · 0 comments
Assignees

Comments

@hakunin
Copy link

hakunin commented Mar 3, 2025

Hi, I've ben trying to use Gemini/Vertex(?) through this gem and it looks like its not the right way to do it.

I've used the sample Google docs (and samples here give):

# https://cloud.google.com/vertex-ai/docs/samples/aiplatform-sdk-ideation?hl=en#aiplatform_sdk_ideation-ruby

require "google/cloud/ai_platform/v1"

class GeminiApi::TestGem

  def self.run
    puts "RUNNING"
    ENV['GOOGLE_APPLICATION_CREDENTIALS'] = 'google-pie-vertex.json'
    new.predict_text_prompt(
      project_id: 'xxxxxxxxxx',
      model: 'gemini-2.0-flash-001',
    )
  end

  ##
  # Vertex AI Predict Text Prompt
  #
  # @param project_id [String] Your Google Cloud project (e.g. "my-project")
  # @param location_id [String] Your Processor Location (e.g. "us-central1")
  # @param publisher [String] The Model Publisher (e.g. "google")
  # @param model [String] The Model Identifier (e.g. "text-bison@001")
  #
  def predict_text_prompt project_id:, location_id: "us-central1", publisher: "google", model:
    # Create the Vertex AI client.
    # TODO problem might be that we can't use the PredictionService?
    client = ::Google::Cloud::AIPlatform::V1::PredictionService::Client.new do |config|
      config.endpoint = "#{location_id}-aiplatform.googleapis.com"
    end

    # Build the resource name from the project.
    endpoint = client.endpoint_path(
      project: project_id,
      location: location_id,
      publisher: publisher,
      model: model
    )

    prompt = "Give me ten interview questions for the role of program manager."

    # Initialize the request arguments
    instance = Google::Protobuf::Value.new(
      struct_value: Google::Protobuf::Struct.new(
        fields: {
          "prompt" => Google::Protobuf::Value.new(
            string_value: prompt
          )
        }
      )
    )

    instances = [instance]

    parameters = Google::Protobuf::Value.new(
      struct_value: Google::Protobuf::Struct.new(
        fields: {
          "temperature" => Google::Protobuf::Value.new(number_value: 0.2),
          "maxOutputTokens" => Google::Protobuf::Value.new(number_value: 256),
          "topP" => Google::Protobuf::Value.new(number_value: 0.95),
          "topK" => Google::Protobuf::Value.new(number_value: 40)
        }
      )
    )

    # Make the prediction request
    response = client.predict endpoint: endpoint, instances: instances, parameters: parameters

    # Handle the prediction response
    puts "Predict Response"
    puts response
  end
end

And I am just getting:

/root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:29:in `check_status': 9:Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.. debug_error_string:{UNKNOWN:Error received from peer ipv4:142.251.36.106:443 {grpc_message:"Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.", grpc_status:9, created_time:"2025-03-03T08:43:45.299372088+00:00"}} (GRPC::FailedPrecondition)
        from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:189:in `attach_status_results_and_complete_call'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:383:in `request_response'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:174:in `block (2 levels) in request_response'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:173:in `block in request_response'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/gapic-common-0.23.0/lib/gapic/grpc/service_stub/rpc_call.rb:123:in `call'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/gapic-common-0.23.0/lib/gapic/grpc/service_stub.rb:205:in `call_rpc'
        from /root/dev/app/.bundle/ruby/3.2.0/gems/google-cloud-ai_platform-v1-0.60.0/lib/google/cloud/ai_platform/v1/prediction_service/client.rb:292:in `predict'
        from /root/dev/app/app/lib/gemini_api/test_gem.rb:65:in `predict_text_prompt'
        from /root/dev/app/app/lib/gemini_api/test_gem.rb:10:in `run'

And it looks like this gem is not supposed to be used with that API?
And there is no ruby API for the new one as Ruby is not listed on the linked page:
https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal

So what are we supposed to use?

REST api through curl seems to work fine, so are we supposed to use the rest API through http libraries?
If that's the case thats fine but its pretty confusing not having this mentioned anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants