> ## 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.

# Get Started with OGX

> Learn how to use OGX with Cerebras Inference for building AI applications with standardized APIs and tooling.

Llama Stack was renamed to OGX in 2026. OGX is an open-source, OpenAI-compatible API server with pluggable providers, including a built-in Cerebras provider. This guide uses the current OGX packages and commands.

## Prerequisites

Before you begin, ensure you have:

* **Cerebras API Key** - Get a free API key [here](https://cloud.cerebras.ai/?utm_source=3pi_ogx\&utm_campaign=partner_doc)
* **Python 3.12 or higher** - Required by current OGX releases
* **uv package manager** - Used to install and run the OGX starter distribution

## Configure OGX with Cerebras

<Steps>
  <Step title="Install OGX">
    Install the OGX starter distribution and the OpenAI SDK in a persistent project environment:

    ```bash theme={null}
    uv init cerebras-ogx && cd cerebras-ogx
    uv add "ogx[starter]" openai
    ```

    For a quick evaluation without creating a project, `uvx` can install and run the server in one command:

    ```bash theme={null}
    uvx --from "ogx[starter]" ogx stack run starter
    ```
  </Step>

  <Step title="Configure environment variables">
    Export your Cerebras API key as an environment variable:

    ```bash theme={null}
    export CEREBRAS_API_KEY=your-cerebras-api-key-here
    ```

    You can also add this to your shell profile (e.g., `~/.bashrc` or `~/.zshrc`) for persistence.
  </Step>

  <Step title="Start the OGX server">
    Launch the starter distribution. It enables the Cerebras provider automatically when `CEREBRAS_API_KEY` is set:

    ```bash theme={null}
    uv run ogx stack run starter
    ```

    The server starts on `http://localhost:8321` by default. Confirm that Cerebras models were discovered before sending requests:

    ```bash theme={null}
    curl -s http://localhost:8321/v1/models | python -m json.tool
    ```
  </Step>

  <Step title="Make your first inference request">
    Use any OpenAI-compatible client to make inference requests through OGX.

    <CodeGroup>
      ```python Python theme={null}
      from openai import OpenAI

      client = OpenAI(
          base_url="http://localhost:8321/v1",
          api_key="fake",
      )

      # Make a chat completion request
      response = client.chat.completions.create(
          model="cerebras/gpt-oss-120b",
          messages=[
              {"role": "user", "content": "What is the capital of France?"}
          ],
      )

      print(response.choices[0].message.content)
      ```

      ```bash cURL theme={null}
      curl -X POST "http://localhost:8321/v1/chat/completions" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "cerebras/gpt-oss-120b",
          "messages": [
              {"role": "user", "content": "What is the capital of France?"}
          ]
        }'
      ```
    </CodeGroup>
  </Step>

  <Step title="Try streaming responses">
    OGX supports streaming responses for real-time output. Streaming is particularly useful for interactive applications where you want to display responses as they're generated.

    <CodeGroup>
      ```python Python theme={null}
      from openai import OpenAI

      client = OpenAI(
          base_url="http://localhost:8321/v1",
          api_key="fake",
      )

      # Stream the response
      stream = client.chat.completions.create(
          model="cerebras/gpt-oss-120b",
          messages=[
              {"role": "user", "content": "Write a short poem about artificial intelligence."}
          ],
          stream=True,
      )

      for chunk in stream:
          if chunk.choices[0].delta.content:
              print(chunk.choices[0].delta.content, end="", flush=True)

      print()
      ```

      ```bash cURL theme={null}
      curl -X POST "http://localhost:8321/v1/chat/completions" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "cerebras/gpt-oss-120b",
          "messages": [
              {"role": "user", "content": "Write a short poem about artificial intelligence."}
          ],
          "stream": true
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>

## Using Cerebras Directly with OpenAI SDK

If you prefer to use Cerebras directly without the OGX server, you can use the OpenAI SDK with Cerebras endpoints. This approach gives you direct access to Cerebras while still tracking usage through the integration header.

<CodeGroup>
  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.getenv("CEREBRAS_API_KEY"),
      base_url="https://api.cerebras.ai/v1",
      default_headers={
          "X-Cerebras-3rd-Party-Integration": "ogx"
      }
  )

  response = client.chat.completions.create(
      model="gpt-oss-120b",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "What is the capital of France?"},
      ],
      max_tokens=500,
  )

  print(response.choices[0].message.content)
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.cerebras.ai/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $CEREBRAS_API_KEY" \
    -H "X-Cerebras-3rd-Party-Integration: ogx" \
    -d '{
      "model": "gpt-oss-120b",
      "messages": [
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "What is the capital of France?"}
      ],
      "max_tokens": 500
    }'
  ```
</CodeGroup>

## Advanced Features

### Using Multiple Models

OGX discovers the models available to your Cerebras account at startup. Use the provider-prefixed IDs returned by `GET /v1/models`, for example:

| Model ID                | Availability | Best For                                       |
| ----------------------- | ------------ | ---------------------------------------------- |
| `cerebras/gpt-oss-120b` | Production   | Text, coding, and tool-use workloads           |
| `cerebras/gemma-4-31b`  | Preview      | Multimodal workloads with text and image input |

Then switch between models in your code:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="http://localhost:8321/v1", api_key="fake")

  # Use gpt-oss-120b for general workloads
  text_response = client.chat.completions.create(
      model="cerebras/gpt-oss-120b",
      messages=[{"role": "user", "content": "Explain quantum computing in one sentence."}],
  )
  print("Text:", text_response.choices[0].message.content)

  # Use gemma-4-31b for multimodal input
  multimodal_response = client.chat.completions.create(
      model="cerebras/gemma-4-31b",
      messages=[{"role": "user", "content": "Describe two uses for image understanding."}],
  )
  print("Multimodal:", multimodal_response.choices[0].message.content)
  ```

  ```bash cURL (Complex Task) theme={null}
  curl -X POST "http://localhost:8321/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "cerebras/gpt-oss-120b",
      "messages": [
          {"role": "user", "content": "Explain quantum computing in one sentence."}
      ]
    }'
  ```

  ```bash cURL (Simple Task) theme={null}
  curl -X POST "http://localhost:8321/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "cerebras/gpt-oss-120b",
      "messages": [
          {"role": "user", "content": "What is 2+2?"}
      ]
    }'
  ```
</CodeGroup>

### System Prompts and Temperature Control

Customize model behavior with system prompts and sampling parameters to fine-tune responses:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="http://localhost:8321/v1", api_key="fake")

  # Example with system prompt and sampling params
  response = client.chat.completions.create(
      model="cerebras/gpt-oss-120b",
      messages=[
          {"role": "system", "content": "You are a helpful coding assistant."},
          {"role": "user", "content": "Write a Python function to calculate fibonacci numbers."}
      ],
      temperature=0.7,
      top_p=0.9,
      max_tokens=500,
  )
  print(response.choices[0].message.content)
  ```

  ```bash cURL theme={null}
  curl -X POST "http://localhost:8321/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "cerebras/gpt-oss-120b",
      "messages": [
          {"role": "system", "content": "You are a helpful coding assistant."},
          {"role": "user", "content": "Write a Python function to calculate fibonacci numbers."}
      ],
      "temperature": 0.7,
      "top_p": 0.9,
      "max_tokens": 500
    }'
  ```
