The code below returns empty list instead of a list of all base models offered by Vertex AI. I can’t understand why. Please help.
public async Task<List<Model>> GetModels(string projectId = "PROJECTID", string location = "us-west1")
{
List<Model> geminiModels = new List<Model>();
try
{
ModelServiceClient modelServiceClient = new ModelServiceClientBuilder
{
JsonCredentials = GoogleAuthentication.JsonCodePaidServices,
Endpoint = $"{location}-aiplatform.googleapis.com:443",
}.Build();
LocationName parent = LocationName.FromProjectLocation(projectId, location);
PagedAsyncEnumerable<ListModelsResponse, Model> response = modelServiceClient.ListModelsAsync(parent);
await response.ForEachAsync((Model item) =>
{
geminiModels.Add(item);
});
return geminiModels;
}
catch (Exception ex)
{
return null;
}