GoogleCloudPlatform / GoogleCloudPlatform/dotnet-docs-samples

Getting error with Claude - Sonnet models

Open
#3,162 0 comments 0 reactions 1 assignee Claimed by @meteatamel View on GitHub
api: vertex-ai samples type: question
Dominant language
C#
Stars
848
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

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(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"}}")'
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.