Google Gen AI SDK for Go 1.70.0
Last reviewed Sep 19, 2026
Prompt Details
Prompt Composition
2prompts
- Go 1.27130 lines · 5.5K tokens
- Google Gen AI SDK for Go 1.70.068 lines · 3.5K tokens
Total198 lines · 9K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 89
- 94
- 117
- 190
- 201
- 208
- 209
- 250
- 252
- 257
- 287
- 295
- 307
- 319
- 323
- 327
- 338
- 345
- 347
- 352
- 362
- 367
- 378
- 426
- 444
- 488
- 494
- 532
- 639
- 732
- 759
- 770
- 772
- 807
- 841
- 862
- 863
- 915
- 916
- 918
- 922
- 942
- 1004
- 1275
- 1395
- 1426
- 1427
Prompt Preview
Apply the Go 1.27 baseline first. These rules cover google.golang.org/genai v1.70.0 with the Gemini Developer API and the Vertex AI/Gemini Enterprise Agent Platform backend. The module requires Go 1.24 or newer; that compilation minimum does not establish ongoing Go security support.
Client mode and identity
- Set
ClientConfig.Backendexplicitly.BackendEnterprisemaps toBackendVertexAI; with an unspecified backend,GOOGLE_GENAI_USE_ENTERPRISEtakes precedence overGOOGLE_GENAI_USE_VERTEXAI. Do not let request data or tenant configuration select credentials or backend. - Use a protected server-side API key for Gemini or intentionally chosen cloud express mode, and prefer workload identity with least-privilege IAM for project-based cloud access. Set
ProjectandLocationexplicitly for that mode; an omitted cloud location can becomeglobal. Separate identities, quotas, and data by environment and tenant policy. - Remove conflicting credential configuration:
GOOGLE_API_KEYwins overGEMINI_API_KEY, and explicit cloud credentials or project/location can displace an environment key. Verify the resolved identity and routing without dumpingClientConfig, which contains the API key. - Make a custom cloud
HTTPClientperform authentication; supplying one bypasses automatic authenticated-client construction. UseClientConfig.UseDefaultCredentialswhen appropriate or provide a reviewed authenticated transport. Merely assigningCredentialsalongside a custom client does not install its authorization middleware. - Select
HTTPOptions.APIVersionfor