@ragpipe/plugin-gemini
v0.4.0
Published
Gemini embedding and generation plugin for ragpipe
Maintainers
Readme
@ragpipe/plugin-gemini
Google Gemini embedding and generation plugin for ragpipe.
Install
pnpm add ragpipe @ragpipe/plugin-geminiUsage
import { defineConfig } from "ragpipe";
import { geminiEmbedding, geminiGeneration } from "@ragpipe/plugin-gemini";
export default defineConfig({
embedding: geminiEmbedding({
apiKey: process.env.GEMINI_API_KEY ?? "",
model: "gemini-embedding-001",
}),
generation: geminiGeneration({
apiKey: process.env.GEMINI_API_KEY ?? "",
model: "gemini-3.1-flash-lite-preview",
systemPrompt: "Answer based on the provided context.",
}),
// ... vectorStore
});API
geminiEmbedding(options)
Returns an EmbeddingPlugin that calls the Gemini Embedding API.
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | — | Google AI API key (required) |
| model | string | - | Embedding model name (required) |
- Dimensions: 3072
- Rate limit: 800ms between calls (built-in)
- Batch support:
embedMany()usesbatchEmbedContentsfor efficient bulk embedding
geminiGeneration(options)
Returns a GenerationPlugin that calls the Gemini Content Generation API.
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | — | Google AI API key (required) |
| model | string | - | Generation model name (required) |
| systemPrompt | string | "Answer based on the provided context." | Default system instruction |
- Streaming:
generateStream()returns anAsyncIterable<string>via SSE - History: Pass
{ history }to include conversation context - Per-call override: Pass
{ systemPrompt }at call time to override the default
Get an API Key
- Go to Google AI Studio
- Create an API key
- Set it as
GEMINI_API_KEYin your environment
License
MIT
