xAI Grok Voice Agent API model, ready to pass to AgentSession.

Produces audio directly, so a separate TTS plugin is not required for session.say().

Hierarchy

  • OpenAIRealtimeModel
    • RealtimeModel

Constructors

  • Creates an xAI Grok Voice Agent API client.

    Parameters

    • options: realtime.RealtimeModelOptions = {}

      Model configuration:

      • model: Grok voice model ID. Defaults to grok-voice-think-fast-1.0.
      • voice: Voice used for audio responses. Defaults to ara.
      • apiKey: xAI API key. When omitted, reads XAI_API_KEY.
      • baseURL: Base URL of the xAI Realtime API. Defaults to wss://api.x.ai/v1.
      • turnDetection: Server-side turn detection. Defaults to server VAD with a 0.5 threshold, 300 ms prefix padding, and 200 ms silence duration.
      • inputAudioTranscription: Input transcription configuration. xAI transcription updates are emitted as interim, non-final transcripts until the turn is committed.
      • reasoning: Reasoning configuration. When omitted, the server default applies.
      • speed: Audio playback speed multiplier. Defaults to 1.0.
      • maxSessionDuration: Milliseconds before recycling the connection. Defaults to 20 minutes. Set to null to disable recycling.
      • connOptions: Retry, backoff, and connection settings.

    Returns realtime.RealtimeModel

    Throws

    Error if an API key cannot be resolved.

    Example

    import { voice } from '@livekit/agents';
    import { realtime } from '@livekit/agents-plugin-xai';

    const session = new voice.AgentSession({
    llm: new realtime.RealtimeModel({ voice: 'ara' }),
    });

Properties

_options: RealtimeOptions
inFrameSize: number
numChannels: number
outFrameSize: number
sampleRate: number

Accessors

  • get model(): string
  • Returns string

  • get provider(): string
  • Returns string

Methods

  • Returns Promise<void>

  • Create a RealtimeModel instance configured for Azure OpenAI Service.

    Parameters

    • __namedParameters: {
          apiKey?: string;
          apiVersion?: string;
          azureDeployment: string;
          azureEndpoint?: string;
          baseURL?: string;
          entraToken?: string;
          inputAudioNoiseReduction?: NoiseReduction;
          inputAudioTranscription?: InputAudioTranscription;
          speed?: number;
          temperature?: number;
          tracing?: TracingConfig;
          turnDetection?: TurnDetectionType;
          voice?: string;
      }
      • Optional apiKey?: string
      • Optional apiVersion?: string
      • azureDeployment: string
      • Optional azureEndpoint?: string
      • Optional baseURL?: string
      • Optional entraToken?: string
      • Optional inputAudioNoiseReduction?: NoiseReduction
      • Optional inputAudioTranscription?: InputAudioTranscription
      • Optional speed?: number
      • Optional temperature?: number

        Deprecated

        Unused in GA API (v1). Temperature is no longer supported.

      • Optional tracing?: TracingConfig
      • Optional turnDetection?: TurnDetectionType
      • Optional voice?: string

    Returns realtime.RealtimeModel

    A RealtimeModel instance configured for Azure OpenAI Service.

    See

    • DEFAULT_INPUT_AUDIO_TRANSCRIPTION.
    • DEFAULT_SERVER_VAD_OPTIONS.

    Throws

    Error if required Azure parameters are missing or invalid.