Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

yukinagae/genkit-go-plugins

Repository files navigation

Firebase Genkit Logo Go Logo

Important

Great news!
Compatible OpenAI plugins are now available in the official Firebase Genkit repository: 👉 https://github.com/firebase/genkit/tree/main/go/plugins/compat_oai

This repository is archived and no longer maintained.
Please use and contribute to the above repository instead.

Thank you!

Firebase Genkit Go Community Plugins

Go Reference Go Report Card GitHub License

This repository contains Go community plugins for Firebase Genkit.

Available plugins

Model / Embedding Plugins

  • openai - Plugins for OpenAI APIs

Installation

go get github.com/yukinagae/genkit-go-plugins@latest

Usage

OpenAI

Get your OpenAI API key from here and run:

export OPENAI_API_KEY=your-api-key

Run genkit start -o with the following sample code:

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/genkit"

	"github.com/yukinagae/genkit-go-plugins/plugins/openai"
)

func main() {
	ctx := context.Background()

	if err := openai.Init(ctx, nil); err != nil {
		log.Fatal(err)
	}

	genkit.DefineFlow("sampleFlow", func(ctx context.Context, input string) (string, error) {
		model := openai.Model("gpt-4o-mini")

		resp, err := model.Generate(ctx,
			ai.NewGenerateRequest(
				&ai.GenerationCommonConfig{Temperature: 1},
				ai.NewUserTextMessage("Hello!")),
			nil)
		if err != nil {
			return "", err
		}

		text := resp.Text()
		return text, nil
	})

	if err := genkit.Init(ctx, nil); err != nil {
		log.Fatal(err)
	}
}

See the official Genkit Go Documentation for more details.

Contributing

We welcome contributions to this project! To get started, please refer to our Contribution Guide.