Google Gen AI SDK for .NET 1.21.0

Last reviewed Sep 20, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. C# 14106 lines · 4.4K tokens
  2. Google Gen AI SDK for .NET 1.21.098 lines · 5.5K tokens
Total204 lines · 9.9K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 79
  • 89
  • 94
  • 117
  • 190
  • 201
  • 208
  • 209
  • 214
  • 250
  • 257
  • 295
  • 319
  • 323
  • 327
  • 338
  • 345
  • 362
  • 367
  • 378
  • 426
  • 459
  • 502
  • 524
  • 532
  • 611
  • 613
  • 636
  • 639
  • 674
  • 759
  • 770
  • 772
  • 775
  • 798
  • 807
  • 841
  • 862
  • 915
  • 916
  • 918
  • 923
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the C# 14 prompt first. These rules cover Google.GenAI 1.21.0 and its Gemini Developer API and Gemini Enterprise Agent Platform backends. The package targets net8.0 and netstandard2.0; use these rules with C# 14 on .NET 10. Package compatibility does not establish runtime support or guarantee that a model, backend, or API version supports every generated property.

Client construction and backend selection

  • Reuse a Client per configured credential and backend boundary, and dispose it with its owner. The SDK caches one HttpClient and disposes even a client returned by ClientOptions.HttpClientFactory; do not share a factory-returned instance with independently disposed SDK clients.
  • Choose enterprise: false or enterprise: true from server configuration. For enterprise workloads fix project and location explicitly, including any residency constraint; an omitted location can resolve to global. Do not combine conflicting enterprise and legacy vertexAI flags.
  • Control GOOGLE_GENAI_USE_ENTERPRISE, GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, GOOGLE_API_KEY, and GEMINI_API_KEY at deployment. The enterprise environment flag takes precedence over the legacy flag, and GOOGLE_API_KEY takes precedence over GEMINI_API_KEY; warnings do not prevent a wrong-account request.
  • Use a workload identity or application default credential for enterprise service workloads and restrict its IAM permissions and accessible resources. The SDK's cloud-platform OAuth scope is not an IAM grant or a replacement for