Skip to content

Getting error with Claude - Sonnet models #3162

@ambitiousrahul

Description

@ambitiousrahul

I am using Google.Cloud.AIPlatform.V1 version 3.38.0 (.NET based SDK for Vertex AI) and trying to connect to GCP: Anthropic models(already enabled on Vertex AI).

 var payloadObj = new
  {
      max_tokens = 500,
      temperature = 0.7,
      top_p = 1.0,
      top_k = 1.0,
      stop_sequences = new string[] { },
      messages = new[]
      {
        new {
            role = "user",
            content = new[]
            {
                new {
                    type = "text",
                    text = "This is my first hi to you. Write good morning message for me"
                }
            }
        }
      },
      anthropic_version = "vertex-2023-10-16"
  };

 var json = JsonConvert.SerializeObject(payloadObj);
var instances = JsonParser.Default.Parse<Google.Protobuf.WellKnownTypes.Value>(json);

   // Create the PredictRequest
   PredictRequest request = new PredictRequest
   {
       //Endpoint = endpoint.ToString(),
       EndpointAsEndpointName = endpoint,
       Instances = { instances }
   };
   PredictResponse response = await geminiClient.PredictAsync(request);

But, I am always getting following error on PredictAsync method

Grpc.Core.RpcException: 'Status(StatusCode="InvalidArgument", Detail="{"type":"error","error":{"type":"invalid_request_error","message":"messages: Field required"}}")'

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the Vertex AI API.samplesIssues that are directly related to samples.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions