Google Gen AI SDK for .NET 1.20.0

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. C# 14106 lines · 4.4K tokens
  2. Google Gen AI SDK for .NET 1.20.065 lines · 3.5K tokens
Total171 lines · 7.9K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 79
  • 89
  • 94
  • 117
  • 190
  • 201
  • 208
  • 209
  • 214
  • 250
  • 257
  • 295
  • 323
  • 327
  • 338
  • 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. Use these rules for Google.GenAI 1.20.0 in C# 14/.NET 10 applications. The package also supplies net8.0 and netstandard2.0 assets; those targets do not require C# 14. These rules cover Gemini Developer API and the cloud backend named Gemini Enterprise Agent Platform, including the compatible Vertex AI client option.

Client identity and routing

  • Set Client(enterprise: false, apiKey: ...) for Gemini Developer API or Client(enterprise: true, project: ..., location: ..., credential: ...) for cloud use from trusted configuration. Keep backend, project, location, identity, and billing boundaries fixed for each tenant and environment; vertexAI remains a compatible flag, but conflicting explicit flags throw.
  • Make environment fallback deliberate: GOOGLE_GENAI_USE_ENTERPRISE takes precedence over GOOGLE_GENAI_USE_VERTEXAI, and GOOGLE_API_KEY takes precedence over GEMINI_API_KEY. Reject ambiguous deployment settings instead of relying on whichever credential is discovered first.
  • Prefer an attached workload identity or trusted application-default credentials with least-privilege IAM for cloud production. Version 1.20.0 also accepts an explicit API key with cloud project/location; their presence does not establish that workload authentication is in use. Keep long-lived Gemini keys on the server.
  • Restrict client-level and per-request HttpOptions.BaseUrl, BaseUrlResourceScope, Headers, and ClientOptions.HttpClientFactory to trusted code. Also protect Client.setDefaultBaseUrl, GOOGLE_GEMINI_BASE_URL, and