Skip to content

feat(dotAI): Dot AI LangChain4J - OpenRouter#36136

Draft
ihoffmann-dot wants to merge 1 commit into
mainfrom
dot-ai-langchain-openrouter
Draft

feat(dotAI): Dot AI LangChain4J - OpenRouter#36136
ihoffmann-dot wants to merge 1 commit into
mainfrom
dot-ai-langchain-openrouter

Conversation

@ihoffmann-dot

Copy link
Copy Markdown
Member

Summary

Adds OpenRouter as a supported provider. OpenRouter aggregates hundreds of models
(OpenAI, Anthropic, Meta, Mistral, DeepSeek, etc.) behind a single OpenAI-compatible
API and one API key — the strategy reuses the LangChain4J OpenAI model classes
pointed at the OpenRouter base URL.

  • Add OpenRouterModelProviderStrategy registered in LangChain4jModelFactory.STRATEGIES
  • No new dependency — reuses langchain4j-open-ai with base URL https://openrouter.ai/api/v1
  • endpoint config field overrides the base URL (proxies/gateways)
  • Chat and streaming chat supported; embeddings and image throw UnsupportedOperationException (OpenRouter has no such endpoints)
  • Add 7 unit tests in LangChain4jModelFactoryTest

Configuration

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

Notes

  • Model IDs use OpenRouter's namespaced form: openai/gpt-4o, anthropic/claude-sonnet-4, deepseek/deepseek-r1.
  • maxRetries is not supported by the streaming chat model and is ignored with a warning (same behavior as the OpenAI provider).

Related Issue

This PR fixes #36133
EPIC: dotAI Multi-Provider Support #33970

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ihoffmann-dot's task in 55s —— View job


Rollback Safety Analysis

  • Read rollback-unsafe categories reference
  • Get full PR diff
  • Analyze diff against all unsafe categories
  • Post result and apply label

Result: ✅ Safe to Roll Back

Applied label: AI: Safe To Rollback

Analysis

The PR adds a single new Java strategy class (OpenRouterModelProviderStrategy) and registers it in LangChain4jModelFactory.STRATEGIES, plus Javadoc and unit tests. Checked against every category in the reference:

Category Check Verdict
C-1 Structural Data Model Change No DB tables touched ✅ Safe
C-2 Elasticsearch Mapping Change No ES mapping code ✅ Safe
C-3 Content JSON Model Version Bump No CURRENT_MODEL_VERSION change ✅ Safe
C-4 DROP TABLE / DROP COLUMN No DDL statements ✅ Safe
H-1 One-Way Data Migration No runonce task, no data transform ✅ Safe
H-2 RENAME TABLE / COLUMN None ✅ Safe
H-3 PK Restructuring None ✅ Safe
H-4 New ContentType Field Type Not a dotCMS field type ✅ Safe
H-5 Storage Provider Change No FileStorageAPI change ✅ Safe
H-6 DROP PROCEDURE / FUNCTION None ✅ Safe
H-7 NOT NULL column without default No schema change ✅ Safe
H-8 VTL Viewtool Contract Change No viewtool touched ✅ Safe
M-1 Column Type Change None ✅ Safe
M-2 Push Publishing Bundle Format None ✅ Safe
M-3 REST/GraphQL API Contract Change No endpoint signatures changed ✅ Safe
M-4 OSGi Plugin API Breakage No OSGi interface changed ✅ Safe

Rolling back after deploying this PR simply means the openrouter provider entry disappears from STRATEGIES. Any running instance configured with "provider": "openrouter" would fail to resolve the strategy on N-1 (falling through to "unknown provider"), but no data loss, no schema change, and no index corruption would occur. The application starts cleanly on N-1.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Codex Review — openai.gpt-5.5

No findings.


Run: #27393349189 · tokens: in: 3406 · out: 923 (reasoning: 914) · total: 4329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

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

1 participant