@tanstack/ai
Version:
Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.
29 lines (28 loc) • 920 B
TypeScript
import { RealtimeToken, RealtimeTokenOptions } from './types.js';
export type * from './types.js';
/**
* Generate a realtime token using the provided adapter.
*
* This function is used on the server to generate ephemeral tokens
* that clients can use to establish realtime connections.
*
* @param options - Token generation options including the adapter
* @returns Promise resolving to a RealtimeToken
*
* @example
* ```typescript
* import { realtimeToken } from '@tanstack/ai'
* import { openaiRealtimeToken } from '@tanstack/ai-openai'
*
* // Server function (TanStack Start example)
* export const getRealtimeToken = createServerFn()
* .handler(async () => {
* return realtimeToken({
* adapter: openaiRealtimeToken({
* model: 'gpt-realtime',
* }),
* })
* })
* ```
*/
export declare function realtimeToken(options: RealtimeTokenOptions): Promise<RealtimeToken>;