Skip to main content

LangChain Cerebras Modern

This package is a compatibility fork of the LangChain integration with Cerebras. It keeps the same import path, langchain_cerebras, while publishing under a separate distribution name for modern LangChain releases and Python 3.13.

At Cerebras, we've developed the world's largest and fastest AI processor, the Wafer-Scale Engine-3 (WSE-3). The Cerebras CS-3 system, powered by the WSE-3, represents a new class of AI supercomputer that sets the standard for generative AI training and inference with unparalleled performance and scalability.

With Cerebras as your inference provider, you can:

  • Achieve unprecedented speed for AI inference workloads
  • Build commercially with high throughput
  • Effortlessly scale your AI workloads with our seamless clustering technology

Our CS-3 systems can be quickly and easily clustered to create the largest AI supercomputers in the world, making it simple to place and run the largest models. Leading corporations, research institutions, and governments are already using Cerebras solutions to develop proprietary models and train popular open-source models.

Want to experience the power of Cerebras? Check out our website for more resources and explore options for accessing our technology through the Cerebras Cloud or on-premise deployments!

For more information about Cerebras Cloud, visit cloud.cerebras.ai. Our API reference is available at inference-docs.cerebras.ai.

Installation

pip install langchain-cerebras-modern

API Key

Get an API Key from cloud.cerebras.ai and add it to your environment variables:

export CEREBRAS_API_KEY="your-api-key-here"

Chat model

More examples

See more examples here.

Example

from langchain_core.prompts import ChatPromptTemplate
from langchain_cerebras import ChatCerebras

chat = ChatCerebras(
    model="llama-3.3-70b",
)

system = "You are an expert on animals who must answer questions in a manner that a 5 year old can understand."
human = "I want to learn more about this animal: {text}"
prompt = ChatPromptTemplate.from_messages(
    [
        ("system", system),
        ("human", human)
    ]
)

chain = prompt | chat
chain.invoke({"text": "Lion"})

Result content:

OH BOY! Let me tell you all about LIONS!

Lions are the kings of the jungle! They're really big and have beautiful, fluffy manes around their necks. The mane is like a big, golden crown!

Lions live in groups called prides. A pride is like a big family, and the lionesses (that's what we call the female lions) take care of the babies. The lionesses are like the mommies, and they teach the babies how to hunt and play.

Lions are very good at hunting. They work together to catch their food, like zebras and antelopes. They're super fast and can run really, really fast!

But lions are also very sleepy. They like to take long naps in the sun, and they can sleep for up to 20 hours a day! Can you imagine sleeping that much?

Lions are also very loud. They roar really loudly to talk to each other. It's like they're saying, "ROAR! I'm the king of the jungle!"

And guess what? Lions are very social. They like to play and cuddle with each other. They're like big, furry teddy bears!

So, that's lions! Aren't they just the coolest?

Development + Contributing

For more information, visit LangChain's contribution guide.

Install Dependencies

poetry install --with test,lint,codespell

Build

poetry build

Unit Test

Unit tests are completely offline and do not require an API key.

make test

Integration Test

Integration tests require the environment variable CEREBRAS_API_KEY to be set to a valid API key along with a connection to the Cerebras Cloud servers.

make integration_test

Linting and Formatting

make lint spell_check check_imports

Metadata

Release files for langchain-cerebras-modern 0.8.2.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-cerebras-modern 0.8.2.post1
File Size Uploaded
langchain_cerebras_modern-0.8.2.post1.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-cerebras-modern 0.8.2.post1
File Interpreter ABI Platform
langchain_cerebras_modern-0.8.2.post1-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / langchain_cerebras_modern-0.8.2.post1.tar.gz

Download URL langchain_cerebras_modern-0.8.2.post1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
217f831baa62ae2eba4784e975cdfe11668eaac2c2e94792ff83742b14a19739
BLAKE2b-256 checksum
How to use checksums
a7906635188c384c6de9add26860bab0ee243e09dd727a208e5627200b7c38a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / langchain_cerebras_modern-0.8.2.post1-py3-none-any.whl

Download URL langchain_cerebras_modern-0.8.2.post1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a976e56bb3a31ab6673c5416c6d20abde823bfc726b4b9064bbfab48bd6438b
BLAKE2b-256 checksum
How to use checksums
5d3dc0f1c0ed6202b95f7fb4cbda7280641843985ecbf37feadc79850ee2a1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.8.2.post1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page