DEV Community
dev.to › pradumnasaraf › building-an-ai-powered-cli-with-golang-and-google-gemini-45a1
Building an AI-Powered CLI with Golang and Google Gemini - DEV Community
August 27, 2024 - package cmd import ( "context" "fmt" "log" "os" "github.com/google/generative-ai-go/genai" "github.com/spf13/cobra" "google.golang.org/api/option" ) // searchCmd represents the search command var searchCmd = &cobra.Command{ Use: "search", Short: "A brief description of your command", // Added the getResponse() function Run: func(cmd *cobra.Command, args []string) { getResponse() }, } func init() { rootCmd.AddCommand(searchCmd) } func getResponse() { ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close() model := client.GenerativeModel("gemini-1.5-flash") resp, err := model.GenerateContent(ctx, genai.Text("Write a story about a AI and magic")) if err != nil { log.Fatal(err) } fmt.Println(resp.Candidates[0].Content.Parts[0]) }
Liu Houliang
liuhouliang.com › en › post › go_gemini
Use Google Gemini API in Go - Liu Houliang
February 19, 2024 - Call client.Close() to close it proactively. Use a model specifically tailored to your use case (e.g., gemini-pro-vision for multimodal input, gemini-pro for text generation and continuous dialogue). import "github.com/google/generative-ai-go/genai" import "google.golang.org/api/option" ctx := context.Background() // Access your API key as an environment variable (see "Set up your API key" above) client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close() model := client.GenerativeModel("MODEL_NAME") When the prompt input i
A simple guide to setting up Gemini 2.5 Pro, free, without running into 3rd party rate limits
They just announced pricing for the 2.5 model, enjoy it while the promotional period lasts, it won't be free for much longer... More on reddit.com
Gemini-Go
I'm here to share this very simple library to talk to the Gemini API. https://github.com/estefspace/gemini-go More on reddit.com
Videos
06:27
2DT SWE | Golang GPT + Gemini Analyzer | How to use Gemini API ...
04:09
Ground Gemini with Google Search with the Gen AI SDK - YouTube
12:07
Gemini API with Python - Getting Started Tutorial - YouTube
06:43
Google Launches an Agent SDK - Agent Development Kit - YouTube
10:55
Gemini 2.5 Pro + Cline: FULLY FREE AI Coder! Develop a Full-stack ...
GitHub
github.com › google › generative-ai-go
GitHub - google/generative-ai-go: Go SDK for Google Generative AI · GitHub
Starred by 856 users
Forked by 101 users
Languages Go 98.7% | Shell 1.3%
GitHub
github.com › googleapis › go-genai
GitHub - googleapis/go-genai: Google Gen AI Go SDK provides an interface for developers to integrate Google's generative models into their Go applications. · GitHub
May 22, 2026 - import "google.golang.org/genai" ... location, Backend: genai.BackendEnterprise, }) You can create a client by configuring the necessary environment variables....
Starred by 1.1K users
Forked by 152 users
Languages Go
Reddit
reddit.com › r/golang › working with gemini api in go
r/golang on Reddit: working with gemini api in go
March 20, 2024 -
ive been wanting to use the gemini api in some projects i have but the documentation is not very helpful and provides barely any information in go while other languages are very well documented in the official gemini api documentation. anyone who knows how it it can be used please help
Top answer 1 of 3
3
https://ai.google.dev/tutorials/go_quickstart
2 of 3
3
Thats a nice example! If your operating on any GCP compute service like GCE or Cloud Run, you dont need to authenticate like that - gcp compute services have metadata server which client will pull from. Other helpful tip: genai.Part is an interface - so you can use type assertion to convert to strings as needed. If you need RAG either use an OSS or MatchingEngine now known as Vector Search. Powerful stuff. You'll also need Gecko for embeddings.
GitHub
github.com › makew0rld › go-gemini
GitHub - makew0rld/go-gemini: Client and server library for the Gemini protocol, in Go.
Starred by 67 users
Forked by 8 users
Languages Go 100.0% | Go 100.0%
GitHub
github.com › jyap808 › go-gemini
GitHub - jyap808/go-gemini: Gemini API in Golang
go-gemini is an implementation of the Gemini API (public and private) in Golang. Based off of https://github.com/toorop/go-bittrex/ import "github.com/jyap808/go-gemini" This library is more of a framework for some bots I use so it is expected ...
Author jyap808
Eli Bendersky
eli.thegreenplace.net › 2023 › using-gemini-models-from-go
Using Gemini models from Go - Eli Bendersky's website
package main import ( "context" "encoding/json" "fmt" "log" "os" "github.com/google/generative-ai-go/genai" "google.golang.org/api/option" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close() model := client.GenerativeModel("gemini-pro-vision") imgData1, err := os.ReadFile("../images/turtle1.png") if err != nil { log.Fatal(err) } imgData2, err := os.ReadFile("../images/turtle2.png") if err != nil { log.Fatal(err) } prompt := []genai.Part{ genai.ImageData("png", imgData1), genai.ImageData("png", imgData2), genai.Text("Describe the difference between these two pictures, with scientific detail"), } resp, err := model.GenerateContent(ctx, prompt...) if err != nil { log.Fatal(err) } bs, _ := json.MarshalIndent(resp, "", " ") fmt.Println(string(bs)) }
OneUptime
oneuptime.com › home › blog › use the google gen ai go sdk to call gemini models from a cloud function
Use the Google Gen AI Go SDK to Call Gemini Models from a Cloud Function
February 17, 2026 - Here is a Cloud Function that takes a prompt and returns a Gemini response. package myfunction import ( "context" "encoding/json" "fmt" "log" "net/http" "os" "github.com/GoogleCloudPlatform/functions-framework-go/functions" "google.golang.org/genai" ) // init registers the Cloud Function entry point func init() { functions.HTTP("GenerateText", GenerateText) } // GenerateRequest represents the incoming request payload type GenerateRequest struct { Prompt string `json:"prompt"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float32 `json:"temperature,omitempty"` } // GenerateResponse re
Go Packages
pkg.go.dev › git.sr.ht › ~yotam › go-gemini
gemini package - git.sr.ht/~yotam/go-gemini - Go Packages
ErrorResponse create a response from the given error with the error string as the Meta field. If the error is of type gemini.Error, the status will be taken from the status field, otherwise it will default to StatusTemporaryFailure.
Medium
kkamalesh117.medium.com › build-golang-gemini-ai-chat-63e520d29f42
Build GoLang Gemini-AI Chat. Powered with Redis Cache | LINK For… | by Kamalesh D | Medium
September 14, 2024 - In this blog post, we’ll explore how to create a chat application powered by Gemini PRO using the Go programming language. We’ll cover the integration of this model, handling user prompts, and implementing a apikey based caching system for a more personalized experience. To utilize this application, you’ll need an API key from ai.google.dev · Go (Golang): A statically typed, compiled language designed for simplicity and efficiency.
Go Packages
pkg.go.dev › google.golang.org › genai
genai package - google.golang.org/genai - Go Packages
3 weeks ago - Gemini API on Gemini Enterprise Agent Platform: Set GOOGLE_GENAI_USE_ENTERPRISE, GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION, as shown below: export GOOGLE_GENAI_USE_ENTERPRISE=true export GOOGLE_CLOUD_PROJECT='your-project-id' export GOOGLE_CLOUD_LOCATION='us-central1' client, err := ...
Go Packages
pkg.go.dev › github.com › google › generative-ai-go › genai
genai package - github.com/google/generative-ai-go/genai - Go Packages
May 2, 2025 - package main import ( "context" "fmt" "log" "os" "github.com/google/generative-ai-go/genai" "google.golang.org/api/option" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close() model := client.GenerativeModel("gemini-1.5-flash") cs := model.StartChat() cs.History = []*genai.Content{ { Parts: []genai.Part{ genai.Text("Hello, I have 2 dogs in my house."), }, Role: "user", }, { Parts: []genai.Part{ genai.Text("Great to meet you.
Go Packages
pkg.go.dev › google.golang.org › adk › model › gemini
gemini package - google.golang.org/adk/model/gemini - Go Packages
January 30, 2026 - func NewModel(ctx context.Context, modelName string, cfg *genai.ClientConfig) (model.LLM, error) NewModel returns model.LLM, backed by the Gemini API.
Google AI
ai.google.dev › gemini api › using gemini api keys
Using Gemini API keys | Google AI for Developers
1 week ago - import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY" }); async function main() { const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", input: "Explain how AI works in a few words", }); console.log(interaction.output_text); } main(); package main import ( "context" "fmt" "log" "google.golang.org/genai" "google.golang.org/genai/interactions" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, &genai.ClientConfig{ APIKey: "YOUR_API_KEY", Backend: genai.BackendGeminiAPI, }) if err != nil { log.Fatal(err