# xAI (https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints/xai)

xAI serves its Grok models through an OpenAI-compatible API that you can add to LibreChat as a custom endpoint.

## Get an API key

Create a key from the [xAI console](https://console.x.ai/). Add it to your `.env` file:

```bash filename=".env"
XAI_API_KEY=your-api-key
```

## Configuration

Add the endpoint under `endpoints.custom` in your `librechat.yaml`:

```yaml filename="librechat.yaml"
    - name: "xai"
      apiKey: "${XAI_API_KEY}"
      baseURL: "https://api.x.ai/v1"
      models:
        default: ["grok-beta"]
        fetch: false
      titleConvo: true
      titleMethod: "completion"
      titleModel: "grok-beta"
      summarize: false
      summaryModel: "grok-beta"
      modelDisplayLabel: "Grok"
```

## Notes

- `titleMethod: "completion"` generates conversation titles through the chat completions endpoint, which is what Grok supports.
