sessions.mjs 1.0 KB

12345678910111213141516171819202122232425262728
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. import { APIResource } from "../../../core/resource.mjs";
  3. import { buildHeaders } from "../../../internal/headers.mjs";
  4. export class Sessions extends APIResource {
  5. /**
  6. * Create an ephemeral API token for use in client-side applications with the
  7. * Realtime API. Can be configured with the same session parameters as the
  8. * `session.update` client event.
  9. *
  10. * It responds with a session object, plus a `client_secret` key which contains a
  11. * usable ephemeral API token that can be used to authenticate browser clients for
  12. * the Realtime API.
  13. *
  14. * @example
  15. * ```ts
  16. * const session =
  17. * await client.beta.realtime.sessions.create();
  18. * ```
  19. */
  20. create(body, options) {
  21. return this._client.post('/realtime/sessions', {
  22. body,
  23. ...options,
  24. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  25. });
  26. }
  27. }
  28. //# sourceMappingURL=sessions.mjs.map