Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-openai): add GPT-Live support with a server relay for realtime sessions #2239

MergedAlemTuzlakmerged 17 commits intomain fromfeat/openai-gpt-livemerged by AlemTuzlak View on GitHub

Showing 41 changed files with 30 additions and 0 deletions (loading 38).

x
0 of 41 viewed, 41 left
28 additions and 0 deletions.changeset/openai-gpt-live.mdAdded
View file
@@ -0,0 +1,28 @@
+---
+'@tanstack/ai': minor
+'@tanstack/ai-client': minor
+'@tanstack/ai-openai': minor
+'@tanstack/ai-react': minor
+'@tanstack/ai-remix': minor
+'@tanstack/ai-octane': minor
+---
+​
+Add OpenAI GPT-Live voice (`gpt-live-1` and `gpt-live-1.1`). On the server, `openaiLiveSession()` creates the session. In the browser, `openaiLive()` connects over WebRTC.
+​
+GPT-Live has no browser token, so this release adds a relay path:
+​
+- `realtimeSession()` in `@tanstack/ai` takes the WebRTC offer from the browser, gives it to a `RealtimeSessionAdapter`, and returns the answer.
+- `RealtimeRelayAdapter` (`kind: 'relay'`) is a browser adapter that connects through your server.
+- `RealtimeClient`, `useRealtimeChat`, and `createRealtimeChat` take `createSession` in place of `getToken` for a relay adapter.
+​
+The options type is now a union of the token form and the relay form. If you read the type of `getToken` from it (for example `UseRealtimeChatOptions['getToken']`), the type now includes `undefined`.
+​
+`RealtimeClient.updateSession()` now sends `providerOptions` to the connection. Before, the client kept `providerOptions` but did not send them.
+​
+Realtime adapters now get `RealtimeConnectOptions` (`abortSignal`, `autoCapture`) in `connect()`. With `autoCapture: false`, `openaiRealtime()` and `openaiLive()` open the microphone on the first `startAudioCapture()`, not on connect.
+​
+`RealtimeClient` sends a tool result only to the connection that asked for it. After a reconnect, a result from the old session is dropped.
+​
+`createSession` receives the connect `AbortSignal` as its second argument. Pass it to the session request so a cancelled connect does not open a provider session.
+​
+A delegated response that fails, or ends before it is complete, reports an error. The client does not continue that turn.
2 additions and 0 deletionsdocs/adapters/openai.mdModified
View file