gemini

package
v0.1.52 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package gemini provides Google Gemini API integration for the LLM gateway.

Index

Constants

This section is empty.

Variables

View Source
var Registration = providers.Registration{
	Type: "gemini",
	New:  New,
	Discovery: providers.DiscoveryConfig{
		DefaultBaseURL: defaultOpenAICompatibleBaseURL,
	},
}

Registration provides factory registration for the Gemini provider.

Functions

func New

New creates a new Gemini provider.

Types

type Provider

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

Provider implements the core.Provider interface for Google Gemini

func NewVertexWithHTTPClient

func NewVertexWithHTTPClient(providerCfg providers.ProviderConfig, opts providers.ProviderOptions, httpClient *http.Client) *Provider

NewVertexWithHTTPClient creates a Vertex-configured Gemini provider using an already-authenticated HTTP client. It is used by the vertex package so Vertex owns Google auth while reusing Gemini request/response translation.

func NewWithHTTPClient

func NewWithHTTPClient(apiKey string, httpClient *http.Client, hooks llmclient.Hooks) *Provider

NewWithHTTPClient creates a new Gemini provider with a custom HTTP client. If httpClient is nil, http.DefaultClient is used.

func (*Provider) CancelBatch

func (p *Provider) CancelBatch(ctx context.Context, id string) (*core.BatchResponse, error)

CancelBatch cancels a native Gemini batch job.

func (*Provider) ChatCompletion

func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)

ChatCompletion sends a chat completion request to Gemini

func (*Provider) CreateBatch

func (p *Provider) CreateBatch(ctx context.Context, req *core.BatchRequest) (*core.BatchResponse, error)

CreateBatch creates a native Gemini batch job through its OpenAI-compatible endpoint.

func (*Provider) CreateFile

func (p *Provider) CreateFile(ctx context.Context, req *core.FileCreateRequest) (*core.FileObject, error)

CreateFile uploads a file through Gemini's OpenAI-compatible /files API.

func (*Provider) DeleteFile

func (p *Provider) DeleteFile(ctx context.Context, id string) (*core.FileDeleteResponse, error)

DeleteFile deletes a file object through Gemini's OpenAI-compatible /files API.

func (*Provider) Embeddings

Embeddings sends an embeddings request to Gemini via its OpenAI-compatible endpoint

func (*Provider) GetBatch

func (p *Provider) GetBatch(ctx context.Context, id string) (*core.BatchResponse, error)

GetBatch retrieves a native Gemini batch job.

func (*Provider) GetBatchResults

func (p *Provider) GetBatchResults(ctx context.Context, id string) (*core.BatchResultsResponse, error)

GetBatchResults fetches Gemini batch results via the output file API.

func (*Provider) GetFile

func (p *Provider) GetFile(ctx context.Context, id string) (*core.FileObject, error)

GetFile retrieves one file object through Gemini's OpenAI-compatible /files API.

func (*Provider) GetFileContent

func (p *Provider) GetFileContent(ctx context.Context, id string) (*core.FileContentResponse, error)

GetFileContent fetches raw file bytes through Gemini's /files/{id}/content API.

func (*Provider) ListBatches

func (p *Provider) ListBatches(ctx context.Context, limit int, after string) (*core.BatchListResponse, error)

ListBatches lists native Gemini batch jobs.

func (*Provider) ListFiles

func (p *Provider) ListFiles(ctx context.Context, purpose string, limit int, after string) (*core.FileListResponse, error)

ListFiles lists files through Gemini's OpenAI-compatible /files API.

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)

ListModels retrieves the list of available models from Gemini

func (*Provider) Responses

Responses sends a Responses API request to Gemini (converted to chat format)

func (*Provider) SetBaseURL

func (p *Provider) SetBaseURL(url string)

SetBaseURL allows configuring a custom base URL for the provider

func (*Provider) SetModelsURL

func (p *Provider) SetModelsURL(url string)

SetModelsURL allows configuring a custom models API base URL. This is primarily useful for tests and local emulators.

func (*Provider) StreamChatCompletion

func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)

StreamChatCompletion returns a raw response body for streaming (caller must close)

func (*Provider) StreamResponses

func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)

StreamResponses returns a raw response body for streaming Responses API (caller must close)

Jump to

Keyboard shortcuts

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