RoutingLLMPromptExecutor
Executes prompts with load balancing across multiple LLM clients.
Delegates client selection to LLMClientRouter, which determines which client should handle each request based on the requested model. This enables load distribution strategies like round-robin, weighted routing, or health-based selection.
Parameters
Router responsible for selecting appropriate clients for each request
Optional fallback configuration when no client is available for the requested model
This class remains open for source and binary compatibility with existing subclasses. For new custom prompt executors, prefer extending ai.koog.prompt.executor.model.DynamicPromptExecutor. If you subclass this class, prefer overriding the ResolvedModel-based overloads. Override the LLModel-based overloads only when you intentionally take over the full model-resolution and execution flow.
Constructors
Creates executor with a map of providers to their client lists. Uses RoundRobinRouter for load distribution.
Creates executor with a list of clients. Clients are grouped by provider and routed using RoundRobinRouter.
Creates executor with a list of clients. Clients are grouped by provider and routed using RoundRobinRouter.
Types
Functions
Executes a given prompt using the specified tools and resolved model, and returns the assistant response. Preferred extension point for subclasses that want to preserve this executor's model-resolution flow.
Executes a given prompt using the specified tools and model, and returns the assistant response.
Executes a given prompt using the specified tools and resolved model and returns the model choices. Preferred extension point for subclasses that want to preserve this executor's model-resolution flow.
Executes a given prompt using the specified tools and model and returns the model choices.
Executes the given prompt with the specified resolved model and streams the response in chunks as a flow. Preferred extension point for subclasses that want to preserve this executor's model-resolution flow.
Executes the given prompt with the specified model and streams the response in chunks as a flow.
Executes a prompt with structured output, enhancing it with schema instructions or native structured output parameter, and parses the response into the defined structure.
Basic JSON schema generator required for the given model. Return BasicJsonSchemaGenerator by default.
Standard JSON schema generator required for the given model. Return StandardJsonSchemaGenerator by default.
Moderates the provided multi-modal content using the specified resolved model. Preferred extension point for subclasses that want to preserve this executor's model-resolution flow.
Moderates the provided multi-modal content using the specified model.
Parses a structured response from the assistant message using the provided structured output configuration and language model. If a fixing parser is specified in the configuration, it will be used; otherwise, the structure will be parsed directly.
Resolves the LLModel to use for the given promptExecutorOperation by checking whether the router has a client for the model's provider, falling back to FallbackPromptExecutorSettings.fallbackModel when no direct client matches.