Package org.mockserver.llm.codec
Class OpenAiCompatibleChatCodec
java.lang.Object
org.mockserver.llm.codec.OpenAiCompatibleChatCodec
- All Implemented Interfaces:
ProviderCodec
- Direct Known Subclasses:
DeepSeekCodec,GroqCodec,MistralCodec,OpenRouterCodec,XaiCodec
Base codec for OpenAI-chat-compatible providers (Mistral, xAI/Grok, DeepSeek,
Groq, OpenRouter). These providers expose the OpenAI Chat Completions wire format
(
POST /v1/chat/completions, Authorization: Bearer) on a different
host, so — exactly like AzureOpenAiCodec — all encoding and decoding
delegates to OpenAiChatCompletionsCodec; only provider() differs
per subclass.
Because the wire shape is byte-identical to OpenAI's, the OpenAI golden fixtures
cover the response format; these aliases are exercised by
OpenAiCompatibleProviderCodecTest instead of dedicated golden files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode(HttpRequest request) encode(Completion completion, String model) encodeEmbedding(EmbeddingResponse embedding, String input) encodeStreaming(Completion completion, String model, StreamingPhysics physics) abstract Providerprovider()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mockserver.llm.ProviderCodec
encodeEmbedding, encodeRerank, streamingFormat
-
Constructor Details
-
OpenAiCompatibleChatCodec
public OpenAiCompatibleChatCodec()
-
-
Method Details
-
provider
- Specified by:
providerin interfaceProviderCodec
-
apiVersion
- Specified by:
apiVersionin interfaceProviderCodec
-
encode
- Specified by:
encodein interfaceProviderCodec
-
encodeStreaming
public List<SseEvent> encodeStreaming(Completion completion, String model, StreamingPhysics physics) - Specified by:
encodeStreamingin interfaceProviderCodec
-
decode
- Specified by:
decodein interfaceProviderCodec
-
encodeEmbedding
- Specified by:
encodeEmbeddingin interfaceProviderCodec
-