fredsa / hello-gemini-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hello, Gemini API.

Sample app showing how to access Gemini using the Gemini API.

Prerequisites

  1. Download and install Go, see https://go.dev/. To determine the version of Go that is available on your path run:

    go version
  2. [Optional] Install gcloud CLI, see https://cloud.google.com/sdk/docs/install.

Prepare sample project

  1. Clone this repo.

    git clone git@github.com:fredsa/hello-gemini-api.git
  2. Change into the project directory.

    cd hello-gemini-api
  3. Install the github.com/google/generative-ai-go/genai package.

    go get github.com/google/generative-ai-go/genai

Authorize the app

  1. Create API key from ai.google.dev.

  2. Modify main.go to use this API key.

    const apiKey = "your-api-key"  // Keep safe.
  3. Keep your API key safe.

Run the sample

  1. 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.
    

About

License:Apache License 2.0


Languages

Language:Go 100.0%