calls.d.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { APIResource } from "../../core/resource.js";
  2. import * as RealtimeAPI from "./realtime.js";
  3. import * as ResponsesAPI from "../responses/responses.js";
  4. import { APIPromise } from "../../core/api-promise.js";
  5. import { RequestOptions } from "../../internal/request-options.js";
  6. export declare class Calls extends APIResource {
  7. /**
  8. * Accept an incoming SIP call and configure the realtime session that will handle
  9. * it.
  10. *
  11. * @example
  12. * ```ts
  13. * await client.realtime.calls.accept('call_id', {
  14. * type: 'realtime',
  15. * });
  16. * ```
  17. */
  18. accept(callID: string, body: CallAcceptParams, options?: RequestOptions): APIPromise<void>;
  19. /**
  20. * End an active Realtime API call, whether it was initiated over SIP or WebRTC.
  21. *
  22. * @example
  23. * ```ts
  24. * await client.realtime.calls.hangup('call_id');
  25. * ```
  26. */
  27. hangup(callID: string, options?: RequestOptions): APIPromise<void>;
  28. /**
  29. * Transfer an active SIP call to a new destination using the SIP REFER verb.
  30. *
  31. * @example
  32. * ```ts
  33. * await client.realtime.calls.refer('call_id', {
  34. * target_uri: 'tel:+14155550123',
  35. * });
  36. * ```
  37. */
  38. refer(callID: string, body: CallReferParams, options?: RequestOptions): APIPromise<void>;
  39. /**
  40. * Decline an incoming SIP call by returning a SIP status code to the caller.
  41. *
  42. * @example
  43. * ```ts
  44. * await client.realtime.calls.reject('call_id');
  45. * ```
  46. */
  47. reject(callID: string, body?: CallRejectParams | null | undefined, options?: RequestOptions): APIPromise<void>;
  48. }
  49. export interface CallAcceptParams {
  50. /**
  51. * The type of session to create. Always `realtime` for the Realtime API.
  52. */
  53. type: 'realtime';
  54. /**
  55. * Configuration for input and output audio.
  56. */
  57. audio?: RealtimeAPI.RealtimeAudioConfig;
  58. /**
  59. * Additional fields to include in server outputs.
  60. *
  61. * `item.input_audio_transcription.logprobs`: Include logprobs for input audio
  62. * transcription.
  63. */
  64. include?: Array<'item.input_audio_transcription.logprobs'>;
  65. /**
  66. * The default system instructions (i.e. system message) prepended to model calls.
  67. * This field allows the client to guide the model on desired responses. The model
  68. * can be instructed on response content and format, (e.g. "be extremely succinct",
  69. * "act friendly", "here are examples of good responses") and on audio behavior
  70. * (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
  71. * instructions are not guaranteed to be followed by the model, but they provide
  72. * guidance to the model on the desired behavior.
  73. *
  74. * Note that the server sets default instructions which will be used if this field
  75. * is not set and are visible in the `session.created` event at the start of the
  76. * session.
  77. */
  78. instructions?: string;
  79. /**
  80. * Maximum number of output tokens for a single assistant response, inclusive of
  81. * tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
  82. * `inf` for the maximum available tokens for a given model. Defaults to `inf`.
  83. */
  84. max_output_tokens?: number | 'inf';
  85. /**
  86. * The Realtime model used for this session.
  87. */
  88. model?: (string & {}) | 'gpt-realtime' | 'gpt-realtime-2025-08-28' | 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17' | 'gpt-realtime-mini' | 'gpt-realtime-mini-2025-10-06' | 'gpt-realtime-mini-2025-12-15' | 'gpt-audio-mini' | 'gpt-audio-mini-2025-10-06' | 'gpt-audio-mini-2025-12-15';
  89. /**
  90. * The set of modalities the model can respond with. It defaults to `["audio"]`,
  91. * indicating that the model will respond with audio plus a transcript. `["text"]`
  92. * can be used to make the model respond with text only. It is not possible to
  93. * request both `text` and `audio` at the same time.
  94. */
  95. output_modalities?: Array<'text' | 'audio'>;
  96. /**
  97. * Reference to a prompt template and its variables.
  98. * [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
  99. */
  100. prompt?: ResponsesAPI.ResponsePrompt | null;
  101. /**
  102. * How the model chooses tools. Provide one of the string modes or force a specific
  103. * function/MCP tool.
  104. */
  105. tool_choice?: RealtimeAPI.RealtimeToolChoiceConfig;
  106. /**
  107. * Tools available to the model.
  108. */
  109. tools?: RealtimeAPI.RealtimeToolsConfig;
  110. /**
  111. * Realtime API can write session traces to the
  112. * [Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
  113. * tracing is enabled for a session, the configuration cannot be modified.
  114. *
  115. * `auto` will create a trace for the session with default values for the workflow
  116. * name, group id, and metadata.
  117. */
  118. tracing?: RealtimeAPI.RealtimeTracingConfig | null;
  119. /**
  120. * When the number of tokens in a conversation exceeds the model's input token
  121. * limit, the conversation be truncated, meaning messages (starting from the
  122. * oldest) will not be included in the model's context. A 32k context model with
  123. * 4,096 max output tokens can only include 28,224 tokens in the context before
  124. * truncation occurs.
  125. *
  126. * Clients can configure truncation behavior to truncate with a lower max token
  127. * limit, which is an effective way to control token usage and cost.
  128. *
  129. * Truncation will reduce the number of cached tokens on the next turn (busting the
  130. * cache), since messages are dropped from the beginning of the context. However,
  131. * clients can also configure truncation to retain messages up to a fraction of the
  132. * maximum context size, which will reduce the need for future truncations and thus
  133. * improve the cache rate.
  134. *
  135. * Truncation can be disabled entirely, which means the server will never truncate
  136. * but would instead return an error if the conversation exceeds the model's input
  137. * token limit.
  138. */
  139. truncation?: RealtimeAPI.RealtimeTruncation;
  140. }
  141. export interface CallReferParams {
  142. /**
  143. * URI that should appear in the SIP Refer-To header. Supports values like
  144. * `tel:+14155550123` or `sip:agent@example.com`.
  145. */
  146. target_uri: string;
  147. }
  148. export interface CallRejectParams {
  149. /**
  150. * SIP response code to send back to the caller. Defaults to `603` (Decline) when
  151. * omitted.
  152. */
  153. status_code?: number;
  154. }
  155. export declare namespace Calls {
  156. export { type CallAcceptParams as CallAcceptParams, type CallReferParams as CallReferParams, type CallRejectParams as CallRejectParams, };
  157. }
  158. //# sourceMappingURL=calls.d.ts.map