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

# Cerebras

Portkey provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including the models hosted on [Cerebras Inference API](https://cerebras.ai/inference).

<Note>
  Provider Slug: `cerebras`
</Note>

## Portkey SDK Integration with Cerebras

Portkey provides a consistent API to interact with models from various providers. To integrate Cerebras with Portkey:

### 1. Install the Portkey SDK

<Tabs>
  <Tab title="NodeJS">
    ```sh theme={"system"}
    npm install --save portkey-ai
    ```
  </Tab>

  <Tab title="Python">
    ```sh theme={"system"}
    pip install portkey-ai
    ```
  </Tab>
</Tabs>

### 2. Initialize Portkey with Cerebras

To use Cerebras with Portkey, get your API key from [here](https://cerebras.ai/inference), then add it to Portkey to create the virtual key.

<Tabs>
  <Tab title="NodeJS SDK">
    ```js theme={"system"}
    import Portkey from 'portkey-ai'

    const portkey = new Portkey({
        apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
        virtualKey: "CEREBRAS_VIRTUAL_KEY" // Your Cerebras Inference virtual key
    })
    ```
  </Tab>

  <Tab title="Python SDK">
    ```py theme={"system"}
    from portkey_ai import Portkey

    portkey = Portkey(
        api_key ="PORTKEY_API_KEY",  # Replace with your Portkey API key
        virtual_key="CEREBRAS_VIRTUAL_KEY" # Your Cerebras Inference virtual key
    )
    ```
  </Tab>
</Tabs>

### 3. Invoke Chat Completions

<Tabs>
  <Tab title="NodeJS SDK">
    ```js theme={"system"}
    const chatCompletion = await portkey.chat.completions.create({
        messages: [{ role: 'user', content: 'Say this is a test' }],
        model: 'llama3.1-8b',
    });

    console.log(chatCompletion.choices);
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={"system"}
    completion = portkey.chat.completions.create(
        messages= [{ "role": 'user', "content": 'Say this is a test' }],
        model= 'llama3.1-8b'
    )

    print(completion)
    ```
  </Tab>
</Tabs>

***

## Supported Models

Cerebras currently supports `Llama-3.1-8B` and `Llama-3.1-70B`. You can find more info here:

<Info>
  [<img src="https://mintcdn.com/portkey-docs/wAHXB_jjwLt8bYcN/images/llms/apple-touch-icon.png?fit=max&auto=format&n=wAHXB_jjwLt8bYcN&q=85&s=18e20ec38a51e829c629e503251ae3eb" alt="Logo" width="20" height="20" data-path="images/llms/apple-touch-icon.png" />Overview - Starter KitStarter Kit](https://inference-docs.cerebras.ai/introduction)
</Info>

## Next Steps

The complete list of features supported in the SDK are available on the link below.

<Card title="SDK" href="/api-reference/portkey-sdk-client" />

You'll find more information in the relevant sections:

1. [Add metadata to your requests](/product/observability/metadata)
2. [Add gateway configs to your Cerebras](/product/ai-gateway/configs)[ requests](/product/ai-gateway/configs)
3. [Tracing Cerebras requests](/product/observability/traces)
4. [Setup a fallback from OpenAI to Cerebras](/product/ai-gateway/fallbacks)
