Package org.mockserver.llm.client
package org.mockserver.llm.client
-
ClassDescriptionShared scaffolding for
LlmClientimplementations: URL parsing, base-request construction (method, path, host, scheme, custom headers) and a sharedObjectMapper.Runtime client for the Anthropic Messages API (POST /v1/messages,x-api-key+anthropic-version).Stateless, deterministic implementation of AWS Signature Version 4 (header-basedAuthorizationheader signing) using only JDK crypto primitives:MessageDigest(SHA-256) andMac/SecretKeySpec(HmacSHA256).Runtime client for Azure OpenAI.Runtime client for Amazon Bedrock's Anthropic models (POST /model/{modelId}/invoke).Runtime client for the Google GeminigenerateContentAPI.Declares a real LLM backend that MockServer can call as a client (the opposite direction to the mock codecs, which build outbound mock responses).Resolves whichLlmBackenda runtime-LLM feature should use, across the three config layers (simplest first): Provider env conventions — auto-detect fromOPENAI_API_KEY/ANTHROPIC_API_KEY/GEMINI_API_KEY/OLLAMA_HOST(the same vars each provider SDK reads). MockServer properties — a single default backend viamockserver.llmProvider/llmApiKey/llmModel/llmBaseUrl. Named backends JSON —mockserver.llmBackendsConfigpoints at a JSON array of backends, selectable by name. The default backend prefers layer 2 (explicit properties) over layer 1 (env); named backends come from layer 3.Per-provider knowledge for calling a real LLM as a client.Orchestrates an outbound completion against a real LLM backend: looks up the per-providerLlmClient, builds the request, sends it via theLlmTransport, and parses the response into aCompletion.Transport seam for outbound runtime-LLM calls.LlmTransportbacked by the server'sNettyHttpClient.Runtime client for a local Ollama server.Runtime client for the OpenAI Chat Completions API (POST /v1/chat/completions,Authorization: Bearer).Runtime client for the OpenAI Responses API (POST /v1/responses,Authorization: Bearer).