Skip to content

GoogleRealtimeModel

Namespace: Vercel.AI.Google

public sealed class GoogleRealtimeModel : IRealtimeModel

Realtime model. Event mapping is local; opening the Live socket is not available on this runtime.

Inheritance: object

Implements: IRealtimeModel

View source

GoogleRealtimeModel(GoogleProvider, string)

Section titled “GoogleRealtimeModel(GoogleProvider, string)”
public GoogleRealtimeModel(GoogleProvider provider, string modelId)

Creates a realtime model.

Parameters

Name Type Description
provider GoogleProvider
modelId string

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id.

Value: string

View source

public Uri BuildUri()

WebSocket URI for this model.

Returns: Uri

View source

public Task<IRealtimeSession> ConnectAsync(CancellationToken cancellationToken)

Opens a realtime session.

Parameters

Name Type Description
cancellationToken CancellationToken

Returns: Task<IRealtimeSession>

View source

CreateClientSecretAsync(GoogleRealtimeSession?, int?, CancellationToken)

Section titled “CreateClientSecretAsync(GoogleRealtimeSession?, int?, CancellationToken)”
public Task<GoogleRealtimeClientSecret> CreateClientSecretAsync(GoogleRealtimeSession? session, int? expiresAfterSeconds, CancellationToken cancellationToken)

Creates an ephemeral auth token that a client uses to open a Live session. <code class=“paramref”>expiresAfterSeconds</code> is the window to open a session and defaults to 60 seconds. The token itself lives 30 minutes longer, so the opened session has room to run.

Parameters

Name Type Description
session GoogleRealtimeSession
expiresAfterSeconds int?
cancellationToken CancellationToken

Returns: Task<GoogleRealtimeClientSecret>

View source

public string GetWebSocketUrl(string token, string url)

The URL a client opens with a token from CancellationToken).

Parameters

Name Type Description
token string
url string

Returns: string

View source

public IReadOnlyList<GoogleRealtimeEvent> ParseServerEvent(JsonElement raw)

Maps one server message with this model’s event mapper.

Parameters

Name Type Description
raw JsonElement

Returns: IReadOnlyList<GoogleRealtimeEvent>

View source

SerializeClientEvent(string, GoogleRealtimeSession?, string?, string?, string?, string?, string?)

Section titled “SerializeClientEvent(string, GoogleRealtimeSession?, string?, string?, string?, string?, string?)”
public JsonObject? SerializeClientEvent(string type, GoogleRealtimeSession? session, string? audio, string? text, string? callId, string? callName, string? callOutput)

Serializes a client event with this model’s event mapper. A session update uses this model.

Parameters

Name Type Description
type string
session GoogleRealtimeSession
audio string
text string
callId string
callName string
callOutput string

Returns: JsonObject

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product