mscraftsman / generative-ai

Gemini AI SDK for .NET and ASP.NET Core enables developers to use Google's state-of-the-art generative AI models to build AI-powered features and applications.
https://mscraftsman.github.io/generative-ai/
Apache License 2.0
55 stars 11 forks source link

await model.ListFiles() get HTTP 403 (Forbidden) #22

Closed doggy8088 closed 7 months ago

doggy8088 commented 7 months ago

The code:

#nullable enable

async Task Main()
{
    var googleAI = new GoogleAI(apiKey: Util.GetPassword("GEMINI_API_KEY"));

    // var model = googleAI.GenerativeModel(model: Model.Gemini15Pro);
    var model = googleAI.GenerativeModel(model: Model.Gemini10Pro001);

    var files = await model.ListFiles();

    files.Dump();
}

The result:

image

I don't know what's the exact problem I met. I can't see response body (JSON) from the Gemini API.

Related: https://github.com/mscraftsman/generative-ai/issues/6 and https://github.com/mscraftsman/generative-ai/issues/19

jochenkirstaetter commented 7 months ago

Hi @doggy8088 Did you upload any files beforehand?

jochenkirstaetter commented 7 months ago

Hi @doggy8088 Do you have access to the Gemini 1.5 API and File API?

jochenkirstaetter commented 7 months ago

Could you please check whether you can make a REST API call using cURL?

GET https://generativelanguage.googleapis.com/v1beta/files?key=$GOOGLE_API_KEY

I assume that you might not have access to the API endpoints (yet).

doggy8088 commented 7 months ago

I used the wrong key. The key to use must be created under the GCP Project that enabled for Gemini 1.5 Pro.