Skip to content

[FEATURE] dotAI: LangChain4J integration — Phase 2 (Google AI Gemini) #36134

Description

@ihoffmann-dot

Problem Statement

dotCMS's LangChain4J integration supports Gemini models only through Google Vertex AI, which requires a GCP project, location and service-account/ADC authentication. Customers who want Gemini through the consumer-facing Gemini API (Google AI Studio) — a simple API key, no GCP project setup — have no way to configure dotAI for it without code changes. Vertex AI also lacks embeddings and image support in our integration, while the Gemini API exposes both through LangChain4J.

Solution

Add Google AI (Gemini API / AI Studio) as a supported provider in LangChain4jModelFactory under the identifier google_ai, distinct from the existing vertex_ai. Authenticates with a Google AI Studio API key. Supports chat (streaming and non-streaming), embeddings and image generation — full model-type coverage. The dimensions field maps to Gemini's outputDimensionality for embeddings; the size field maps to Gemini's imageSize (1K/2K) for image.

{
  "chat": {
    "provider": "google_ai",
    "model": "gemini-2.0-flash",
    "apiKey": "AIza...",
    "maxTokens": 4096,
    "temperature": 0.7
  },
  "embeddings": {
    "provider": "google_ai",
    "model": "gemini-embedding-001",
    "apiKey": "AIza...",
    "dimensions": 768
  },
  "image": {
    "provider": "google_ai",
    "model": "gemini-2.5-flash-image",
    "apiKey": "AIza...",
    "size": "1K"
  }
}

Acceptance Criteria

  • Chat completions work end-to-end using provider: "google_ai" in providerConfig.
  • Streaming chat works through the same provider.
  • Embeddings work, with dimensions controlling the output vector size.
  • Image generation works with Gemini image models (e.g. gemini-2.5-flash-image), with optional size (1K/2K).
  • endpoint overrides the default base URL when set.
  • Unit tests cover the Google AI builder paths in LangChain4jModelFactoryTest.

dotCMS Version

main

Links

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions