Interface LlmClientFactory

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 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()
      Returns true if this provider requires an API key to function. Providers that run locally without authentication (e.g. Ollama, vLLM) should override this to return false.

      Used by the bootstrap module to determine whether to include a provider when no explicit API key is configured.

      Returns:
      true if an API key is required; false otherwise
    • create

      Creates a new LLM client from a LlmClientFactoryContext: the JSON mapper, the neutral LlmClientConfiguration, and the LlmSecretResolver the 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 be null
      Returns:
      a fully constructed LLM client ready to execute requests
      Throws:
      LlmProviderConfigurationException - if a required value is missing or invalid