Google Gen AI SDK for Go 1.70.0

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. 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.Backend explicitly. BackendEnterprise maps to BackendVertexAI; with an unspecified backend, GOOGLE_GENAI_USE_ENTERPRISE takes precedence over GOOGLE_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 Project and Location explicitly for that mode; an omitted cloud location can become global. Separate identities, quotas, and data by environment and tenant policy.
  • Remove conflicting credential configuration: GOOGLE_API_KEY wins over GEMINI_API_KEY, and explicit cloud credentials or project/location can displace an environment key. Verify the resolved identity and routing without dumping ClientConfig, which contains the API key.
  • Make a custom cloud HTTPClient perform authentication; supplying one bypasses automatic authenticated-client construction. Use ClientConfig.UseDefaultCredentials when appropriate or provide a reviewed authenticated transport. Merely assigning Credentials alongside a custom client does not install its authorization middleware.
  • Select HTTPOptions.APIVersion for