Skip to content

Google Gen AI Go SDK provides an interface for developers to integrate Google's generative models into their Go applications. This is an early release. API is subject to change. Please do not use this SDK in production environments at this stage

License

Notifications You must be signed in to change notification settings

gmh5225/go-genai

 
 

Repository files navigation

GitHub go.mod Go version

Google Gen AI Go SDK

The Google Gen AI Go SDK enables developers to use Google's state-of-the-art generative AI models (like Gemini) to build AI-powered features and applications. This SDK supports use cases like:

  • Generate text from text-only input
  • Generate text from text-and-images input (multimodal)
  • ...

For example, with just a few lines of code, you can access Gemini's multimodal capabilities to generate text from text-and-image input.

result, err := client.Models.GenerateContent(ctx,
  "gemini-2.0-flash-exp",
  genai.PartSlice{
    genai.Text("What's this image about?"),
    genai.InlineData{Data: imageBytes, MIMEType: "image/jpeg"},
  },
  nil,
)

Installation and usage

Add the SDK to your module with go get google.golang.org/genai.

Create Clients

Imports

import genai "google.golang.org/genai"

Gemini API Client:

client, err := genai.NewClient(ctx, &genai.ClientConfig{
	APIKey:   apiKey,
	Backend:  genai.BackendGoogleAI,
})

Vertex AI Client:

client, err := genai.NewClient(ctx, &genai.ClientConfig{
	Project:  project,
	Location: location,
	Backend:  genai.BackendVertexAI,
})

License

The contents of this repository are licensed under the Apache License, version 2.0.

About

Google Gen AI Go SDK provides an interface for developers to integrate Google's generative models into their Go applications. This is an early release. API is subject to change. Please do not use this SDK in production environments at this stage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%