</CodeGroup>

### Multi-Turn Conversations

The OpenAI-compatible chat endpoint supports multi-turn conversations:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="http://localhost:8321/v1", api_key="fake")

  # For agentic applications, use multi-turn conversations
  conversation = [
      {"role": "system", "content": "You are a helpful research assistant."},
      {"role": "user", "content": "What are the latest trends in AI?"}
  ]

  response = client.chat.completions.create(
      model="cerebras/gpt-oss-120b",
      messages=conversation,
  )
  print(response.choices[0].message.content)

  # Continue the conversation
  conversation.append({"role": "assistant", "content": response.choices[0].message.content})
  conversation.append({"role": "user", "content": "Can you elaborate on one of those trends?"})

  response2 = client.chat.completions.create(
      model="cerebras/gpt-oss-120b",
      messages=conversation,
  )
  print(response2.choices[0].message.content)
  ```

  ```bash cURL (First Turn) theme={null}
  curl -X POST "http://localhost:8321/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "cerebras/gpt-oss-120b",
      "messages": [
          {"role": "system", "content": "You are a helpful research assistant."},
          {"role": "user", "content": "What are the latest trends in AI?"}
      ]
    }'
  ```

  ```bash cURL (Follow-up Turn) theme={null}
  curl -X POST "http://localhost:8321/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "cerebras/gpt-oss-120b",
      "messages": [
        {"role": "system", "content": "You are a helpful research assistant."},
        {"role": "user", "content": "What are the latest trends in AI?"},
        {"role": "assistant", "content": "[Previous response content here]"},
        {"role": "user", "content": "Can you elaborate on one of those trends?"}
      ]
    }'
  ```
</CodeGroup>

## FAQ

<Accordion title="What's the difference between using OGX and calling Cerebras directly?">
  OGX provides a provider-agnostic, OpenAI-compatible server plus APIs for responses, files, vector stores, batches, and skills. If you only need basic inference, calling Cerebras directly with the OpenAI SDK is simpler.
</Accordion>

<Accordion title="Can I use OGX without running a local server?">
  Yes. Point any OpenAI-compatible client at a remote OGX server that has the Cerebras provider enabled. Alternatively, use the OpenAI SDK directly as shown in the "Using Cerebras Directly" section.
</Accordion>

<Accordion title="Which Cerebras models work best with OGX?">
  Use `gpt-oss-120b` for text, coding, and tool-use workloads. Use `gemma-4-31b` when you need image input. Check the [model catalog](/models/overview) for current availability before configuring additional models.
</Accordion>

<Accordion title="What Python versions are supported?">
  Current OGX packages require Python 3.12 or higher.
</Accordion>

<Accordion title="How do I handle rate limits and errors?">
  Handle `429` and transient `5xx` responses with bounded retries and exponential backoff in your application. Monitor account usage through the [Cerebras Cloud dashboard](https://cloud.cerebras.ai/?utm_source=3pi_ogx\&utm_campaign=partner_doc).
</Accordion>

## Troubleshooting

### Server won't start

If the OGX server fails to start:

1. Verify your Python version is 3.12 or higher: `python --version`
2. Check that your `CEREBRAS_API_KEY` environment variable is set: `echo $CEREBRAS_API_KEY`
3. Confirm the package can start: `uvx --from "ogx[starter]" ogx stack run starter`
4. Check the [OGX releases page](https://github.com/ogx-ai/ogx/releases) for breaking changes

### Connection errors

If you see connection errors when making requests:

1. Verify the OGX server is running on the expected port (default: 8321)
2. Check that your Cerebras API key is valid by testing it directly with the OpenAI SDK
3. Ensure there are no firewall rules blocking localhost connections
4. Try restarting the OGX server
5. Verify your network connectivity to `api.cerebras.ai`

### Model not found errors

If you get "model not found" errors:

1. Use the `cerebras/` prefix for model names (e.g., `cerebras/gpt-oss-120b`)
2. List available models: `curl http://localhost:8321/v1/models`
3. Restart the OGX server after changing provider environment variables
4. Consult the [Cerebras models page](/models) for the current list of available models

### Slow response times

If responses are slower than expected:

1. Verify you're using Cerebras models (not accidentally routing through another provider)
2. Check your network connection and latency to Cerebras endpoints
3. Reduce unnecessary prompt and output tokens
4. Enable streaming to get partial responses faster
5. Check your Cerebras account for any rate limiting or usage quotas

### Import errors with the OpenAI SDK

If you get import errors:

1. Ensure the OpenAI SDK is installed: `uv add openai`
2. Check that you're using the correct import: `from openai import OpenAI`
3. Verify that your base URL includes `/v1`
4. Create a fresh virtual environment if issues persist

## Next Steps

* Explore the [OGX documentation](https://ogx-ai.github.io/) for APIs, providers, and deployment options
* Review the [OGX Cerebras provider reference](https://ogx-ai.github.io/docs/providers/inference/remote_cerebras)
* Try different [Cerebras models](/models/overview) to find the best fit for your use case
* Review the [OGX GitHub repository](https://github.com/ogx-ai/ogx) for releases and examples

<Note>
  OGX was formerly named Llama Stack. The current package is `ogx`, the current command is `ogx`, and the server runs on port 8321 by default.
</Note>
