sessions.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import { path } from "../../../internal/utils/path.mjs";
  5. export class Sessions extends APIResource {
  6. /**
  7. * Create a ChatKit session
  8. *
  9. * @example
  10. * ```ts
  11. * const chatSession =
  12. * await client.beta.chatkit.sessions.create({
  13. * user: 'x',
  14. * workflow: { id: 'id' },
  15. * });
  16. * ```
  17. */
  18. create(body, options) {
  19. return this._client.post('/chatkit/sessions', {
  20. body,
  21. ...options,
  22. headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  23. });
  24. }
  25. /**
  26. * Cancel a ChatKit session
  27. *
  28. * @example
  29. * ```ts
  30. * const chatSession =
  31. * await client.beta.chatkit.sessions.cancel('cksess_123');
  32. * ```
  33. */
  34. cancel(sessionID, options) {
  35. return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
  36. ...options,
  37. headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  38. });
  39. }
  40. }
  41. //# sourceMappingURL=sessions.mjs.map