AbstractProtected_Protected property to store additional provider-specific settings
ProtectedthinkingState tracking for streaming thinking extraction Providers should initialize this if they support thinking models
Get the current additional settings
ProtectedapiOnly sub-classes can access the API key
Whether this LLM provider supports assistant prefill (pre-seeding the start of the model's response). Providers that support prefill should override this to return true. This is used as a code-level default when database metadata (AIModelType/AIModel/AIModelVendor.SupportsPrefill) is null. Database values of true/false override this getter.
Check if this provider supports streaming
true if streaming is supported, false otherwise
ProtectedaddAdd thinking content to a chat completion message
OptionalthinkingContent: stringProcess a chat completion request. If streaming is enabled and supported, this will route to the streaming implementation.
Process multiple chat completion requests in parallel. This is useful for:
Array of chat completion parameter objects
Optionalcallbacks: ParallelChatCompletionsCallbacksOptional callbacks for progress and individual completions
Promise resolving to an array of ChatResults in the same order as the input params
AbstractClassifyClear all additional settings This is useful for resetting the state of the provider or when switching between different configurations.
Protected AbstractcreateCreate a provider-specific streaming request
Chat parameters
A stream object that can be iterated with for await
ProtectedextractExtract thinking content from non-streaming content This method handles case-insensitive extraction of thinking blocks
Protected AbstractfinalizeCreate the final response object from streaming results
The complete content accumulated from all chunks
The last chunk received from the stream
The usage information (tokens, etc.)
A complete ChatResult object
Returns the native file input capabilities of this LLM driver, or null if the driver does not support file attachments. Subclasses that accept files (PDFs, images, etc.) should override this method.
ProtectedgetGet the thinking tag format for this provider Providers can override this to customize the thinking tag format
ProtectedhandleTemplate method for handling streaming chat completion This implements the common pattern across providers while delegating provider-specific logic to abstract methods.
ProtectedinitializeInitialize thinking stream state for streaming extraction
Protected AbstractnonImplementation for non-streaming chat completion
ProtectedprocessProcess streaming chunk with thinking extraction This method handles case-insensitive extraction across chunk boundaries
Protected AbstractprocessProcess a streaming chunk from the provider
The raw chunk from the provider
Processed content and metadata
ProtectedresetHook invoked at the start AND end (in finally) of every streaming chat
completion to reset per-request streaming state. Default is a no-op;
providers that maintain instance-level streaming state (e.g., Anthropic /
OpenAI thinking-block accumulators) MUST override this. See audit R2-C5
for context — without this, state from a prior request bleeds into the
next one and accumulated buffers grow unbounded across the singleton's
lifetime.
ProtectedresetReset thinking stream state
Set additional provider-specific settings Subclasses should override this method to validate required settings
Provider-specific settings
AbstractSummarizeProtectedsupportsCheck if the provider supports thinking models Providers should override this to return true if they support thinking extraction
Base class for all LLM sub-class implementations. Not all sub-classes will support all methods. If a method is not supported an exception will be thrown.