GenerateContent

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
using var client = new GeminiClient(apiKey);

GenerateContentResponse response = await client.GenerateContentAsync(
    modelId: "gemini-1.5-flash-latest",
    contents: [
        new Content
        {
            Parts = [
                new Part
                {
                    Text = "Generate 5 random words",
                },
            ],
            Role = "user",
        },
    ],
    generationConfig: new GenerationConfig(),
    safetySettings: new List<SafetySetting>());

Console.WriteLine(response.Candidates?[0].Content?.Parts?[0].Text);