openai 7.13.0 → 7.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/client.d.mts +3 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +3 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/helpers/live.d.mts +2 -0
  11. package/helpers/live.d.mts.map +1 -0
  12. package/helpers/live.d.ts +2 -0
  13. package/helpers/live.d.ts.map +1 -0
  14. package/helpers/live.js +6 -0
  15. package/helpers/live.js.map +1 -0
  16. package/helpers/live.mjs +2 -0
  17. package/helpers/live.mjs.map +1 -0
  18. package/lib/live/transcript-grouper.d.mts +96 -0
  19. package/lib/live/transcript-grouper.d.mts.map +1 -0
  20. package/lib/live/transcript-grouper.d.ts +96 -0
  21. package/lib/live/transcript-grouper.d.ts.map +1 -0
  22. package/lib/live/transcript-grouper.js +223 -0
  23. package/lib/live/transcript-grouper.js.map +1 -0
  24. package/lib/live/transcript-grouper.mjs +219 -0
  25. package/lib/live/transcript-grouper.mjs.map +1 -0
  26. package/lib/live/transcript-grouping.d.mts +49 -0
  27. package/lib/live/transcript-grouping.d.mts.map +1 -0
  28. package/lib/live/transcript-grouping.d.ts +49 -0
  29. package/lib/live/transcript-grouping.d.ts.map +1 -0
  30. package/lib/live/transcript-grouping.js +287 -0
  31. package/lib/live/transcript-grouping.js.map +1 -0
  32. package/lib/live/transcript-grouping.mjs +283 -0
  33. package/lib/live/transcript-grouping.mjs.map +1 -0
  34. package/lib/live/webrtc.d.mts +13 -0
  35. package/lib/live/webrtc.d.mts.map +1 -0
  36. package/lib/live/webrtc.d.ts +13 -0
  37. package/lib/live/webrtc.d.ts.map +1 -0
  38. package/lib/live/webrtc.js +16 -0
  39. package/lib/live/webrtc.js.map +1 -0
  40. package/lib/live/webrtc.mjs +10 -0
  41. package/lib/live/webrtc.mjs.map +1 -0
  42. package/lib/realtime/webrtc.d.mts +13 -0
  43. package/lib/realtime/webrtc.d.mts.map +1 -0
  44. package/lib/realtime/webrtc.d.ts +13 -0
  45. package/lib/realtime/webrtc.d.ts.map +1 -0
  46. package/lib/realtime/webrtc.js +16 -0
  47. package/lib/realtime/webrtc.js.map +1 -0
  48. package/lib/realtime/webrtc.mjs +10 -0
  49. package/lib/realtime/webrtc.mjs.map +1 -0
  50. package/lib/webrtc/connection.d.mts +40 -0
  51. package/lib/webrtc/connection.d.mts.map +1 -0
  52. package/lib/webrtc/connection.d.ts +40 -0
  53. package/lib/webrtc/connection.d.ts.map +1 -0
  54. package/lib/webrtc/connection.js +228 -0
  55. package/lib/webrtc/connection.js.map +1 -0
  56. package/lib/webrtc/connection.mjs +224 -0
  57. package/lib/webrtc/connection.mjs.map +1 -0
  58. package/lib/webrtc/data-channel.d.mts +32 -0
  59. package/lib/webrtc/data-channel.d.mts.map +1 -0
  60. package/lib/webrtc/data-channel.d.ts +32 -0
  61. package/lib/webrtc/data-channel.d.ts.map +1 -0
  62. package/lib/webrtc/data-channel.js +125 -0
  63. package/lib/webrtc/data-channel.js.map +1 -0
  64. package/lib/webrtc/data-channel.mjs +121 -0
  65. package/lib/webrtc/data-channel.mjs.map +1 -0
  66. package/lib/webrtc/errors.d.mts +19 -0
  67. package/lib/webrtc/errors.d.mts.map +1 -0
  68. package/lib/webrtc/errors.d.ts +19 -0
  69. package/lib/webrtc/errors.d.ts.map +1 -0
  70. package/lib/webrtc/errors.js +18 -0
  71. package/lib/webrtc/errors.js.map +1 -0
  72. package/lib/webrtc/errors.mjs +14 -0
  73. package/lib/webrtc/errors.mjs.map +1 -0
  74. package/lib/webrtc/subscriptions.d.mts +13 -0
  75. package/lib/webrtc/subscriptions.d.mts.map +1 -0
  76. package/lib/webrtc/subscriptions.d.ts +13 -0
  77. package/lib/webrtc/subscriptions.d.ts.map +1 -0
  78. package/lib/webrtc/subscriptions.js +62 -0
  79. package/lib/webrtc/subscriptions.js.map +1 -0
  80. package/lib/webrtc/subscriptions.mjs +58 -0
  81. package/lib/webrtc/subscriptions.mjs.map +1 -0
  82. package/lib/webrtc/types.d.mts +99 -0
  83. package/lib/webrtc/types.d.mts.map +1 -0
  84. package/lib/webrtc/types.d.ts +99 -0
  85. package/lib/webrtc/types.d.ts.map +1 -0
  86. package/lib/webrtc/types.js +3 -0
  87. package/lib/webrtc/types.js.map +1 -0
  88. package/lib/webrtc/types.mjs +2 -0
  89. package/lib/webrtc/types.mjs.map +1 -0
  90. package/live/webrtc.d.mts +3 -0
  91. package/live/webrtc.d.mts.map +1 -0
  92. package/live/webrtc.d.ts +3 -0
  93. package/live/webrtc.d.ts.map +1 -0
  94. package/live/webrtc.js +8 -0
  95. package/live/webrtc.js.map +1 -0
  96. package/live/webrtc.mjs +2 -0
  97. package/live/webrtc.mjs.map +1 -0
  98. package/package.json +11 -1
  99. package/realtime/webrtc.d.mts +3 -0
  100. package/realtime/webrtc.d.mts.map +1 -0
  101. package/realtime/webrtc.d.ts +3 -0
  102. package/realtime/webrtc.d.ts.map +1 -0
  103. package/realtime/webrtc.js +8 -0
  104. package/realtime/webrtc.js.map +1 -0
  105. package/realtime/webrtc.mjs +2 -0
  106. package/realtime/webrtc.mjs.map +1 -0
  107. package/resources/beta/responses/responses.d.mts +48 -0
  108. package/resources/beta/responses/responses.d.mts.map +1 -1
  109. package/resources/beta/responses/responses.d.ts +48 -0
  110. package/resources/beta/responses/responses.d.ts.map +1 -1
  111. package/resources/beta/responses/responses.js.map +1 -1
  112. package/resources/beta/responses/responses.mjs.map +1 -1
  113. package/resources/conversations/items.d.mts +16 -0
  114. package/resources/conversations/items.d.mts.map +1 -1
  115. package/resources/conversations/items.d.ts +16 -0
  116. package/resources/conversations/items.d.ts.map +1 -1
  117. package/resources/index.d.mts +1 -0
  118. package/resources/index.d.mts.map +1 -1
  119. package/resources/index.d.ts +1 -0
  120. package/resources/index.d.ts.map +1 -1
  121. package/resources/index.js +3 -1
  122. package/resources/index.js.map +1 -1
  123. package/resources/index.mjs +1 -0
  124. package/resources/index.mjs.map +1 -1
  125. package/resources/live/forks/forks.d.mts +110 -0
  126. package/resources/live/forks/forks.d.mts.map +1 -0
  127. package/resources/live/forks/forks.d.ts +110 -0
  128. package/resources/live/forks/forks.d.ts.map +1 -0
  129. package/resources/live/forks/forks.js +9 -0
  130. package/resources/live/forks/forks.js.map +1 -0
  131. package/resources/live/forks/forks.mjs +5 -0
  132. package/resources/live/forks/forks.mjs.map +1 -0
  133. package/resources/live/forks/index.d.mts +4 -0
  134. package/resources/live/forks/index.d.mts.map +1 -0
  135. package/resources/live/forks/index.d.ts +4 -0
  136. package/resources/live/forks/index.d.ts.map +1 -0
  137. package/resources/live/forks/index.js +7 -0
  138. package/resources/live/forks/index.js.map +1 -0
  139. package/resources/live/forks/index.mjs +3 -0
  140. package/resources/live/forks/index.mjs.map +1 -0
  141. package/resources/live/forks/internal-base.d.mts +73 -0
  142. package/resources/live/forks/internal-base.d.mts.map +1 -0
  143. package/resources/live/forks/internal-base.d.ts +73 -0
  144. package/resources/live/forks/internal-base.d.ts.map +1 -0
  145. package/resources/live/forks/internal-base.js +49 -0
  146. package/resources/live/forks/internal-base.js.map +1 -0
  147. package/resources/live/forks/internal-base.mjs +43 -0
  148. package/resources/live/forks/internal-base.mjs.map +1 -0
  149. package/resources/live/forks/ws-base.d.mts +109 -0
  150. package/resources/live/forks/ws-base.d.mts.map +1 -0
  151. package/resources/live/forks/ws-base.d.ts +109 -0
  152. package/resources/live/forks/ws-base.d.ts.map +1 -0
  153. package/resources/live/forks/ws-base.js +476 -0
  154. package/resources/live/forks/ws-base.js.map +1 -0
  155. package/resources/live/forks/ws-base.mjs +472 -0
  156. package/resources/live/forks/ws-base.mjs.map +1 -0
  157. package/resources/live/forks/ws.d.mts +13 -0
  158. package/resources/live/forks/ws.d.mts.map +1 -0
  159. package/resources/live/forks/ws.d.ts +13 -0
  160. package/resources/live/forks/ws.d.ts.map +1 -0
  161. package/resources/live/forks/ws.js +34 -0
  162. package/resources/live/forks/ws.js.map +1 -0
  163. package/resources/live/forks/ws.mjs +29 -0
  164. package/resources/live/forks/ws.mjs.map +1 -0
  165. package/resources/live/forks.d.mts +2 -0
  166. package/resources/live/forks.d.mts.map +1 -0
  167. package/resources/live/forks.d.ts +2 -0
  168. package/resources/live/forks.d.ts.map +1 -0
  169. package/resources/live/forks.js +6 -0
  170. package/resources/live/forks.js.map +1 -0
  171. package/resources/live/forks.mjs +3 -0
  172. package/resources/live/forks.mjs.map +1 -0
  173. package/resources/live/index.d.mts +7 -0
  174. package/resources/live/index.d.mts.map +1 -0
  175. package/resources/live/index.d.ts +7 -0
  176. package/resources/live/index.d.ts.map +1 -0
  177. package/resources/live/index.js +13 -0
  178. package/resources/live/index.js.map +1 -0
  179. package/resources/live/index.mjs +6 -0
  180. package/resources/live/index.mjs.map +1 -0
  181. package/resources/live/internal-base.d.mts +71 -0
  182. package/resources/live/internal-base.d.mts.map +1 -0
  183. package/resources/live/internal-base.d.ts +71 -0
  184. package/resources/live/internal-base.d.ts.map +1 -0
  185. package/resources/live/internal-base.js +48 -0
  186. package/resources/live/internal-base.js.map +1 -0
  187. package/resources/live/internal-base.mjs +42 -0
  188. package/resources/live/internal-base.mjs.map +1 -0
  189. package/resources/live/live.d.mts +1864 -0
  190. package/resources/live/live.d.mts.map +1 -0
  191. package/resources/live/live.d.ts +1864 -0
  192. package/resources/live/live.d.ts.map +1 -0
  193. package/resources/live/live.js +40 -0
  194. package/resources/live/live.js.map +1 -0
  195. package/resources/live/live.mjs +35 -0
  196. package/resources/live/live.mjs.map +1 -0
  197. package/resources/live/sessions.d.mts +254 -0
  198. package/resources/live/sessions.d.mts.map +1 -0
  199. package/resources/live/sessions.d.ts +254 -0
  200. package/resources/live/sessions.d.ts.map +1 -0
  201. package/resources/live/sessions.js +118 -0
  202. package/resources/live/sessions.js.map +1 -0
  203. package/resources/live/sessions.mjs +114 -0
  204. package/resources/live/sessions.mjs.map +1 -0
  205. package/resources/live/sideband/index.d.mts +4 -0
  206. package/resources/live/sideband/index.d.mts.map +1 -0
  207. package/resources/live/sideband/index.d.ts +4 -0
  208. package/resources/live/sideband/index.d.ts.map +1 -0
  209. package/resources/live/sideband/index.js +7 -0
  210. package/resources/live/sideband/index.js.map +1 -0
  211. package/resources/live/sideband/index.mjs +3 -0
  212. package/resources/live/sideband/index.mjs.map +1 -0
  213. package/resources/live/sideband/internal-base.d.mts +73 -0
  214. package/resources/live/sideband/internal-base.d.mts.map +1 -0
  215. package/resources/live/sideband/internal-base.d.ts +73 -0
  216. package/resources/live/sideband/internal-base.d.ts.map +1 -0
  217. package/resources/live/sideband/internal-base.js +49 -0
  218. package/resources/live/sideband/internal-base.js.map +1 -0
  219. package/resources/live/sideband/internal-base.mjs +43 -0
  220. package/resources/live/sideband/internal-base.mjs.map +1 -0
  221. package/resources/live/sideband/sideband.d.mts +25 -0
  222. package/resources/live/sideband/sideband.d.mts.map +1 -0
  223. package/resources/live/sideband/sideband.d.ts +25 -0
  224. package/resources/live/sideband/sideband.d.ts.map +1 -0
  225. package/resources/live/sideband/sideband.js +9 -0
  226. package/resources/live/sideband/sideband.js.map +1 -0
  227. package/resources/live/sideband/sideband.mjs +5 -0
  228. package/resources/live/sideband/sideband.mjs.map +1 -0
  229. package/resources/live/sideband/ws-base.d.mts +114 -0
  230. package/resources/live/sideband/ws-base.d.mts.map +1 -0
  231. package/resources/live/sideband/ws-base.d.ts +114 -0
  232. package/resources/live/sideband/ws-base.d.ts.map +1 -0
  233. package/resources/live/sideband/ws-base.js +476 -0
  234. package/resources/live/sideband/ws-base.js.map +1 -0
  235. package/resources/live/sideband/ws-base.mjs +472 -0
  236. package/resources/live/sideband/ws-base.mjs.map +1 -0
  237. package/resources/live/sideband/ws.d.mts +13 -0
  238. package/resources/live/sideband/ws.d.mts.map +1 -0
  239. package/resources/live/sideband/ws.d.ts +13 -0
  240. package/resources/live/sideband/ws.d.ts.map +1 -0
  241. package/resources/live/sideband/ws.js +34 -0
  242. package/resources/live/sideband/ws.js.map +1 -0
  243. package/resources/live/sideband/ws.mjs +29 -0
  244. package/resources/live/sideband/ws.mjs.map +1 -0
  245. package/resources/live/sideband.d.mts +2 -0
  246. package/resources/live/sideband.d.mts.map +1 -0
  247. package/resources/live/sideband.d.ts +2 -0
  248. package/resources/live/sideband.d.ts.map +1 -0
  249. package/resources/live/sideband.js +6 -0
  250. package/resources/live/sideband.js.map +1 -0
  251. package/resources/live/sideband.mjs +3 -0
  252. package/resources/live/sideband.mjs.map +1 -0
  253. package/resources/live/ws-base.d.mts +106 -0
  254. package/resources/live/ws-base.d.mts.map +1 -0
  255. package/resources/live/ws-base.d.ts +106 -0
  256. package/resources/live/ws-base.d.ts.map +1 -0
  257. package/resources/live/ws-base.js +476 -0
  258. package/resources/live/ws-base.js.map +1 -0
  259. package/resources/live/ws-base.mjs +472 -0
  260. package/resources/live/ws-base.mjs.map +1 -0
  261. package/resources/live/ws.d.mts +13 -0
  262. package/resources/live/ws.d.mts.map +1 -0
  263. package/resources/live/ws.d.ts +13 -0
  264. package/resources/live/ws.d.ts.map +1 -0
  265. package/resources/live/ws.js +34 -0
  266. package/resources/live/ws.js.map +1 -0
  267. package/resources/live/ws.mjs +29 -0
  268. package/resources/live/ws.mjs.map +1 -0
  269. package/resources/live.d.mts +2 -0
  270. package/resources/live.d.mts.map +1 -0
  271. package/resources/live.d.ts +2 -0
  272. package/resources/live.d.ts.map +1 -0
  273. package/resources/live.js +6 -0
  274. package/resources/live.js.map +1 -0
  275. package/resources/live.mjs +3 -0
  276. package/resources/live.mjs.map +1 -0
  277. package/resources/responses/responses.d.mts +48 -0
  278. package/resources/responses/responses.d.mts.map +1 -1
  279. package/resources/responses/responses.d.ts +48 -0
  280. package/resources/responses/responses.d.ts.map +1 -1
  281. package/resources/responses/responses.js.map +1 -1
  282. package/resources/responses/responses.mjs.map +1 -1
  283. package/resources/webhooks/webhooks.d.mts +72 -5
  284. package/resources/webhooks/webhooks.d.mts.map +1 -1
  285. package/resources/webhooks/webhooks.d.ts +72 -5
  286. package/resources/webhooks/webhooks.d.ts.map +1 -1
  287. package/src/client.ts +5 -0
  288. package/src/helpers/live.ts +8 -0
  289. package/src/lib/live/transcript-grouper.ts +303 -0
  290. package/src/lib/live/transcript-grouping.ts +362 -0
  291. package/src/lib/live/webrtc.ts +23 -0
  292. package/src/lib/realtime/webrtc.ts +20 -0
  293. package/src/lib/webrtc/connection.ts +309 -0
  294. package/src/lib/webrtc/data-channel.ts +144 -0
  295. package/src/lib/webrtc/errors.ts +38 -0
  296. package/src/lib/webrtc/subscriptions.ts +62 -0
  297. package/src/lib/webrtc/types.ts +109 -0
  298. package/src/live/webrtc.ts +10 -0
  299. package/src/realtime/webrtc.ts +10 -0
  300. package/src/resources/beta/responses/responses.ts +60 -0
  301. package/src/resources/conversations/items.ts +20 -0
  302. package/src/resources/index.ts +1 -0
  303. package/src/resources/live/api.md +87 -0
  304. package/src/resources/live/forks/forks.ts +169 -0
  305. package/src/resources/live/forks/index.ts +5 -0
  306. package/src/resources/live/forks/internal-base.ts +107 -0
  307. package/src/resources/live/forks/ws-base.ts +611 -0
  308. package/src/resources/live/forks/ws.ts +46 -0
  309. package/src/resources/live/forks.ts +3 -0
  310. package/src/resources/live/index.ts +20 -0
  311. package/src/resources/live/internal-base.ts +104 -0
  312. package/src/resources/live/live.ts +2296 -0
  313. package/src/resources/live/sessions.ts +337 -0
  314. package/src/resources/live/sideband/index.ts +10 -0
  315. package/src/resources/live/sideband/internal-base.ts +107 -0
  316. package/src/resources/live/sideband/sideband.ts +58 -0
  317. package/src/resources/live/sideband/ws-base.ts +621 -0
  318. package/src/resources/live/sideband/ws.ts +46 -0
  319. package/src/resources/live/sideband.ts +3 -0
  320. package/src/resources/live/ws-base.ts +607 -0
  321. package/src/resources/live/ws.ts +42 -0
  322. package/src/resources/live.ts +3 -0
  323. package/src/resources/responses/responses.ts +60 -0
  324. package/src/resources/webhooks/api.md +1 -0
  325. package/src/resources/webhooks/webhooks.ts +82 -3
  326. package/src/version.ts +1 -1
  327. package/version.d.mts +1 -1
  328. package/version.d.ts +1 -1
  329. package/version.js +1 -1
  330. package/version.mjs +1 -1
