gemini

package module
v0.0.0-...-b6ec562 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 18 Imported by: 0

README

Gemini

The Gemini provider for facades.AI() of Goravel.

Version

goravel/gemini goravel/framework
v1.18.x v1.18.x

Install

Run the command below in your project to install the package automatically:

./artisan package:install github.com/goravel/gemini

This registers the service provider and updates config/ai.go so ai.providers.gemini.via resolves through geminifacades.Gemini("gemini").

Or check the setup file to install the package manually.

Custom Failover

The provider marks these Gemini HTTP errors as failoverable by default:

Status Reason
429 Too Many Requests rate_limited
402 Payment Required insufficient_credits
503 Service Unavailable provider_overloaded

Configure failover rules to add Gemini-specific error message mappings. Plain strings use substring matching, and slash-delimited strings use Go regular expressions.

"gemini": map[string]any{
	"key": config.Env("GEMINI_API_KEY", ""),
	"failover": map[string][]string{
		"context_length_exceeded": {
			"maximum context length",
			"/(?i)context.*length/",
		},
	},
	"via": func() (ai.Provider, error) {
		return geminifacades.Gemini("gemini")
	},
}

Supported capabilities

  • Text prompting
  • Streaming responses
  • Tool calling
  • Prompt attachments
  • Provider-managed files via the Gemini files API
  • Image generation
  • Audio generation
  • Transcription

Not supported

  • Attachment-based image editing on the Gemini Developer API
  • Structured speaker segments in transcription responses

Gemini's Go SDK supports multimodal prompting, file uploads, image generation, and audio output, but image editing is only available through Vertex-specific APIs. This driver also treats diarization as prompt guidance only, so transcripts do not currently return segmented speaker metadata.

Testing

Run the command below to run all tests:

go test ./...

Run the live Gemini smoke test with a real API key:

GEMINI_API_KEY=your-key go test -run '^TestProviderPromptIntegration$' -v ./...

The smoke test skips automatically when GEMINI_API_KEY is not set.

Documentation

Index

Constants

View Source
const (
	Binding = "goravel.gemini"
	Name    = "Gemini"
)
View Source
const DefaultAudioVoice = "Aoede"
View Source
const DefaultImageModel = "imagen-4.0-generate-001"
View Source
const DefaultTextModel = "gemini-2.5-flash"

Variables

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewGemini

func NewGemini(config contractsconfig.Config, provider string) (*Provider, error)

func (*Provider) Audio

func (*Provider) DeleteFile

func (r *Provider) DeleteFile(ctx context.Context, id string) error

func (*Provider) GetFile

func (r *Provider) GetFile(ctx context.Context, id string) (contractsai.FileResponse, error)

func (*Provider) Image

func (*Provider) Prompt

func (*Provider) PutFile

func (*Provider) Stream

type ServiceProvider

type ServiceProvider struct{}

func (*ServiceProvider) Boot

func (r *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (r *ServiceProvider) Register(app foundation.Application)

func (*ServiceProvider) Relationship

func (r *ServiceProvider) Relationship() binding.Relationship

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL