Google Gen AI SDK for Go 1.71.0
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
2prompts
- Go 1.27130 lines · 5.5K tokens
- Google Gen AI SDK for Go 1.71.0103 lines · 5.5K tokens
Total233 lines · 11K 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.71.0 with the Gemini Developer API and Vertex AI / Gemini Enterprise Agent Platform. The module's Go 1.24 minimum is a compilation requirement; use a supported, patched Go 1.27 toolchain. SDK types do not guarantee that every backend, API version, or model supports a feature.
Backend selection and credential resolution
- Set
ClientConfig.Backendexplicitly. With an unspecified backend,GOOGLE_GENAI_USE_ENTERPRISEtakes precedence overGOOGLE_GENAI_USE_VERTEXAI, even when its value selects Gemini instead of Vertex;BackendEnterpriseis normalized toBackendVertexAI. - Supply the Gemini API key through trusted server configuration and keep long-lived keys out of browser and mobile clients. If environment fallback is used, set only the intended variable:
GOOGLE_API_KEYwins overGEMINI_API_KEY, with a warning when both are present. - Never set explicit
CredentialsandAPIKeytogether; the constructor rejects them and includes the configuration in the error. Choose a reviewed Vertex authentication profile instead of mixing explicit and environment-derived settings whose precedence can clear the key or project/location. Explicit API key plus explicit project/location is supported in this tag. - Use a workload identity with only the required project permissions for Vertex. Automatic credential detection uses the
cloud-platformOAuth scope; that scope does not replace IAM restrictions on the identity. - When supplying
ClientConfig.HTTPClientfor Vertex, provide its