- All Known Implementing Classes:
FakeLlmClientFactory
public interface LlmClientFactory
Factory for creating
LlmClient instances for one provider.
Implementations are discovered via JPMS ServiceLoader. Each factory handles a single provider id
and lives in a provider module (for example agentforge4j-llm-openai).
-
Method Summary
Modifier and TypeMethodDescriptioncreate(LlmClientFactoryContext context) Creates a new LLM client from aLlmClientFactoryContext: the JSON mapper, the neutralLlmClientConfiguration, and theLlmSecretResolverthe provider uses to resolve its credential reference.Returns the provider id this factory creates clients for.default booleanReturnstrueif this provider requires an API key to function.
-
Method Details
-
getProviderName
String getProviderName()Returns the provider id this factory creates clients for.- Returns:
- non-blank provider id such as
"openai"or"ollama"
-
requiresApiKey
default boolean requiresApiKey()Returnstrueif this provider requires an API key to function. Providers that run locally without authentication (e.g. Ollama, vLLM) should override this to returnfalse.Used by the bootstrap module to determine whether to include a provider when no explicit API key is configured.
- Returns:
trueif an API key is required;falseotherwise
-
create
Creates a new LLM client from aLlmClientFactoryContext: the JSON mapper, the neutralLlmClientConfiguration, and theLlmSecretResolverthe provider uses to resolve its credential reference. Implementations read the neutral configuration and provider options, validate them, and construct the client.- Parameters:
context- the factory inputs; must not benull- Returns:
- a fully constructed LLM client ready to execute requests
- Throws:
LlmProviderConfigurationException- if a required value is missing or invalid
-