Skip to content

Gemini ​

@anvia/gemini connects Anvia to Google's Gemini API or Gemini models on Vertex AI. One GeminiClient creates provider-neutral models for completions, embeddings, image generation, and transcription.

Choose the connection at the application boundary. Agents, extractors, pipelines, and media workflows receive an Anvia model and do not need to know which Google endpoint created it.

Choose a connection ​

DeploymentClient configurationAuthentication
Gemini APIapiKeyGEMINI_API_KEY
Vertex AIvertexai, project, and locationGoogle Application Default Credentials or googleAuthOptions
Existing Google SDK clientclientOwned by the application

Start with the Gemini API for a simple API-key integration. Use Vertex AI when the application already relies on Google Cloud IAM, project-level quotas, or regional deployment controls.

Create a completion model ​

ts
import { GeminiClient } from '@anvia/gemini'

const gemini = new GeminiClient({
  apiKey: process.env.GEMINI_API_KEY,
})

export const model = gemini.completionModel(
  'gemini-2.5-flash',
)

Pass model to an agent, direct completion, extractor, or pipeline. Keep the client and credentials in server-only code.

Model factories ​

WorkloadFactoryAnvia contract
Text, tools, and multimodal understandingcompletionModel(...)Streaming completion model
Vector embeddingsembeddingModel(...)Embedding model
Gemini-native image generationimageGenerationModel(...)Image-generation model
Imagen generationimagenGenerationModel(...)Image-generation model
Audio transcriptiontranscriptionModel(...)Transcription model
Provider inventorylistModels()Normalized model list

These factories share a client, but they are different model contracts. For example, a completion model that understands an image cannot be passed where an image-generation model is required.

Completion capabilities ​

The completion adapter supports streaming, tools and tool choice, image input, document-like file input, output schemas, and reasoning content. The exact Gemini model and deployment must also support the requested capability.

In this section ​

Built for Anvia.