PromptExecutorBuilder

Builder for constructing a PromptExecutor that automatically selects the appropriate executor implementation based on the registered clients.

Executor selection heuristic (determined at build time):

  • If every registered provider appears exactly once, a MultiLLMPromptExecutor is created. It dispatches each request to the single client registered for the requested model's provider.

  • If any provider has more than one client registered, a RoutingLLMPromptExecutor is created. It load-balances requests across all clients for the same provider.

Obtain an instance through PromptExecutor.builder.

Example usage in Java:

// Two distinct providers → MultiLLMPromptExecutor
PromptExecutor executor = PromptExecutor.builder()
.addClient(openAIClient)
.addClient(anthropicClient)
.build();

// Two clients for the same provider → RoutingLLMPromptExecutor (load balanced)
PromptExecutor executor = PromptExecutor.builder()
.addClient(firstOpenAIClient)
.addClient(secondOpenAIClient)
.build();

See also

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard

Registers an additional LLMClient.

Link copied to clipboard
fun anthropic(apiKey: String, settings: AnthropicClientSettings = AnthropicClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System): PromptExecutorBuilder

Adds an Anthropic client.

Link copied to clipboard

Constructs a PromptExecutor from the registered clients.

Link copied to clipboard
fun dashscope(apiKey: String, settings: DashscopeClientSettings = DashscopeClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System, toolsConverter: OpenAICompatibleToolDescriptorSchemaGenerator = OpenAICompatibleToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds a Dashscope client.

Link copied to clipboard
fun deepseek(apiKey: String, settings: DeepSeekClientSettings = DeepSeekClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System, toolsConverter: OpenAICompatibleToolDescriptorSchemaGenerator = OpenAICompatibleToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds a DeepSeek client.

Link copied to clipboard

Configures a fallback model to use when no client is registered for the requested model's provider.

Link copied to clipboard
fun google(apiKey: String, settings: GoogleClientSettings = GoogleClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System): PromptExecutorBuilder

Adds a Google AI client.

Link copied to clipboard
fun mistral(apiKey: String, settings: MistralAIClientSettings = MistralAIClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System, toolsConverter: OpenAICompatibleToolDescriptorSchemaGenerator = OpenAICompatibleToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds a Mistral AI client.

Link copied to clipboard
fun ollama(baseUrl: String = "http://localhost:11434", baseClient: HttpClient = HttpClient(), timeoutConfig: ConnectionTimeoutConfig = ConnectionTimeoutConfig(), clock: Clock = Clock.System, contextWindowStrategy: ContextWindowStrategy = ContextWindowStrategy.Companion.None, toolDescriptorConverter: ToolDescriptorSchemaGenerator = OllamaToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds an Ollama client.

Link copied to clipboard
fun openAI(apiKey: String, settings: OpenAIClientSettings = OpenAIClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System, toolsConverter: OpenAICompatibleToolDescriptorSchemaGenerator = OpenAICompatibleToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds an OpenAI client.

Link copied to clipboard
fun openRouter(apiKey: String, settings: OpenRouterClientSettings = OpenRouterClientSettings(), baseClient: HttpClient = HttpClient(), clock: Clock = Clock.System, toolsConverter: OpenAICompatibleToolDescriptorSchemaGenerator = OpenAICompatibleToolDescriptorSchemaGenerator()): PromptExecutorBuilder

Adds an OpenRouter client.