@@ -0,0 +1,337 @@
1
+ // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as LiveAPI from './live';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { buildHeaders } from '../../internal/headers';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { path } from '../../internal/utils/path';
9
+
10
+ export class Sessions extends APIResource {
11
+ /**
12
+ * Accept an incoming SIP call with Live startup configuration.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * await client.live.sessions.accept('session_id', {
17
+ * session: { model: 'gpt-live-1', type: 'live' },
18
+ * });
19
+ * ```
20
+ */
21
+ accept(sessionID: string, body: SessionAcceptParams, options?: RequestOptions): APIPromise<void> {
22
+ return this._client.post(path`/live/sessions/${sessionID}/accept`, {
23
+ body,
24
+ ...options,
25
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
26
+ __security: { bearerAuth: true },
27
+ });
28
+ }
29
+
30
+ /**
31
+ * Get Live session content
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const response =
36
+ * await client.live.sessions.downloadRecording('live_SQ');
37
+ *
38
+ * const content = await response.blob();
39
+ * console.log(content);
40
+ * ```
41
+ */
42
+ downloadRecording(sessionID: string, options?: RequestOptions): APIPromise<Response> {
43
+ return this._client.get(path`/live/sessions/${sessionID}/content`, {
44
+ ...options,
45
+ headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
46
+ __security: { bearerAuth: true },
47
+ __binaryResponse: true,
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Fork a stored Live session onto a new WebRTC connection.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const response = await client.live.sessions.fork(
57
+ * 'session_id',
58
+ * { transport: { sdp: 'x', type: 'webrtc' } },
59
+ * );
60
+ * ```
61
+ */
62
+ fork(
63
+ sessionID: string,
64
+ body: SessionForkParams,
65
+ options?: RequestOptions,
66
+ ): APIPromise<SessionForkResponse> {
67
+ return this._client.post(path`/live/sessions/${sessionID}/fork`, {
68
+ body,
69
+ ...options,
70
+ __security: { bearerAuth: true },
71
+ });
72
+ }
73
+
74
+ /**
75
+ * Hang up a Live session.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * await client.live.sessions.hangup('session_id');
80
+ * ```
81
+ */
82
+ hangup(sessionID: string, options?: RequestOptions): APIPromise<void> {
83
+ return this._client.post(path`/live/sessions/${sessionID}/hangup`, {
84
+ ...options,
85
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
86
+ __security: { bearerAuth: true },
87
+ });
88
+ }
89
+
90
+ /**
91
+ * Transfer a Live SIP call to another destination.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * await client.live.sessions.refer('session_id', {
96
+ * target_uri: 'tel:+14155550123',
97
+ * });
98
+ * ```
99
+ */
100
+ refer(sessionID: string, body: SessionReferParams, options?: RequestOptions): APIPromise<void> {
101
+ return this._client.post(path`/live/sessions/${sessionID}/refer`, {
102
+ body,
103
+ ...options,
104
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
105
+ __security: { bearerAuth: true },
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Reject an incoming SIP call.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * await client.live.sessions.reject('session_id', {
115
+ * status_code: 486,
116
+ * });
117
+ * ```
118
+ */
119
+ reject(sessionID: string, body: SessionRejectParams, options?: RequestOptions): APIPromise<void> {
120
+ return this._client.post(path`/live/sessions/${sessionID}/reject`, {
121
+ body,
122
+ ...options,
123
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
124
+ __security: { bearerAuth: true },
125
+ });
126
+ }
127
+ }
128
+
129
+ /**
130
+ * The created Live session identifier and WebRTC answer. Apply transport.sdp as
131
+ * the peer's remote answer and wait for session.started on the data channel before
132
+ * sending commands.
133
+ */
134
+ export interface SessionForkResponse {
135
+ /**
136
+ * The newly created Live session. Use its ID for session controls and sideband
137
+ * connections.
138
+ */
139
+ session: SessionForkResponse.Session;
140
+
141
+ /**
142
+ * WebRTC transport with the SDP answer.
143
+ */
144
+ transport: SessionForkResponse.Transport;
145
+ }
146
+
147
+ export namespace SessionForkResponse {
148
+ /**
149
+ * The newly created Live session. Use its ID for session controls and sideband
150
+ * connections.
151
+ */
152
+ export interface Session {
153
+ /**
154
+ * Opaque session identifier. Preserve the returned value unchanged, including its
155
+ * prefix.
156
+ */
157
+ id: string;
158
+ }
159
+
160
+ /**
161
+ * WebRTC transport with the SDP answer.
162
+ */
163
+ export interface Transport {
164
+ /**
165
+ * Session Description Protocol message for the WebRTC connection.
166
+ */
167
+ sdp: string;
168
+
169
+ /**
170
+ * The transport used for the Live session. Always `webrtc`.
171
+ */
172
+ type: 'webrtc';
173
+ }
174
+ }
175
+
176
+ export interface SessionAcceptParams {
177
+ /**
178
+ * Model and startup configuration for the Live session that answers the incoming
179
+ * SIP call.
180
+ */
181
+ session: SessionAcceptParams.Session;
182
+ }
183
+
184
+ export namespace SessionAcceptParams {
185
+ /**
186
+ * Model and startup configuration for the Live session that answers the incoming
187
+ * SIP call.
188
+ */
189
+ export interface Session {
190
+ /**
191
+ * The Live model to use for the accepted call.
192
+ */
193
+ model: (string & {}) | 'gpt-live-1';
194
+
195
+ /**
196
+ * The session type. Always `live`.
197
+ */
198
+ type: 'live';
199
+
200
+ /**
201
+ * Startup audio output configuration. SIP negotiates the media format;
202
+ * audio.format is only accepted for primary WebSockets. Voice cannot change after
203
+ * startup.
204
+ */
205
+ audio?: Session.Audio;
206
+
207
+ /**
208
+ * Who handles tasks delegated by the Live model. Omitted or null selects your
209
+ * application; use `responses` to let the API manage a Responses backend.
210
+ */
211
+ delegation?: LiveAPI.ClientDelegation | Session.Responses | null;
212
+
213
+ /**
214
+ * Ordered text-only history supplied before startup. Supports developer, user, and
215
+ * assistant messages with one text part each; at most 128 messages and 8,192
216
+ * rendered tokens in total.
217
+ */
218
+ input?: Array<LiveAPI.InitialItem>;
219
+
220
+ /**
221
+ * Frontend instructions for voice, conversation, interruptions, and when to
222
+ * delegate. Start with the
223
+ * [Live prompting guide](https://developers.openai.com/api/docs/guides/live-prompting);
224
+ * put business rules and tool workflows in a separate
225
+ * [backend prompt](https://developers.openai.com/api/docs/guides/live-delegation#start-with-your-existing-backend-prompt).
226
+ * Limited to 16,384 client-supplied tokens. Omitted or blank instructions use
227
+ * server defaults. Immutable after startup.
228
+ */
229
+ instructions?: string | null;
230
+
231
+ /**
232
+ * Whether to store the session for later forking and recording download. Defaults
233
+ * to false for new sessions.
234
+ */
235
+ store?: boolean;
236
+ }
237
+
238
+ export namespace Session {
239
+ /**
240
+ * Startup audio output configuration. SIP negotiates the media format;
241
+ * audio.format is only accepted for primary WebSockets. Voice cannot change after
242
+ * startup.
243
+ */
244
+ export interface Audio {
245
+ /**
246
+ * Settings for speech generated by the Live model. Choose the voice before
247
+ * starting the session.
248
+ */
249
+ output?: Audio.Output;
250
+ }
251
+
252
+ export namespace Audio {
253
+ /**
254
+ * Settings for speech generated by the Live model. Choose the voice before
255
+ * starting the session.
256
+ */
257
+ export interface Output {
258
+ /**
259
+ * The voice used for Live speech, as a built-in voice name or a custom voice
260
+ * object containing its ID. Defaults to `marin` and cannot change after startup.
261
+ */
262
+ voice?: string | LiveAPI.BuiltInVoice | LiveAPI.CustomVoice;
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Delegate tasks to a Responses model managed by the Live session.
268
+ */
269
+ export interface Responses {
270
+ /**
271
+ * Backend model, prompt, and tools used when the Live session delegates a task to
272
+ * Responses.
273
+ */
274
+ responses: LiveAPI.ResponsesDelegationConfig;
275
+
276
+ /**
277
+ * The delegation owner. Always `responses` for tasks handled by the Responses API.
278
+ */
279
+ type: 'responses';
280
+ }
281
+ }
282
+ }
283
+
284
+ export interface SessionForkParams {
285
+ /**
286
+ * WebRTC transport with an SDP offer for the new connection to the forked session.
287
+ */
288
+ transport: SessionForkParams.Transport;
289
+
290
+ /**
291
+ * Optional configuration overrides for the new Live session. Omit this object or
292
+ * send an empty object to inherit the stored session's settings.
293
+ */
294
+ session?: LiveAPI.MediaSessionForkConfig;
295
+ }
296
+
297
+ export namespace SessionForkParams {
298
+ /**
299
+ * WebRTC transport with an SDP offer for the new connection to the forked session.
300
+ */
301
+ export interface Transport {
302
+ /**
303
+ * Session Description Protocol message for the WebRTC connection.
304
+ */
305
+ sdp: string;
306
+
307
+ /**
308
+ * The transport used for the Live session. Always `webrtc`.
309
+ */
310
+ type: 'webrtc';
311
+ }
312
+ }
313
+
314
+ export interface SessionReferParams {
315
+ /**
316
+ * Nonblank URI for the SIP Refer-To header, such as tel:+14155550123 or
317
+ * sip:agent@example.com.
318
+ */
319
+ target_uri: string;
320
+ }
321
+
322
+ export interface SessionRejectParams {
323
+ /**
324
+ * SIP rejection status sent to the caller. This field is required.
325
+ */
326
+ status_code: number;
327
+ }
328
+
329
+ export declare namespace Sessions {
330
+ export {
331
+ type SessionForkResponse as SessionForkResponse,
332
+ type SessionAcceptParams as SessionAcceptParams,
333
+ type SessionForkParams as SessionForkParams,
334
+ type SessionReferParams as SessionReferParams,
335
+ type SessionRejectParams as SessionRejectParams,
336
+ };
337
+ }
@@ -0,0 +1,10 @@
1
+ // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Sideband,
5
+ type ConnectClientEvent,
6
+ type ConnectServerEvent,
7
+ type SidebandConnectParams,
8
+ } from './sideband';
9
+ export { type SidebandWSClientOptions } from './ws';
10
+ export { type SidebandWSReconnectOptions, type SidebandWSParameters } from './ws-base';
@@ -0,0 +1,107 @@
1
+ // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
+
3
+ import * as LiveAPI from '../live';
4
+ import * as SidebandAPI from './sideband';
5
+ import { OpenAI } from '../../../client';
6
+ import { EventEmitter } from '../../../core/EventEmitter';
7
+ import { OpenAIError } from '../../../core/error';
8
+ import { path } from '../../../internal/utils/path';
9
+
10
+ import type { RawWebSocketData, ReconnectingEvent, UnsentMessage } from '../../../internal/ws';
11
+ import { SidebandWSParameters } from './ws-base';
12
+
13
+ export type SidebandStreamMessage =
14
+ | { type: 'connecting' | 'open' | 'closing' }
15
+ | { type: 'close'; code: number; reason: string; unsent: UnsentMessage<SidebandAPI.ConnectClientEvent>[] }
16
+ | { type: 'reconnecting'; reconnect: ReconnectingEvent<SidebandWSParameters> }
17
+ | { type: 'reconnected' }
18
+ | { type: 'message'; message: SidebandAPI.ConnectServerEvent }
19
+ | { type: 'raw'; data: RawWebSocketData }
20
+ | { type: 'error'; error: WebSocketError };
21
+
22
+ export class WebSocketError extends OpenAIError {
23
+ /**
24
+ * The error data that the API sent back in an error event.
25
+ */
26
+ error?: LiveAPI.ErrorEvent | undefined;
27
+
28
+ constructor(message: string, event: LiveAPI.ErrorEvent | null) {
29
+ super(message);
30
+
31
+ this.error = event ?? undefined;
32
+ }
33
+ }
34
+
35
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
36
+
37
+ type WebSocketEvents = Simplify<
38
+ {
39
+ event: (event: SidebandAPI.ConnectServerEvent) => void;
40
+ raw: (data: RawWebSocketData) => void;
41
+ error: (error: WebSocketError) => void;
42
+ close: (code: number, reason: string, unsent: UnsentMessage<SidebandAPI.ConnectClientEvent>[]) => void;
43
+ reconnecting: (event: ReconnectingEvent<SidebandWSParameters>) => void;
44
+ reconnected: () => void;
45
+ } & {
46
+ [EventType in Exclude<NonNullable<SidebandAPI.ConnectServerEvent['type']>, 'error'>]: (
47
+ event: Extract<SidebandAPI.ConnectServerEvent, { type?: EventType }>,
48
+ ) => unknown;
49
+ }
50
+ >;
51
+
52
+ export abstract class SidebandEmitter extends EventEmitter<WebSocketEvents> {
53
+ /**
54
+ * Send an event to the API.
55
+ */
56
+ abstract send(event: SidebandAPI.ConnectClientEvent): void;
57
+
58
+ /**
59
+ * Send raw data over the WebSocket without JSON serialization.
60
+ */
61
+ abstract sendRaw(data: RawWebSocketData): void;
62
+
63
+ /**
64
+ * Close the WebSocket connection.
65
+ */
66
+ abstract close(props?: { code: number; reason: string }): void;
67
+
68
+ protected _onError(event: null, message: string, cause: any): void;
69
+ protected _onError(event: LiveAPI.ErrorEvent, message?: string | undefined): void;
70
+ protected _onError(event: LiveAPI.ErrorEvent | null, message?: string | undefined, cause?: any): void {
71
+ message = message ?? safeJSONStringify(event) ?? 'unknown error';
72
+
73
+ if (!this._hasListener('error')) {
74
+ const error = new WebSocketError(
75
+ message +
76
+ `\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`ws.on('error', (error) => ...)\` `,
77
+ event,
78
+ );
79
+ // @ts-ignore
80
+ error.cause = cause;
81
+ Promise.reject(error);
82
+ return;
83
+ }
84
+
85
+ const error = new WebSocketError(message, event);
86
+ // @ts-ignore
87
+ error.cause = cause;
88
+
89
+ this._emit('error', error);
90
+ }
91
+ }
92
+
93
+ export function buildURL(client: OpenAI, parameters: Record<string, unknown>): URL {
94
+ const { session_id: path0, ...query } = parameters;
95
+ const endpoint = path`/live/sessions/${path0}/attach`;
96
+ const url = new URL(client.buildURL(endpoint, query, undefined));
97
+ url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';
98
+ return url;
99
+ }
100
+
101
+ function safeJSONStringify(value: unknown): string | null {
102
+ try {
103
+ return JSON.stringify(value);
104
+ } catch {
105
+ return null;
106
+ }
107
+ }
@@ -0,0 +1,58 @@
1
+ // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as LiveAPI from '../live';
5
+
6
+ export class Sideband extends APIResource {}
7
+
8
+ /**
9
+ * Client events accepted by an attached Live sideband WebSocket. The session is
10
+ * already started; send audio over the primary connection.
11
+ */
12
+ export type ConnectClientEvent =
13
+ | LiveAPI.SessionUpdateEvent
14
+ | LiveAPI.InputAudioMuteEvent
15
+ | LiveAPI.InputAudioUnmuteEvent
16
+ | LiveAPI.InstructionsAppendEvent
17
+ | LiveAPI.ThinkingAppendEvent
18
+ | LiveAPI.CommentaryAppendEvent
19
+ | LiveAPI.ResponseItemCreateEvent
20
+ | LiveAPI.ResponseCreateEvent
21
+ | LiveAPI.SessionCloseEvent;
22
+
23
+ /**
24
+ * Server events received by an attached Live sideband WebSocket. Audio deltas are
25
+ * delivered over the primary connection.
26
+ */
27
+ export type ConnectServerEvent =
28
+ | LiveAPI.SessionStartedEvent
29
+ | LiveAPI.SessionUpdatedEvent
30
+ | LiveAPI.InputAudioMutedEvent
31
+ | LiveAPI.InputAudioUnmutedEvent
32
+ | LiveAPI.InstructionsAppendedEvent
33
+ | LiveAPI.ThinkingAppendedEvent
34
+ | LiveAPI.CommentaryAppendedEvent
35
+ | LiveAPI.InputTranscriptDeltaEvent
36
+ | LiveAPI.OutputTranscriptDeltaEvent
37
+ | LiveAPI.DelegationCreatedEvent
38
+ | LiveAPI.ResponseEvent
39
+ | LiveAPI.SessionUsageUpdatedEvent
40
+ | LiveAPI.SessionClosedEvent
41
+ | LiveAPI.ErrorEvent
42
+ | LiveAPI.InfoEvent;
43
+
44
+ export interface SidebandConnectParams {
45
+ /**
46
+ * Opt in to the graceful WebSocket closing handshake when the session ends. The
47
+ * server may also enable this behavior by default.
48
+ */
49
+ graceful_close?: boolean;
50
+ }
51
+
52
+ export declare namespace Sideband {
53
+ export {
54
+ type ConnectClientEvent as ConnectClientEvent,
55
+ type ConnectServerEvent as ConnectServerEvent,
56
+ type SidebandConnectParams as SidebandConnectParams,
57
+ };
58
+ }