Package org.mockserver.llm.client
Class LlmBackendResolver
java.lang.Object
org.mockserver.llm.client.LlmBackendResolver
Resolves which
LlmBackend a runtime-LLM feature should use, across the
three config layers (simplest first):
- Provider env conventions — auto-detect from
OPENAI_API_KEY/ANTHROPIC_API_KEY/GEMINI_API_KEY/OLLAMA_HOST(the same vars each provider SDK reads). - MockServer properties — a single default backend via
mockserver.llmProvider/llmApiKey/llmModel/llmBaseUrl. - Named backends JSON —
mockserver.llmBackendsConfigpoints at a JSON array of backends, selectable by name.
The environment lookup is injected so the resolver is unit-testable without mutating the real process environment.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAll named backends from the layer-3 JSON file, keyed by name.resolveByName(String name) Resolve a named backend from the layer-3 JSON file.Resolve the default backend: explicit MockServer properties (layer 2) if a provider is configured, otherwise an env-detected backend (layer 1), otherwise empty.
-
Constructor Details
-
LlmBackendResolver
public LlmBackendResolver() -
LlmBackendResolver
-
-
Method Details
-
resolveDefault
Resolve the default backend: explicit MockServer properties (layer 2) if a provider is configured, otherwise an env-detected backend (layer 1), otherwise empty. -
resolveByName
Resolve a named backend from the layer-3 JSON file. Empty if no file is configured, the file cannot be read, or no entry matches the name. -
namedBackends
All named backends from the layer-3 JSON file, keyed by name. Empty if not configured or unreadable (a parse error is logged, not thrown).
-