ReqLLM.Providers.Cerebras (ReqLLM v1.0.0)
View SourceCerebras provider – OpenAI-compatible Chat Completions API with ultra-fast inference.
Implementation
Uses built-in OpenAI-style encoding/decoding defaults with Cerebras-specific adjustments.
Cerebras-Specific Notes
- System messages have stronger influence compared to OpenAI's implementation
- Streaming not supported with reasoning models in JSON mode or tool calling
- Requires
strict: truein tool schemas for structured output (automatically added) - Qwen models do NOT support
strict: true(automatically excluded) - Only supports
tool_choice: "auto"or"none", not function-specific choices
Unsupported OpenAI Features
The following fields will result in a 400 error if supplied:
frequency_penaltylogit_biaspresence_penaltyparallel_tool_callsservice_tier
Configuration
# Add to .env file (automatically loaded)
CEREBRAS_API_KEY=csk_...
Summary
Functions
Default implementation of attach/3.
Default implementation of attach_stream/4.
Default implementation of decode_response/1.
Default implementation of decode_stream_event/2.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Default implementation of extract_usage/2.
Default implementation of prepare_request/4.
Default implementation of translate_options/3.
Functions
Default implementation of attach/3.
Sets up Bearer token authentication and standard pipeline steps.
Default implementation of attach_stream/4.
Builds complete streaming requests using OpenAI-compatible format.
Default implementation of decode_response/1.
Handles success/error responses with standard ReqLLM.Response creation.
Default implementation of decode_stream_event/2.
Decodes SSE events using OpenAI-compatible format.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Encodes request body using OpenAI-compatible format for chat and embedding operations.
Default implementation of extract_usage/2.
Extracts usage data from standard usage field in response body.
Default implementation of prepare_request/4.
Handles :chat, :object, and :embedding operations using OpenAI-compatible patterns.
Default implementation of translate_options/3.
Pass-through implementation that returns options unchanged.