Google Gen AI SDK for .NET 1.21.0
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
2prompts
- C# 14106 lines · 4.4K tokens
- 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
Clientper configured credential and backend boundary, and dispose it with its owner. The SDK caches oneHttpClientand disposes even a client returned byClientOptions.HttpClientFactory; do not share a factory-returned instance with independently disposed SDK clients. - Choose
enterprise: falseorenterprise: truefrom server configuration. For enterprise workloads fixprojectandlocationexplicitly, including any residency constraint; an omitted location can resolve toglobal. Do not combine conflictingenterpriseand legacyvertexAIflags. - Control
GOOGLE_GENAI_USE_ENTERPRISE,GOOGLE_GENAI_USE_VERTEXAI,GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION,GOOGLE_API_KEY, andGEMINI_API_KEYat deployment. The enterprise environment flag takes precedence over the legacy flag, andGOOGLE_API_KEYtakes precedence overGEMINI_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-platformOAuth scope is not an IAM grant or a replacement for