Sample app showing how to access Gemini using the Gemini API.
-
Download and install Go, see https://go.dev/. To determine the version of Go that is available on your path run:
go version
-
[Optional] Install
gcloud
CLI, see https://cloud.google.com/sdk/docs/install.
-
Clone this repo.
git clone git@github.com:fredsa/hello-gemini-api.git
-
Change into the project directory.
cd hello-gemini-api
-
Install the
github.com/google/generative-ai-go/genai
package.go get github.com/google/generative-ai-go/genai
-
Create API key from ai.google.dev.
-
Modify
main.go
to use this API key.const apiKey = "your-api-key" // Keep safe.
-
Keep your API key safe.
-
Compile and run.
go run main.go
The output should look something like this
>> Hello, who are you? I am a large language model, trained by Google.