Google Gen AI SDK for .NET 1

Last reviewed Oct 25, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. C# 14106 lines · 4.4K tokens
  2. Google Gen AI SDK for .NET 150 lines · 2.9K tokens
Total156 lines · 7.3K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 89
  • 94
  • 117
  • 190
  • 201
  • 208
  • 209
  • 214
  • 250
  • 257
  • 295
  • 319
  • 323
  • 327
  • 338
  • 345
  • 362
  • 367
  • 378
  • 426
  • 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 the active Google.GenAI 1.x line on a supported .NET runtime, for both the Gemini Developer API and Gemini Enterprise Agent Platform. The package targets net8.0 and netstandard2.0; package compatibility alone does not establish runtime support or feature availability on a backend.

Client identity and transport

  • Select Developer API or enterprise mode from server configuration when constructing Client; fix enterprise project and location to approved resources and regions. Do not let an HTTP caller choose enterprise, vertexAI, a provider account, or a shared client belonging to another tenant.
  • 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 SDK may use ambient values when constructor arguments are omitted, and GOOGLE_API_KEY wins when both API-key variables are set. Test the intended effective identity before serving requests.
  • Keep Developer API keys on an authenticated backend. For enterprise, use a restricted workload identity or application default credentials and authorize the caller's project resources separately; an OAuth scope or provider key does not enforce application tenant boundaries.
  • Reuse a Client only within its credential and backend boundary, and dispose it with its owner. Treat ClientOptions.HttpClientFactory instances as owned by the SDK when sharing or disposing clients.
  • Allowlist HTTPS scheme, host, and port for constructor and per-operation