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
dotCMS Version
main
Links
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 athttps://openrouter.ai/api/v1(overridable viaendpoint). Supports chat (streaming and non-streaming); OpenRouter offers no embeddings or image-generation endpoints, so those throwUnsupportedOperationException. Model IDs use OpenRouter's namespaced form.{ "chat": { "provider": "openrouter", "model": "openai/gpt-4o", "apiKey": "sk-or-...", "maxTokens": 4096, "temperature": 0.7 } }Acceptance Criteria
provider: "openrouter"inproviderConfig.openai/gpt-4o,anthropic/claude-sonnet-4) are passed through correctly.endpointoverrides the default base URL when set (proxies/gateways).provider: "openrouter"throws a clearUnsupportedOperationException.LangChain4jModelFactoryTest.dotCMS Version
main
Links