Provider-specific Swarmauri import package for Cerebras Inference chat completions with sync, async, streaming, batch, and JSON workflows.
Project description
Swarmauri Cerebras LLM
swarmauri_llm_cerebras provides the CerebrasModel import path for Swarmauri applications that use Cerebras Inference chat completions. The package re-exports the maintained implementation from swarmauri_standard, giving projects a provider-specific dependency for Cerebras-hosted Llama, Qwen, and GPT-OSS style model workflows.
Why Swarmauri Cerebras LLM?
Use this package when you want Cerebras Inference behind the Swarmauri LLMBase interface. CerebrasModel formats Swarmauri conversations for the Cerebras chat completions endpoint, supports sync and async prediction, streams response deltas, runs sequential and concurrent batches, captures usage data, and exposes model options such as temperature, top-p, seed, stop sequences, and JSON output mode.
FAQ
Q: Which Cerebras endpoint does this adapter call?
A: The adapter posts to https://api.cerebras.ai/v1/chat/completions and uses bearer-token authentication with a Cerebras API key.
Q: Which model names are configured locally?
A: The current configured list includes llama-4-scout-17b-16e-instruct, llama3.1-8b, llama-3.3-70b, llama-4-maverick-17b-128e-instruct, qwen-3-32b, qwen-3-coder-480b, and gpt-oss-120b. The default is llama3.1-8b.
Q: Does this package contain a separate Cerebras implementation?
A: No. It re-exports CerebrasModel from swarmauri_standard.llms.CerebrasModel so applications can depend on this provider package while sharing the common implementation.
Q: How do I request JSON output?
A: Pass enable_json=True to predict(), apredict(), stream(), or astream(). The adapter sets response_format to json_object.
Features
- Provider-specific import:
from swarmauri_llm_cerebras import CerebrasModel. - Swarmauri
Conversation,HumanMessage,SystemMessage, andAgentMessageintegration. - Sync
predict()and asyncapredict()chat completion calls. - Sync
stream()and asyncastream()streaming deltas. - Sync
batch()and asyncabatch()helpers. - Configurable
temperature,max_completion_tokens,top_p,seed,stop, andenable_json. - Usage metadata mapping to Swarmauri
UsageDatawhen provider usage data is returned. - Model discovery through the Cerebras
/v1/modelsendpoint. - Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.
Prerequisites
- Cerebras Inference API key.
- Network access to
api.cerebras.ai. - Swarmauri conversations built from Swarmauri message classes.
Installation
Install with uv:
uv add swarmauri_llm_cerebras
Install with pip:
pip install swarmauri_llm_cerebras
Usage
Run a chat completion:
import os
from swarmauri_llm_cerebras import CerebrasModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
from swarmauri_standard.messages.SystemMessage import SystemMessage
conversation = Conversation()
conversation.add_message(SystemMessage(content="Answer with concise technical prose."))
conversation.add_message(HumanMessage(content="What is Cerebras Inference?"))
model = CerebrasModel(
api_key=os.environ["CEREBRAS_API_KEY"],
name="llama3.1-8b",
)
result = model.predict(
conversation=conversation,
temperature=0.2,
max_completion_tokens=256,
)
print(result.get_last().content)
Stream response deltas:
import os
from swarmauri_llm_cerebras import CerebrasModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
conversation = Conversation()
conversation.add_message(HumanMessage(content="Write a short product summary."))
model = CerebrasModel(api_key=os.environ["CEREBRAS_API_KEY"])
for token in model.stream(conversation=conversation, max_completion_tokens=180):
print(token, end="")
Use the async API:
import asyncio
import os
from swarmauri_llm_cerebras import CerebrasModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
async def main() -> None:
conversation = Conversation()
conversation.add_message(HumanMessage(content="Return JSON with a status field."))
model = CerebrasModel(api_key=os.environ["CEREBRAS_API_KEY"])
result = await model.apredict(conversation=conversation, enable_json=True)
print(result.get_last().content)
asyncio.run(main())
Related Packages
LLM provider packages:
- swarmauri_llm_ai21
- swarmauri_llm_anthropic
- swarmauri_llm_cohere
- swarmauri_llm_deepinfra
- swarmauri_llm_groq
- swarmauri_llm_mistral
- swarmauri_llm_openai
Foundational packages:
- swarmauri_core defines core interfaces.
- swarmauri_base provides base component classes.
- swarmauri_standard contains the shared
CerebrasModelimplementation. - swarmauri provides namespace imports and plugin discovery.
Best Practices
- Store
CEREBRAS_API_KEYin a secret manager or environment variable. - Set
nameexplicitly for reproducible model behavior. - Use
seedwhen deterministic replay matters for supported models. - Use async methods for high-concurrency workloads.
- Validate JSON mode outputs before feeding them into strict downstream parsers.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_llm_cerebras-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_llm_cerebras-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04585be6e88f86313eba4ee7b586accc96ddf41f5e2b29f3cc9d7b0e6af96ffa
|
|
| MD5 |
5355df28ad51679ed2cdde99e44f40a1
|
|
| BLAKE2b-256 |
5a7fbb73de3a38b8794320bd65ac691b5e9b9dd27ea03df6cbda8c43d5ae204b
|
File details
Details for the file swarmauri_llm_cerebras-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_llm_cerebras-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a572efb5c72339c3676ed22f19ab310b0bd7321440dee35ad15fe1aee8bde29d
|
|
| MD5 |
b05b092827e11828e96ba8c2ac6e95ff
|
|
| BLAKE2b-256 |
13ce7d65c01685d1ab0c34c548aee73596331463eaa1273ba8c4582a58abd409
|