Creates a new instance of the CerebrasLLM class
The Cerebras API key to use for authentication
Protected_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
Read only getter method to get the Cerebras client instance
Read only getter method to get the Cerebras client instance
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.
Cerebras supports streaming
Cerebras exposes OpenAI-compatible function calling, including parallel calls and a strict (constrained-decoding) mode, so the shared OpenAI-shaped mapping applies unchanged.
This matters more than the model count suggests: GPT-OSS-120B on Cerebras is the single most-deployed model across MJ's shipped agents, and until this override it was the one configuration native tool calling could not reach — the capability gate resolved to the envelope no matter what metadata said.
Two Cerebras-specific caveats, both handled by callers rather than here. Its catalog rotates aggressively, so a model that supports tools today may not be served tomorrow — verify at integration time. And it has a documented tool-hallucination quirk: it can emit a call to a tool that was never declared. extractOpenAICompatibleToolCalls surfaces such a call rather than dropping it, which is deliberate — the agent loop must be able to see a bad call and reject it by name, not receive silence.
ProtectedaddAdd thinking content to a chat completion message
OptionalthinkingContent: stringProtectedapplySets response_format, unless tools are going out on the same request.
Cerebras rejects the two together outright — 400 "tools" is incompatible with "response_format" — in every forcing mode, measured across the whole provider matrix.
No request
carrying both succeeds on this vendor, so the choice is not between two working requests but
between one working request and a guaranteed failure.
Tools win. A tool declaration is a decision channel the caller is relying on; JSON mode is a formatting constraint the prompt itself already states in every MJ prompt that sets it, and a model that ignores it produces output the envelope parser tolerates. Dropping it is loud rather than silent, because a caller who set it deliberately should be able to find out why their request did not carry it.
ProtectedapplyAdds the native tool-calling fields when the caller declared tools.
parallel_tool_calls is forwarded only when the caller set it explicitly. Cerebras supports
parallel calls at the API level but per-model, and sending the flag unasked would impose a
default the caller never chose on a catalog that rotates.
Process 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
Classifies text into categories using Cerebras LLM capabilities
Parameters for classification
A classification result
Clear all additional settings This is useful for resetting the state of the provider or when switching between different configurations.
ProtectedconvertBuilds the Cerebras message array from MJ messages.
Shared by the streaming and non-streaming paths so a tool conversation cannot round-trip
correctly on one and silently break on the other. Two things it must do that a naive
.map() cannot: a tool-role turn expands into N provider messages (one per result),
and an assistant turn has to carry its tool_calls forward or the results answering them
are orphaned and the request is rejected.
ProtectedcreateCreate a streaming request for Cerebras
ProtectedextractExtract thinking content from non-streaming content This method handles case-insensitive extraction of thinking blocks
ProtectedfinalizeCreate the final response from streaming results for Cerebras
ProtectedflushReturns (and clears) any user-visible content the thinking-tag stripper is still holding back at
the end of a stream. Mid-stream, processStreamChunkWithThinking holds back a trailing
fragment that could be the start of a <think>/</think> tag so a split tag never leaks as
partial text; once the stream ends, such a fragment is real content and must be emitted (bug A5).
Only flushes when NOT inside a thinking block: an unterminated <think> block's buffered text is
reasoning, not answer, and is left held back (never surfaced as visible content). Returns ''
when thinking extraction isn't active (no state) or there's nothing to flush.
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
ProtectednonImplementation for non-streaming chat completion
ProtectedprocessProcess streaming chunk with thinking extraction This method handles case-insensitive extraction across chunk boundaries
ProtectedprocessProcess a streaming chunk from Cerebras
ProtectedresetClear per-request streaming state. Invoked by the base class at the start and end of every streaming request.
ProtectedresetReset thinking stream state
Set additional provider-specific settings Subclasses should override this method to validate required settings
Provider-specific settings
ProtectedsetSet the reasoning_effort parameter for Cerebras models Currently only supported for OpenAI GPT OSS models
Summarizes text using Cerebras LLM capabilities
Parameters for the summarization
A summary result
ProtectedsupportsCheck if the provider supports thinking models
Cerebras supports thinking models with
Cerebras implementation of the BaseLLM class