What instrumentation is missing
The Google GenAI Go SDK (google.golang.org/genai v1.41.0) exposes an image generation API via client.Models.GenerateImages() (Imagen models). The genai HTTP router in trace/contrib/genai/tracegenai.go only matches four path patterns:
func containsGenerateContent(path string) bool {
return strings.Contains(path, ":generateContent") ||
strings.Contains(path, "/generateContent") ||
strings.Contains(path, ":streamGenerateContent") ||
strings.Contains(path, "/streamGenerateContent")
}
func containsEmbedContent(path string) bool {
return strings.Contains(path, ":embedContent") ||
strings.Contains(path, "/embedContent") ||
strings.Contains(path, ":batchEmbedContents") ||
strings.Contains(path, "/batchEmbedContents")
}
The Imagen API uses the :predict method suffix:
POST https://generativelanguage.googleapis.com/v1beta/models/imagen-4.0-generate-001:predict
This path contains neither :generateContent nor :embedContent variants, so genaiRouter returns nil and all GenerateImages calls are untraced.
Go SDK usage
result, err := client.Models.GenerateImages(ctx,
"imagen-4.0-generate-001",
"A photorealistic image of a cat",
&genai.GenerateImagesConfig{NumberOfImages: 1},
)
What could be traced
A dedicated generateImagesTracer (similar to the existing generateContentTracer and embedContentTracer) matching :predict paths on Imagen model IDs could capture:
braintrust.input_json: {"model": "imagen-4.0-generate-001", "prompt": "...", "config": {...}}
braintrust.output_json: image output summary — e.g. {"images_count": 1, "mime_type": "image/png"} (raw pixel bytes omitted, matching the embeddingsOutputSummary convention of not logging raw vectors)
braintrust.metadata: model, numberOfImages, aspectRatio, safetyFilterLevel, outputOptions
Note: the :predict path is also shared by Imagen's EditImage and UpscaleImage methods; the model ID in the path (e.g. imagen-4.0-generate-001 vs imagegeneration@006) distinguishes them.
Braintrust docs status
supported (Python only) — the Braintrust Gemini integration docs include this in the operations table:
"generate_images and async generate_images | Image generation calls, with generated image output captured in the span output. Python only."
This confirms generate_images tracing is an intended Braintrust capability for the GenAI SDK; Go is currently the only unsupported runtime.
Source: https://www.braintrust.dev/docs/integrations/ai-providers/gemini
Upstream sources
Local repo files inspected
trace/contrib/genai/tracegenai.go — genaiRouter and path-matching helpers (containsGenerateContent, containsEmbedContent): no :predict case
trace/contrib/genai/generatecontent.go — reference pattern for request parsing and response instrumentation
trace/contrib/genai/embedcontent.go — reference pattern for output summary (shape-only, no raw vectors)
trace/contrib/genai/go.mod — google.golang.org/genai v1.41.0 (Models.GenerateImages available in this version)
trace/contrib/genai/tracegenai_test.go — no tests for :predict / Imagen paths
examples/internal/genai/main.go — no GenerateImages example
What instrumentation is missing
The Google GenAI Go SDK (
google.golang.org/genai v1.41.0) exposes an image generation API viaclient.Models.GenerateImages()(Imagen models). The genai HTTP router intrace/contrib/genai/tracegenai.goonly matches four path patterns:The Imagen API uses the
:predictmethod suffix:This path contains neither
:generateContentnor:embedContentvariants, sogenaiRouterreturnsniland allGenerateImagescalls are untraced.Go SDK usage
What could be traced
A dedicated
generateImagesTracer(similar to the existinggenerateContentTracerandembedContentTracer) matching:predictpaths on Imagen model IDs could capture:braintrust.input_json:{"model": "imagen-4.0-generate-001", "prompt": "...", "config": {...}}braintrust.output_json: image output summary — e.g.{"images_count": 1, "mime_type": "image/png"}(raw pixel bytes omitted, matching theembeddingsOutputSummaryconvention of not logging raw vectors)braintrust.metadata:model,numberOfImages,aspectRatio,safetyFilterLevel,outputOptionsNote: the
:predictpath is also shared by Imagen'sEditImageandUpscaleImagemethods; the model ID in the path (e.g.imagen-4.0-generate-001vsimagegeneration@006) distinguishes them.Braintrust docs status
supported (Python only) — the Braintrust Gemini integration docs include this in the operations table:
This confirms
generate_imagestracing is an intended Braintrust capability for the GenAI SDK; Go is currently the only unsupported runtime.Source: https://www.braintrust.dev/docs/integrations/ai-providers/gemini
Upstream sources
google.golang.org/genaipkg.go.dev —Models.GenerateImages: https://pkg.go.dev/google.golang.org/genai#Models.GenerateImagesLocal repo files inspected
trace/contrib/genai/tracegenai.go—genaiRouterand path-matching helpers (containsGenerateContent,containsEmbedContent): no:predictcasetrace/contrib/genai/generatecontent.go— reference pattern for request parsing and response instrumentationtrace/contrib/genai/embedcontent.go— reference pattern for output summary (shape-only, no raw vectors)trace/contrib/genai/go.mod—google.golang.org/genai v1.41.0(Models.GenerateImagesavailable in this version)trace/contrib/genai/tracegenai_test.go— no tests for:predict/ Imagen pathsexamples/internal/genai/main.go— noGenerateImagesexample