Class LlmCompletionService

java.lang.Object
org.mockserver.llm.client.LlmCompletionService

public class LlmCompletionService extends Object
Orchestrates an outbound completion against a real LLM backend: looks up the per-provider LlmClient, builds the request, sends it via the LlmTransport, and parses the response into a Completion.

This is the single entry point used by runtime-LLM features (drift detection, semantic matching). It enforces the roadmap's safety rules:

  • Off unless configured — callers resolve a backend via LlmBackendResolver; with none, the feature is simply unavailable.
  • Fail closed — any timeout, transport error, non-2xx status, or parse failure returns Optional.empty() and logs one line. A flaky network must never flip an assertion.
  • Reproducible — clients pin temperature=0/seed; responses are cached per (provider, model, base URL, normalised prompt) so a given input is stable within a run.
Never sits on the deterministic assertion/matching path itself.