Class GeminiLlmClient

java.lang.Object
org.mockserver.llm.client.AbstractLlmClient
org.mockserver.llm.client.GeminiLlmClient
All Implemented Interfaces:
LlmClient

public class GeminiLlmClient extends AbstractLlmClient
Runtime client for the Google Gemini generateContent API. The API key is passed as a ?key= query parameter; assistant turns use the model role and system text is hoisted to systemInstruction.

Security note: Gemini's API-key auth mandates the key in the query string, so unlike header-based credentials it can appear in HTTP access/proxy logs. This is a property of the provider's API design, not a MockServer choice; in high-security environments front the call with a gateway that injects the key after ingress.

  • Constructor Details

    • GeminiLlmClient

      public GeminiLlmClient()
  • Method Details

    • provider

      public Provider provider()
      Description copied from interface: LlmClient
      The provider this client handles — the registry key.
    • buildCompletionRequest

      public HttpRequest buildCompletionRequest(LlmBackend backend, ParsedConversation prompt)
      Description copied from interface: LlmClient
      Build the outbound completion request (URL path, auth headers, request body) for the given backend and prompt. The returned request carries the socket address resolved from the backend's base URL (or the provider default). Implementations pin temperature=0 and a seed where the provider supports it, for reproducibility.
    • parseCompletionResponse

      public Completion parseCompletionResponse(HttpResponse response)
      Description copied from interface: LlmClient
      Parse a successful provider response body into a Completion. Implementations should tolerate missing optional fields and never throw for a well-formed-but-sparse response; malformed bodies may throw and are handled (fail-closed) by LlmCompletionService.