# xAI (/en/ai/models/asr/xai)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI.
> Documentation version: Main.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-guides-v1.txt).


xAI provides real-time automatic speech recognition (ASR) over WebSocket for conversational AI applications.

### Sample configuration

The following example shows a starting `asr` parameter configuration you can use when you [Start a conversational AI agent](/en/api-reference/api-ref/conversational-ai/join).

**Python SDK**

```python
from agora_agent import XaiSTT

# ... other agent configuration ...
.with_stt(XaiSTT(
    api_key='your-xai-api-key',
    base_url='wss://api.x.ai/v1/stt',
    sample_rate=16000,
    language='en',
))
```

**TypeScript SDK**

```typescript
import { XAiSTT } from 'agora-agents';

// ... other agent configuration ...
.withStt(new XAiSTT({
  apiKey: 'your-xai-api-key',
  baseUrl: 'wss://api.x.ai/v1/stt',
  sampleRate: 16000,
  language: 'en',
}));
```

**Go SDK**

```go
sampleRate := vendors.SampleRate16kHz

// ... other agent configuration ...
WithStt(
    vendors.NewXaiSTT(vendors.XaiSTTOptions{
        APIKey:     "your-xai-api-key",
        BaseURL:    "wss://api.x.ai/v1/stt",
        SampleRate: &sampleRate,
        Language:   "en",
    }),
)
```

**REST API**

```json
"asr": {
  "vendor": "xai",
  "params": {
    "api_key": "${env:XAI_API_KEY}",
    "base_url": "wss://api.x.ai/v1/stt",
    "sample_rate": 16000,
    "language": "en"
  }
}
```

### Key parameters

**params required**

**`api_key` (string) required**

The xAI API key used to authenticate requests. You must provide a valid key for the service to function.

**`base_url` (string) optional**

The WebSocket endpoint URL for the xAI streaming STT API. Defaults to `wss://api.x.ai/v1/stt`.

**`sample_rate` (integer) optional**

The audio sample rate in Hz. Supported values: `8000`, `16000`, `22050`, `24000`, `44100`, `48000`.

**`language` (string) optional**

The language code to use for transcription. For example, use `en` for English. Setting this enables text formatting of numbers, currencies, and units. For supported language codes, refer to the [xAI documentation](https://docs.x.ai/developers/model-capabilities/audio/speech-to-text#supported-languages).

> **Caution**
>
> The parameters listed on this page are validated for use with Conversational AI Engine. Required parameters must be provided as documented. Any additional parameters are passed through directly to the underlying vendor without validation. For a full list of supported options, refer to the [xAI Speech to Text documentation](https://docs.x.ai/developers/model-capabilities/audio/speech-to-text#streaming-speech-to-text-websocket).

This integration is fully supported for use with Conversational AI Engine. While it has completed functional validation, it is newer to the platform, and additional provider-specific edge cases may be identified as usage scales across a broader range of applications and workloads.
