dotnet-gemini-sdk icon indicating copy to clipboard operation
dotnet-gemini-sdk copied to clipboard

Is there any way to use user-defined API_KEY ?

Open anhhtca opened this issue 10 months ago • 3 comments

Hi, Users will provide their own keys to call Google Gemini Api.

Is there any way to do that?

Regards,

anhhtca avatar Mar 26 '24 01:03 anhhtca

Hi @anhhtca !

Sorry for late response.

Currently we register the api key in the gemini client add

    services.AddGeminiClient(config =>
    {
        config.ApiKey = "YOUR_GOOGLE_GEMINI_API_KEY";
        config.ImageBaseUrl = "CURRENTLY_IMAGE_BASE_URL";
        config.TextBaseUrl = "CURRENTLY_IMAGE_BASE_URL";
    });

You want to change it after registering the instance?

gsilvamartin avatar Apr 17 '24 02:04 gsilvamartin

I am using below as config.TextBaseUrl https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent

and when i try to call TextPrompt method of the client I get below error:

System.Exception: Unexpected error occurred. ---> System.Net.Http.HttpRequestException: { "error": { "code": 400, "message": "* GenerateContentRequest.model: unexpected model name format\n", "status": "INVALID_ARGUMENT" } }

Please help in explaining what I may be doing wrong?

NitinRawat26 avatar Jun 10 '24 18:06 NitinRawat26

Hi @NitinRawat26 which model you're using? Can you provide the details of request?

gsilvamartin avatar Jul 29 '24 22:07 gsilvamartin