> ## Documentation Index
> Fetch the complete documentation index at: https://inference-docs.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cerebras Inference with Docker

> Learn how to run Cerebras Inference inside Docker containers to create safe, reproducible environments for AI-generated code.

By combining Docker's containerization with Cerebras' inference speed, teams can evaluate new code quickly while keeping experiments isolated, repeatable, and far, far away from a production database.

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/AG7rfsALofQ" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Try it yourself

In this tutorial we will build DevDuck, our multi-agent system that combines Cerebras fast inference with Docker Compose for isolated AI development environments.

<Steps>
  <Step title="Initialization">
    First, make sure that you have Docker installed, which you can download from the [official website](https://www.docker.com/products/docker-desktop/).
  </Step>

  <Step title="Clone the repository">
    Next, open a terminal and run the following commands:

    ```bash theme={null}
    git clone https://github.com/sebastiand-cerebras/docker-cerebras-demo
    cd docker-cerebras-demo
    ```
  </Step>

  <Step title="Set up your environment">
    Once you've cloned the repository, create a `.env` file with your Cerebras API key, which you can obtain from the [Cerebras platform](https://inference.cerebras.ai/). DevDuck uses the ultra-fast `gpt-oss-120b` model through Cerebras for all agents.

    ```bash theme={null}
    cat <<EOF > .env
    CEREBRAS_API_KEY={YOUR_API_KEY}
    CEREBRAS_BASE_URL=https://api.cerebras.ai/v1
    CEREBRAS_CHAT_MODEL=gpt-oss-120b
    EOF
    ```
  </Step>

  <Step title="Running DevDuck">
    All that's left to do is run the program. To build and start DevDuck, run:

    ```bash theme={null}
    docker compose up --build
    ```

    The compose setup spins up our agents and [Docker's MCP gateway](https://github.com/docker/mcp-gateway) which manages the MCP tools for working with the Node.js sandbox containers.
  </Step>

  <Step title="Using DevDuck">
    The application will be available at [http://0.0.0.0:8000](http://0.0.0.0:8000). DevDuck has a coordinator agent that manages two specialized Cerebras-powered sub-agents for different programming tasks.

    To get started, simply ask for a task and the program will automatically route to the correct agent. The DevDuck coordinator hands off to the appropriate Cerebras agent, which then executes your request in seconds.
  </Step>
</Steps>

With Compose, we can easily host multiple containers. Our agents can switch between each other and call tools with no extra work on your part. With Cerebras inference, expect sandbox initializations, file creation, and code generation to be done in seconds.

## Example Usage

<Accordion title="🔢 Prime Number Checker">
  ```text theme={null}
  Hello Cerebras!

  Create a function called isPrime that checks if a number is prime.

  EXECUTE it with these numbers: 7, 10, 13, 20

  Show me which ones are prime.
  ```
</Accordion>

<Accordion title="🌊 Fibonacci Sequence Generator">
  ```text theme={null}
  Cerebras, create a function that generates the first N Fibonacci numbers.

  EXECUTE it to generate the first 10 Fibonacci numbers.

  Print the sequence.
  ```
</Accordion>

<Accordion title="📊 Array Statistics Calculator">
  ```text theme={null}
  Hi Cerebras!

  Write code that takes this array: [5, 10, 15, 20, 25]
  Calculate the sum, average, min, and max.

  EXECUTE it and print the results.
  ```
</Accordion>

<Accordion title="💡 Quick Tips for Sandbox Execution">
  * Use the word "EXECUTE" explicitly
  * Keep functions simple and self-contained
  * Provide specific test data
  * Avoid external dependencies
</Accordion>

## Available Models

DevDuck uses Cerebras models for ultra-fast code generation:

| Model            | Parameters | Best For                                                         |
| ---------------- | ---------- | ---------------------------------------------------------------- |
| **gpt-oss-120b** | 120B       | Largest model for the most demanding tasks (default in DevDuck)  |
| **zai-glm-4.7**  | 357B       | Advanced 357B parameter model with strong reasoning capabilities |

Change the `CEREBRAS_CHAT_MODEL` environment variable to switch between models.
