Skip to content

[FEATURE] dotAI: LangChain4J integration — Phase 2 (OpenRouter) #36133

Description

@ihoffmann-dot

Problem Statement

dotCMS's LangChain4J integration supports OpenAI, Azure OpenAI, Google Vertex AI and AWS Bedrock. Customers wanting access to a broad catalog of models (OpenAI, Anthropic, Meta, Mistral, DeepSeek, etc.) through a single API key and unified billing currently need a separate provider configuration per vendor. OpenRouter aggregates hundreds of models behind one OpenAI-compatible API, but there is no way to configure dotAI to use it without code changes.

Solution

Add OpenRouter as a supported provider in LangChain4jModelFactory. OpenRouter exposes an OpenAI-compatible API, so the strategy reuses the LangChain4J OpenAI model classes pointed at https://openrouter.ai/api/v1 (overridable via endpoint). Supports chat (streaming and non-streaming); OpenRouter offers no embeddings or image-generation endpoints, so those throw UnsupportedOperationException. Model IDs use OpenRouter's namespaced form.

{
  "chat": {
    "provider": "openrouter",
    "model": "openai/gpt-4o",
    "apiKey": "sk-or-...",
    "maxTokens": 4096,
    "temperature": 0.7
  }
}

Acceptance Criteria

  • Chat completions work end-to-end using provider: "openrouter" in providerConfig.
  • Streaming chat works through the same provider.
  • Namespaced model IDs (e.g. openai/gpt-4o, anthropic/claude-sonnet-4) are passed through correctly.
  • endpoint overrides the default base URL when set (proxies/gateways).
  • Attempting embeddings or image generation with provider: "openrouter" throws a clear UnsupportedOperationException.
  • Unit tests cover the OpenRouter 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