From c8ff5bdad0daeed1fcc1e4ef46adb6844fe26182 Mon Sep 17 00:00:00 2001 From: Akira Daquisu Date: Sat, 15 Nov 2025 11:58:09 -0300 Subject: [PATCH 1/2] fix(docs): correct example for GenerateContent using an HTTP URL --- example_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/example_test.go b/example_test.go index 669f41f8..96c7a5fd 100644 --- a/example_test.go +++ b/example_test.go @@ -485,10 +485,26 @@ func ExampleModels_GenerateContent_httpURL_vertexai() { log.Fatal(err) } + // Download the image and store it in-memory + fileResp, err := http.Get("https://storage.googleapis.com/cloud-samples-data/generative-ai/image/scones.jpg") + if err != nil { + log.Fatal(err) + } + var fileBytes []byte + if fileResp != nil && fileResp.Body != nil { + fileBytes, _ = io.ReadAll(fileResp.Body) + fileResp.Body.Close() + } + // Call the GenerateContent method. parts := []*genai.Part{ {Text: "What's this picture about?"}, - {FileData: &genai.FileData{FileURI: "https://storage.googleapis.com/cloud-samples-data/generative-ai/image/scones.jpg", MIMEType: "image/jpeg"}}, + { + InlineData: &genai.Blob{ + MIMEType: "image/jpeg", + Data: fileBytes, + }, + }, } contents := []*genai.Content{{Parts: parts}} From bfe61494e9e7d08b4379a2e7d387ba6c700ce36c Mon Sep 17 00:00:00 2001 From: Akira Daquisu <50253469+Daquisu@users.noreply.github.com> Date: Fri, 26 Dec 2025 14:19:37 -0300 Subject: [PATCH 2/2] feat(docs): use latest flash model --- example_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_test.go b/example_test.go index 96c7a5fd..9da64e5f 100644 --- a/example_test.go +++ b/example_test.go @@ -508,7 +508,7 @@ func ExampleModels_GenerateContent_httpURL_vertexai() { } contents := []*genai.Content{{Parts: parts}} - result, err := client.Models.GenerateContent(ctx, "gemini-2.5-flash", contents, nil) + result, err := client.Models.GenerateContent(ctx, "gemini-flash-latest", contents, nil) if err != nil { log.Fatal(err) }