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

# xAI

> xAI introduces X's Grok family of models.

Using Langtrace to monitor your xAI apps is quick and easy. Follow these steps:

## Setup

1. Install the Langtrace and xAI SDKs.

*Note: You'll need API keys from Langtrace and xAI. Sign up for [Langtrace](https://langtrace.ai) and/or [xAI](https://x.com/) if you haven't done so already.*

```bash Python theme={null}
# Install the SDK
pip install -U langtrace-python-sdk openai
```

2. Setup environment variables:

```bash Shell theme={null}
export LANGTRACE_API_KEY=YOUR_LANGTRACE_API_KEY
export XAI_API_KEY=YOUR_OPENAI_API_KEY
```

## Usage

Generate a simple output with your deployment's model:

<CodeGroup>
  ```python Python theme={null}
  import os
  from langtrace_python_sdk import langtrace # Must precede any llm module imports
  langtrace.init(api_key = os.environ['LANGTRACE_API_KEY'])
  from openai import OpenAI
  client = OpenAI(
    # This is the default and can be omitted
    api_key=os.environ["XAI_API_KEY"],
    base_url="https://api.x.ai/v1",
  )

  # Generate a simple output with the llama3 MODEL

  chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "What is LangChain?",
        }
    ],
    model="grok-beta",
  )
  print(chat_completion.choices[0].message.content)

  ```
</CodeGroup>

You can now view your traces on the Langtrace dashboard:

<img src="https://mintcdn.com/langtraceai-2/-UwpI0EgGcwfnnlh/images/xai.png?fit=max&auto=format&n=-UwpI0EgGcwfnnlh&q=85&s=63a15ba94b81f8e776f75a33f3a24fd5" alt="traces" width="3078" height="1730" data-path="images/xai.png" />
