XaiRealtimeModel
Namespace: Vercel.AI.Xai
public sealed class XaiRealtimeModel : IRealtimeModelxAI realtime voice model.
Inheritance: object
Implements: IRealtimeModel
Constructors
Section titled “Constructors”XaiRealtimeModel(string, HttpClient, string, Func<IReadOnlyDictionary<string, string?>>?)
Section titled “XaiRealtimeModel(string, HttpClient, string, Func<IReadOnlyDictionary<string, string?>>?)”public XaiRealtimeModel(string modelId, HttpClient httpClient, string baseUrl, Func<IReadOnlyDictionary<string, string?>>? headers)Creates a realtime model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string | |
httpClient |
HttpClient | |
baseUrl |
string | |
headers |
Func<IReadOnlyDictionary<string, string>> |
Properties
Section titled “Properties”ModelId
Section titled “ModelId”public string ModelId { get; }Model id.
Value: string
Provider
Section titled “Provider”public string Provider { get; }Provider id.
Value: string
Methods
Section titled “Methods”BuildUri()
Section titled “BuildUri()”public Uri BuildUri()WebSocket URI for this model.
Returns: Uri
ConnectAsync(CancellationToken)
Section titled “ConnectAsync(CancellationToken)”public Task<IRealtimeSession> ConnectAsync(CancellationToken cancellationToken)WebSocket sessions are opened by the caller with Url.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<IRealtimeSession>
CreateClientSecretAsync(int?, CancellationToken)
Section titled “CreateClientSecretAsync(int?, CancellationToken)”public Task<XaiClientSecret> CreateClientSecretAsync(int? expiresAfterSeconds, CancellationToken cancellationToken)Posts to /realtime/client_secrets and returns a WebSocket URL that includes the model.
Parameters
| Name | Type | Description |
|---|---|---|
expiresAfterSeconds |
int? | |
cancellationToken |
CancellationToken |
Returns: Task<XaiClientSecret>
SerializeClientEvent(string)
Section titled “SerializeClientEvent(string)”public string? SerializeClientEvent(string type)Serializes a client event. conversation-item-truncate is dropped because xAI ignores it over WebSocket.
Parameters
| Name | Type | Description |
|---|---|---|
type |
string |
Returns: string
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product