Record Class LlmBackend

java.lang.Object
java.lang.Record
org.mockserver.llm.client.LlmBackend

public record LlmBackend(String name, Provider provider, String baseUrl, String apiKey, String model, Map<String,String> headers, Long timeoutMillis) extends Record
Declares a real LLM backend that MockServer can call as a client (the opposite direction to the mock codecs, which build outbound mock responses). Used only by runtime-LLM features (drift detection, semantic matching) — never on the deterministic assertion/matching path.

Reuses the Provider enum as the "type", mirroring the codec registry so the provider taxonomy stays the single source of truth. Most fields are optional: baseUrl and model default per provider in the per-provider LlmClient, so enabling a backend is usually just a type plus a key (Ollama needs neither).

Immutable: headers is defensively copied to an unmodifiable map in the compact constructor. apiKey is a secret and is redacted by toString().

  • Constructor Details

    • LlmBackend

      public LlmBackend(String name, Provider provider, String baseUrl, String apiKey, String model, Map<String,String> headers, Long timeoutMillis)
      Creates an instance of a LlmBackend record class.
      Parameters:
      name - the value for the name record component
      provider - the value for the provider record component
      baseUrl - the value for the baseUrl record component
      apiKey - the value for the apiKey record component
      model - the value for the model record component
      headers - the value for the headers record component
      timeoutMillis - the value for the timeoutMillis record component
  • Method Details

    • of

      public static LlmBackend of(Provider provider, String apiKey)
      Convenience for the common case: a provider type and an API key, all other fields defaulted.
    • hasApiKey

      public boolean hasApiKey()
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • provider

      public Provider provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • baseUrl

      public String baseUrl()
      Returns the value of the baseUrl record component.
      Returns:
      the value of the baseUrl record component
    • apiKey

      public String apiKey()
      Returns the value of the apiKey record component.
      Returns:
      the value of the apiKey record component
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • headers

      public Map<String,String> headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • timeoutMillis

      public Long timeoutMillis()
      Returns the value of the timeoutMillis record component.
      Returns:
      the value of the timeoutMillis record component