Skip to content

New ModelRouter module#569

Open
hkuhn42 wants to merge 5 commits intolangchain4j:mainfrom
hkuhn42:main
Open

New ModelRouter module#569
hkuhn42 wants to merge 5 commits intolangchain4j:mainfrom
hkuhn42:main

Conversation

@hkuhn42
Copy link

@hkuhn42 hkuhn42 commented Feb 15, 2026

Issue

Closes langchain4j/langchain4j#4490

Change

Adds a new ModelRouter model with a pluggable ModelRoutingStrategy

  • New class ModelRouter
  • New interface ModelRoutingStrategy
  • ModelRoutingStrategy impl for failover routing
  • ModelRoutingStrategy impl for least token usage routing

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit tests in all modules, and they are all green
  • I have manually run all integration tests in the module I have added/changed, and they are all green

Checklist for adding new maven module

  • I have added my new module in the root pom.xml and langchain4j-community-bom/pom.xml

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
  • I have added a {NameOfIntegration}EmbeddingStoreRemovalIT that extends from EmbeddingStoreWithRemovalIT

Checklist for changing existing embedding store integration

  • I have manually verified that the {NameOfIntegration}EmbeddingStore works correctly with the data persisted using the latest released version of LangChain4j

@Martin7-1 Martin7-1 added enhancement New feature or request P2 High priority P3 Medium priority labels Feb 20, 2026
Copy link
Collaborator

@Martin7-1 Martin7-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkuhn42 Thanks for the great idea! Could you please run make format to make spotless happy?

BTW, please add some ITs to use real LLM call :)

hkuhn42 and others added 2 commits February 20, 2026 14:02
Co-authored-by: Martin7-1 <yi.zheng.se@gmail.com>
…ngchain4j/model/router/ChatModelWrapper.java

Co-authored-by: Martin7-1 <yi.zheng.se@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P2 High priority P3 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there any Interest in model routing capability?

3 participants

Comments