@perplexity-ai/perplexity_ai 0.32.0 → 0.33.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 (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +1 -1
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/index.d.mts +1 -1
  12. package/resources/index.d.mts.map +1 -1
  13. package/resources/index.d.ts +1 -1
  14. package/resources/index.d.ts.map +1 -1
  15. package/resources/index.js +1 -1
  16. package/resources/index.js.map +1 -1
  17. package/resources/index.mjs +1 -1
  18. package/resources/index.mjs.map +1 -1
  19. package/resources/responses/files.d.mts +26 -0
  20. package/resources/responses/files.d.mts.map +1 -0
  21. package/resources/responses/files.d.ts +26 -0
  22. package/resources/responses/files.d.ts.map +1 -0
  23. package/resources/responses/files.js +30 -0
  24. package/resources/responses/files.js.map +1 -0
  25. package/resources/responses/files.mjs +26 -0
  26. package/resources/responses/files.mjs.map +1 -0
  27. package/resources/responses/index.d.mts +3 -0
  28. package/resources/responses/index.d.mts.map +1 -0
  29. package/resources/responses/index.d.ts +3 -0
  30. package/resources/responses/index.d.ts.map +1 -0
  31. package/resources/responses/index.js +9 -0
  32. package/resources/responses/index.js.map +1 -0
  33. package/resources/responses/index.mjs +4 -0
  34. package/resources/responses/index.mjs.map +1 -0
  35. package/resources/responses/responses.d.mts +969 -0
  36. package/resources/responses/responses.d.mts.map +1 -0
  37. package/resources/responses/responses.d.ts +969 -0
  38. package/resources/responses/responses.d.ts.map +1 -0
  39. package/resources/responses/responses.js +38 -0
  40. package/resources/responses/responses.js.map +1 -0
  41. package/resources/responses/responses.mjs +33 -0
  42. package/resources/responses/responses.mjs.map +1 -0
  43. package/resources/responses.d.mts +1 -927
  44. package/resources/responses.d.mts.map +1 -1
  45. package/resources/responses.d.ts +1 -927
  46. package/resources/responses.d.ts.map +1 -1
  47. package/resources/responses.js +2 -26
  48. package/resources/responses.js.map +1 -1
  49. package/resources/responses.mjs +1 -24
  50. package/resources/responses.mjs.map +1 -1
  51. package/src/client.ts +9 -5
  52. package/src/resources/index.ts +3 -1
  53. package/src/resources/responses/files.ts +42 -0
  54. package/src/resources/responses/index.ts +23 -0
  55. package/src/resources/responses/responses.ts +1316 -0
  56. package/src/resources/responses.ts +1 -1259
  57. package/src/version.ts +1 -1
  58. package/version.d.mts +1 -1
  59. package/version.d.ts +1 -1
  60. package/version.js +1 -1
  61. package/version.mjs +1 -1
@@ -0,0 +1,1316 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as ResponsesAPI from './responses';
5
+ import * as Shared from '../shared';
6
+ import * as FilesAPI from './files';
7
+ import { FileContentParams, Files } from './files';
8
+ import { APIPromise } from '../../core/api-promise';
9
+ import { Stream } from '../../core/streaming';
10
+ import { RequestOptions } from '../../internal/request-options';
11
+ import { addOutputText } from '../../lib/add-output-text';
12
+ import { path } from '../../internal/utils/path';
13
+
14
+ export class Responses extends APIResource {
15
+ files: FilesAPI.Files = new FilesAPI.Files(this._client);
16
+
17
+ /**
18
+ * Generate a response for the provided input with optional web search and
19
+ * reasoning.
20
+ */
21
+ create(
22
+ body: ResponseCreateParamsNonStreaming,
23
+ options?: RequestOptions,
24
+ ): APIPromise<ResponseCreateResponse>;
25
+ create(
26
+ body: ResponseCreateParamsStreaming,
27
+ options?: RequestOptions,
28
+ ): APIPromise<Stream<ResponseStreamChunk>>;
29
+ create(
30
+ body: ResponseCreateParamsBase,
31
+ options?: RequestOptions,
32
+ ): APIPromise<Stream<ResponseStreamChunk> | ResponseCreateResponse>;
33
+ create(
34
+ body: ResponseCreateParams,
35
+ options?: RequestOptions,
36
+ ): APIPromise<ResponseCreateResponse> | APIPromise<Stream<ResponseStreamChunk>> {
37
+ const promise = this._client.post('/v1/responses', { body, ...options, stream: body.stream ?? false });
38
+
39
+ // For non-streaming responses, automatically add output_text property
40
+ if (!body.stream) {
41
+ return (promise as APIPromise<ResponseCreateResponse>)._thenUnwrap((rsp) => {
42
+ if ('object' in rsp && rsp.object === 'response') {
43
+ addOutputText(rsp as ResponseCreateResponse);
44
+ }
45
+ return rsp;
46
+ }) as APIPromise<ResponseCreateResponse>;
47
+ }
48
+
49
+ return promise as APIPromise<Stream<ResponseStreamChunk>>;
50
+ }
51
+
52
+ /**
53
+ * Retrieve a response by its ID. Use this to poll the status of background tasks.
54
+ */
55
+ retrieve(responseID: string, options?: RequestOptions): APIPromise<ResponseRetrieveResponse> {
56
+ return this._client.get(path`/v1/responses/${responseID}`, options);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Text annotation (e.g., URL citation)
62
+ */
63
+ export interface Annotation {
64
+ end_index?: number;
65
+
66
+ start_index?: number;
67
+
68
+ title?: string;
69
+
70
+ type?: string;
71
+
72
+ url?: string;
73
+ }
74
+
75
+ export interface ContentPart {
76
+ text: string;
77
+
78
+ /**
79
+ * Type of a content part
80
+ */
81
+ type: 'output_text';
82
+
83
+ annotations?: Array<Annotation>;
84
+ }
85
+
86
+ export interface ErrorInfo {
87
+ message: string;
88
+
89
+ code?: string;
90
+
91
+ type?: string;
92
+ }
93
+
94
+ export interface FunctionCallOutputItem {
95
+ id: string;
96
+
97
+ /**
98
+ * JSON string of arguments
99
+ */
100
+ arguments: string;
101
+
102
+ /**
103
+ * Correlates with function_call_output input
104
+ */
105
+ call_id: string;
106
+
107
+ name: string;
108
+
109
+ /**
110
+ * Status of a response or output item
111
+ */
112
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
113
+
114
+ type: 'function_call';
115
+
116
+ /**
117
+ * Base64-encoded opaque signature for thinking models
118
+ */
119
+ thought_signature?: string;
120
+ }
121
+
122
+ export interface FunctionTool {
123
+ /**
124
+ * The name of the function
125
+ */
126
+ name: string;
127
+
128
+ type: 'function';
129
+
130
+ /**
131
+ * A description of what the function does
132
+ */
133
+ description?: string;
134
+
135
+ /**
136
+ * JSON Schema defining the function's parameters
137
+ */
138
+ parameters?: { [key: string]: unknown };
139
+
140
+ /**
141
+ * Whether to enable strict schema validation
142
+ */
143
+ strict?: boolean;
144
+ }
145
+
146
+ export type InputItem =
147
+ | InputItem.InputMessage
148
+ | InputItem.FunctionCallOutputInput
149
+ | InputItem.FunctionCallInput;
150
+
151
+ export namespace InputItem {
152
+ export interface InputMessage {
153
+ /**
154
+ * Message content - either a string or array of content parts
155
+ */
156
+ content: string | Array<InputMessage.ContentPartArray>;
157
+
158
+ role: 'user' | 'assistant' | 'system' | 'developer';
159
+
160
+ type: 'message';
161
+ }
162
+
163
+ export namespace InputMessage {
164
+ export interface ContentPartArray {
165
+ type: 'input_text' | 'input_image';
166
+
167
+ image_url?: string;
168
+
169
+ text?: string;
170
+ }
171
+ }
172
+
173
+ export interface FunctionCallOutputInput {
174
+ /**
175
+ * The call_id from function_call output
176
+ */
177
+ call_id: string;
178
+
179
+ /**
180
+ * Function result (JSON string)
181
+ */
182
+ output: string;
183
+
184
+ type: 'function_call_output';
185
+
186
+ /**
187
+ * Function name (required by some providers)
188
+ */
189
+ name?: string;
190
+
191
+ /**
192
+ * Base64-encoded signature from function_call
193
+ */
194
+ thought_signature?: string;
195
+ }
196
+
197
+ export interface FunctionCallInput {
198
+ /**
199
+ * Function arguments (JSON string)
200
+ */
201
+ arguments: string;
202
+
203
+ /**
204
+ * The call_id that correlates with function_call_output
205
+ */
206
+ call_id: string;
207
+
208
+ /**
209
+ * The function name
210
+ */
211
+ name: string;
212
+
213
+ type: 'function_call';
214
+
215
+ /**
216
+ * Base64-encoded signature for thinking models
217
+ */
218
+ thought_signature?: string;
219
+ }
220
+ }
221
+
222
+ export type OutputItem =
223
+ | OutputItem.MessageOutputItem
224
+ | OutputItem.SearchResultsOutputItem
225
+ | OutputItem.FetchURLResultsOutputItem
226
+ | FunctionCallOutputItem;
227
+
228
+ export namespace OutputItem {
229
+ export interface MessageOutputItem {
230
+ id: string;
231
+
232
+ content: Array<ResponsesAPI.ContentPart>;
233
+
234
+ /**
235
+ * Role in a message
236
+ */
237
+ role: 'assistant';
238
+
239
+ /**
240
+ * Status of a response or output item
241
+ */
242
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
243
+
244
+ type: 'message';
245
+ }
246
+
247
+ export interface SearchResultsOutputItem {
248
+ results: Array<Shared.SearchResult>;
249
+
250
+ type: 'search_results';
251
+
252
+ queries?: Array<string>;
253
+ }
254
+
255
+ export interface FetchURLResultsOutputItem {
256
+ contents: Array<FetchURLResultsOutputItem.Content>;
257
+
258
+ type: 'fetch_url_results';
259
+ }
260
+
261
+ export namespace FetchURLResultsOutputItem {
262
+ /**
263
+ * Content fetched from a URL
264
+ */
265
+ export interface Content {
266
+ /**
267
+ * The fetched content snippet
268
+ */
269
+ snippet: string;
270
+
271
+ /**
272
+ * The title of the page
273
+ */
274
+ title: string;
275
+
276
+ /**
277
+ * The URL from which content was fetched
278
+ */
279
+ url: string;
280
+ }
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Metadata for a file shared from a response sandbox via the share_file tool.
286
+ */
287
+ export interface ResponseFile {
288
+ /**
289
+ * File identifier, scoped to the parent response.
290
+ */
291
+ id: string;
292
+
293
+ /**
294
+ * Size of the file in bytes.
295
+ */
296
+ bytes: number;
297
+
298
+ /**
299
+ * Unix timestamp (seconds) when the file was produced.
300
+ */
301
+ created_at: number;
302
+
303
+ /**
304
+ * Original filename set by the share_file tool call.
305
+ */
306
+ filename: string;
307
+
308
+ /**
309
+ * Object type. Always `file`.
310
+ */
311
+ object: 'file';
312
+ }
313
+
314
+ export interface ResponseFileList {
315
+ data: Array<ResponseFile>;
316
+
317
+ /**
318
+ * Object type. Always `list`.
319
+ */
320
+ object: 'list';
321
+ }
322
+
323
+ /**
324
+ * SSE stream event. Discriminate by the `type` field:
325
+ *
326
+ * - `response.created`: Initial response object
327
+ * - `response.in_progress`: Response processing started
328
+ * - `response.completed`: Final response with output
329
+ * - `response.failed`: Error occurred
330
+ * - `response.output_item.added`: New output item started
331
+ * - `response.output_item.done`: Output item completed
332
+ * - `response.output_text.delta`: Streaming text delta
333
+ * - `response.output_text.done`: Final text content
334
+ * - `response.reasoning.started`: Reasoning phase started
335
+ * - `response.reasoning.search_queries`: Search queries issued
336
+ * - `response.reasoning.search_results`: Search results received
337
+ * - `response.reasoning.fetch_url_queries`: URL fetch queries issued
338
+ * - `response.reasoning.fetch_url_results`: URL fetch results received
339
+ * - `response.reasoning.stopped`: Reasoning phase complete
340
+ */
341
+ export type ResponseStreamChunk =
342
+ | ResponseStreamChunk.ResponseCreatedEvent
343
+ | ResponseStreamChunk.ResponseInProgressEvent
344
+ | ResponseStreamChunk.ResponseCompletedEvent
345
+ | ResponseStreamChunk.ResponseFailedEvent
346
+ | ResponseStreamChunk.OutputItemAddedEvent
347
+ | ResponseStreamChunk.OutputItemDoneEvent
348
+ | ResponseStreamChunk.TextDeltaEvent
349
+ | ResponseStreamChunk.TextDoneEvent
350
+ | ResponseStreamChunk.ReasoningStartedEvent
351
+ | ResponseStreamChunk.SearchQueriesEvent
352
+ | ResponseStreamChunk.SearchResultsEvent
353
+ | ResponseStreamChunk.FetchURLQueriesEvent
354
+ | ResponseStreamChunk.FetchURLResultsEvent
355
+ | ResponseStreamChunk.ReasoningStoppedEvent;
356
+
357
+ export namespace ResponseStreamChunk {
358
+ /**
359
+ * Response created event (type: "response.created"). Contains the initial response
360
+ * object.
361
+ */
362
+ export interface ResponseCreatedEvent {
363
+ /**
364
+ * Monotonically increasing sequence number for event ordering
365
+ */
366
+ sequence_number: number;
367
+
368
+ /**
369
+ * SSE event type discriminator (always "response.created")
370
+ */
371
+ type: 'response.created';
372
+
373
+ /**
374
+ * Non-streaming response returned when stream is false
375
+ */
376
+ response?: ResponseCreatedEvent.Response;
377
+ }
378
+
379
+ export namespace ResponseCreatedEvent {
380
+ /**
381
+ * Non-streaming response returned when stream is false
382
+ */
383
+ export interface Response {
384
+ id: string;
385
+
386
+ created_at: number;
387
+
388
+ model: string;
389
+
390
+ /**
391
+ * Object type in API responses
392
+ */
393
+ object: 'response';
394
+
395
+ output: Array<ResponsesAPI.OutputItem>;
396
+
397
+ /**
398
+ * Status of a response or output item
399
+ */
400
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
401
+
402
+ /**
403
+ * Whether the response was created in background mode.
404
+ */
405
+ background?: boolean;
406
+
407
+ error?: ResponsesAPI.ErrorInfo;
408
+
409
+ usage?: ResponsesAPI.ResponsesUsage;
410
+ }
411
+ }
412
+
413
+ /**
414
+ * Response in progress event (type: "response.in_progress"). Emitted when response
415
+ * processing has started.
416
+ */
417
+ export interface ResponseInProgressEvent {
418
+ /**
419
+ * Monotonically increasing sequence number for event ordering
420
+ */
421
+ sequence_number: number;
422
+
423
+ /**
424
+ * SSE event type discriminator (always "response.in_progress")
425
+ */
426
+ type: 'response.in_progress';
427
+
428
+ /**
429
+ * Non-streaming response returned when stream is false
430
+ */
431
+ response?: ResponseInProgressEvent.Response;
432
+ }
433
+
434
+ export namespace ResponseInProgressEvent {
435
+ /**
436
+ * Non-streaming response returned when stream is false
437
+ */
438
+ export interface Response {
439
+ id: string;
440
+
441
+ created_at: number;
442
+
443
+ model: string;
444
+
445
+ /**
446
+ * Object type in API responses
447
+ */
448
+ object: 'response';
449
+
450
+ output: Array<ResponsesAPI.OutputItem>;
451
+
452
+ /**
453
+ * Status of a response or output item
454
+ */
455
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
456
+
457
+ /**
458
+ * Whether the response was created in background mode.
459
+ */
460
+ background?: boolean;
461
+
462
+ error?: ResponsesAPI.ErrorInfo;
463
+
464
+ usage?: ResponsesAPI.ResponsesUsage;
465
+ }
466
+ }
467
+
468
+ /**
469
+ * Response event Contains the full or partial response object.
470
+ */
471
+ export interface ResponseCompletedEvent {
472
+ /**
473
+ * Monotonically increasing sequence number for event ordering
474
+ */
475
+ sequence_number: number;
476
+
477
+ /**
478
+ * SSE event type discriminator (always "response.completed")
479
+ */
480
+ type: 'response.completed';
481
+
482
+ /**
483
+ * Non-streaming response returned when stream is false
484
+ */
485
+ response?: ResponseCompletedEvent.Response;
486
+ }
487
+
488
+ export namespace ResponseCompletedEvent {
489
+ /**
490
+ * Non-streaming response returned when stream is false
491
+ */
492
+ export interface Response {
493
+ id: string;
494
+
495
+ created_at: number;
496
+
497
+ model: string;
498
+
499
+ /**
500
+ * Object type in API responses
501
+ */
502
+ object: 'response';
503
+
504
+ output: Array<ResponsesAPI.OutputItem>;
505
+
506
+ /**
507
+ * Status of a response or output item
508
+ */
509
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
510
+
511
+ /**
512
+ * Whether the response was created in background mode.
513
+ */
514
+ background?: boolean;
515
+
516
+ error?: ResponsesAPI.ErrorInfo;
517
+
518
+ usage?: ResponsesAPI.ResponsesUsage;
519
+ }
520
+ }
521
+
522
+ /**
523
+ * Response failed event (type: "response.failed"). Contains error details when
524
+ * streaming fails.
525
+ */
526
+ export interface ResponseFailedEvent {
527
+ error: ResponsesAPI.ErrorInfo;
528
+
529
+ /**
530
+ * Monotonically increasing sequence number for event ordering
531
+ */
532
+ sequence_number: number;
533
+
534
+ /**
535
+ * SSE event type discriminator (always "response.failed")
536
+ */
537
+ type: 'response.failed';
538
+ }
539
+
540
+ /**
541
+ * Output item added event (type: "response.output_item.added"). Emitted when a new
542
+ * output item (message or tool call) starts.
543
+ */
544
+ export interface OutputItemAddedEvent {
545
+ item: ResponsesAPI.OutputItem;
546
+
547
+ output_index: number;
548
+
549
+ /**
550
+ * Monotonically increasing sequence number for event ordering
551
+ */
552
+ sequence_number: number;
553
+
554
+ /**
555
+ * SSE event type discriminator (always "response.output_item.added")
556
+ */
557
+ type: 'response.output_item.added';
558
+ }
559
+
560
+ /**
561
+ * Output item done event (type: "response.output_item.done"). Emitted when an
562
+ * output item (message or tool call) completes.
563
+ */
564
+ export interface OutputItemDoneEvent {
565
+ item: ResponsesAPI.OutputItem;
566
+
567
+ output_index: number;
568
+
569
+ /**
570
+ * Monotonically increasing sequence number for event ordering
571
+ */
572
+ sequence_number: number;
573
+
574
+ /**
575
+ * SSE event type discriminator (always "response.output_item.done")
576
+ */
577
+ type: 'response.output_item.done';
578
+ }
579
+
580
+ /**
581
+ * Text delta event (type: "response.output_text.delta"). Contains incremental text
582
+ * content.
583
+ */
584
+ export interface TextDeltaEvent {
585
+ content_index: number;
586
+
587
+ delta: string;
588
+
589
+ item_id: string;
590
+
591
+ output_index: number;
592
+
593
+ /**
594
+ * Monotonically increasing sequence number for event ordering
595
+ */
596
+ sequence_number: number;
597
+
598
+ /**
599
+ * SSE event type discriminator (always "response.output_text.delta")
600
+ */
601
+ type: 'response.output_text.delta';
602
+ }
603
+
604
+ /**
605
+ * Text done event (type: "response.output_text.done"). Contains the final text
606
+ * content.
607
+ */
608
+ export interface TextDoneEvent {
609
+ content_index: number;
610
+
611
+ item_id: string;
612
+
613
+ output_index: number;
614
+
615
+ /**
616
+ * Monotonically increasing sequence number for event ordering
617
+ */
618
+ sequence_number: number;
619
+
620
+ text: string;
621
+
622
+ /**
623
+ * SSE event type discriminator (always "response.output_text.done")
624
+ */
625
+ type: 'response.output_text.done';
626
+ }
627
+
628
+ /**
629
+ * Reasoning started event (type: "response.reasoning.started"). Signals the model
630
+ * has started reasoning/searching.
631
+ */
632
+ export interface ReasoningStartedEvent {
633
+ /**
634
+ * Monotonically increasing sequence number for event ordering
635
+ */
636
+ sequence_number: number;
637
+
638
+ /**
639
+ * SSE event type discriminator (always "response.reasoning.started")
640
+ */
641
+ type: 'response.reasoning.started';
642
+
643
+ thought?: string;
644
+ }
645
+
646
+ /**
647
+ * Search queries event (type: "response.reasoning.search_queries"). Contains
648
+ * search queries being executed.
649
+ */
650
+ export interface SearchQueriesEvent {
651
+ queries: Array<string>;
652
+
653
+ /**
654
+ * Monotonically increasing sequence number for event ordering
655
+ */
656
+ sequence_number: number;
657
+
658
+ /**
659
+ * SSE event type discriminator (always "response.reasoning.search_queries")
660
+ */
661
+ type: 'response.reasoning.search_queries';
662
+
663
+ thought?: string;
664
+ }
665
+
666
+ /**
667
+ * Search results event (type: "response.reasoning.search_results"). Contains
668
+ * search results returned.
669
+ */
670
+ export interface SearchResultsEvent {
671
+ results: Array<Shared.SearchResult>;
672
+
673
+ /**
674
+ * Monotonically increasing sequence number for event ordering
675
+ */
676
+ sequence_number: number;
677
+
678
+ /**
679
+ * SSE event type discriminator (always "response.reasoning.search_results")
680
+ */
681
+ type: 'response.reasoning.search_results';
682
+
683
+ thought?: string;
684
+
685
+ usage?: ResponsesAPI.ResponsesUsage;
686
+ }
687
+
688
+ /**
689
+ * URL fetch queries event (type: "response.reasoning.fetch_url_queries"). Contains
690
+ * URLs being fetched.
691
+ */
692
+ export interface FetchURLQueriesEvent {
693
+ /**
694
+ * Monotonically increasing sequence number for event ordering
695
+ */
696
+ sequence_number: number;
697
+
698
+ /**
699
+ * SSE event type discriminator (always "response.reasoning.fetch_url_queries")
700
+ */
701
+ type: 'response.reasoning.fetch_url_queries';
702
+
703
+ urls: Array<string>;
704
+
705
+ thought?: string;
706
+ }
707
+
708
+ /**
709
+ * URL fetch results event (type: "response.reasoning.fetch_url_results"). Contains
710
+ * fetched URL contents.
711
+ */
712
+ export interface FetchURLResultsEvent {
713
+ contents: Array<FetchURLResultsEvent.Content>;
714
+
715
+ /**
716
+ * Monotonically increasing sequence number for event ordering
717
+ */
718
+ sequence_number: number;
719
+
720
+ /**
721
+ * SSE event type discriminator (always "response.reasoning.fetch_url_results")
722
+ */
723
+ type: 'response.reasoning.fetch_url_results';
724
+
725
+ thought?: string;
726
+ }
727
+
728
+ export namespace FetchURLResultsEvent {
729
+ /**
730
+ * Content fetched from a URL
731
+ */
732
+ export interface Content {
733
+ /**
734
+ * The fetched content snippet
735
+ */
736
+ snippet: string;
737
+
738
+ /**
739
+ * The title of the page
740
+ */
741
+ title: string;
742
+
743
+ /**
744
+ * The URL from which content was fetched
745
+ */
746
+ url: string;
747
+ }
748
+ }
749
+
750
+ /**
751
+ * Reasoning stopped event (type: "response.reasoning.stopped"). Signals the model
752
+ * has finished reasoning/searching.
753
+ */
754
+ export interface ReasoningStoppedEvent {
755
+ /**
756
+ * Monotonically increasing sequence number for event ordering
757
+ */
758
+ sequence_number: number;
759
+
760
+ /**
761
+ * SSE event type discriminator (always "response.reasoning.stopped")
762
+ */
763
+ type: 'response.reasoning.stopped';
764
+
765
+ thought?: string;
766
+ }
767
+ }
768
+
769
+ export interface ResponsesCreateParams {
770
+ /**
771
+ * Input content - either a string or array of input items
772
+ */
773
+ input: string | Array<InputItem>;
774
+
775
+ /**
776
+ * Run the response asynchronously. When true, the request is queued and the
777
+ * response object's `status` will be `queued` or `in_progress`. Poll GET
778
+ * /v1/responses/{response_id} to retrieve the final result.
779
+ */
780
+ background?: boolean | null;
781
+
782
+ /**
783
+ * System instructions for the model
784
+ */
785
+ instructions?: string;
786
+
787
+ /**
788
+ * ISO 639-1 language code for response language
789
+ */
790
+ language_preference?: string;
791
+
792
+ /**
793
+ * Maximum tokens to generate
794
+ */
795
+ max_output_tokens?: number;
796
+
797
+ /**
798
+ * Maximum number of research loop steps. If provided, overrides the preset's
799
+ * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
800
+ */
801
+ max_steps?: number;
802
+
803
+ /**
804
+ * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
805
+ * models is also provided, models takes precedence. Required if neither models nor
806
+ * preset is provided.
807
+ */
808
+ model?: string;
809
+
810
+ /**
811
+ * Model fallback chain. Each model is in provider/model format. Models are tried
812
+ * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
813
+ * single model field. The response.model will reflect the model that actually
814
+ * succeeded.
815
+ */
816
+ models?: Array<string>;
817
+
818
+ /**
819
+ * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
820
+ * model with system prompt and search parameters. Required if model is not
821
+ * provided.
822
+ */
823
+ preset?: string;
824
+
825
+ reasoning?: ResponsesCreateParams.Reasoning;
826
+
827
+ /**
828
+ * Specifies the desired output format for the model response
829
+ */
830
+ response_format?: Shared.ResponseFormat;
831
+
832
+ /**
833
+ * If true, returns SSE stream instead of JSON
834
+ */
835
+ stream?: boolean;
836
+
837
+ /**
838
+ * Tools available to the model
839
+ */
840
+ tools?: Array<
841
+ | ResponsesCreateParams.WebSearchTool
842
+ | ResponsesCreateParams.FetchURLTool
843
+ | ResponsesCreateParams.PeopleSearchTool
844
+ | FunctionTool
845
+ | ResponsesCreateParams.FinanceSearchTool
846
+ | ResponsesCreateParams.SandboxTool
847
+ >;
848
+ }
849
+
850
+ export namespace ResponsesCreateParams {
851
+ export interface Reasoning {
852
+ /**
853
+ * How much effort the model should spend on reasoning
854
+ */
855
+ effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
856
+ }
857
+
858
+ export interface WebSearchTool {
859
+ type: 'web_search';
860
+
861
+ filters?: WebSearchTool.Filters;
862
+
863
+ max_tokens?: number;
864
+
865
+ max_tokens_per_page?: number;
866
+
867
+ /**
868
+ * Search context size (low, medium, high). Omit when supplying explicit max_tokens
869
+ * / max_tokens_per_page.
870
+ */
871
+ search_context_size?: 'low' | 'medium' | 'high';
872
+
873
+ /**
874
+ * User's geographic location for search personalization
875
+ */
876
+ user_location?: WebSearchTool.UserLocation;
877
+ }
878
+
879
+ export namespace WebSearchTool {
880
+ export interface Filters {
881
+ /**
882
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
883
+ */
884
+ last_updated_after_filter?: string;
885
+
886
+ /**
887
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
888
+ */
889
+ last_updated_before_filter?: string;
890
+
891
+ /**
892
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
893
+ */
894
+ search_after_date_filter?: string;
895
+
896
+ /**
897
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
898
+ */
899
+ search_before_date_filter?: string;
900
+
901
+ search_domain_filter?: Array<string>;
902
+
903
+ search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
904
+ }
905
+
906
+ /**
907
+ * User's geographic location for search personalization
908
+ */
909
+ export interface UserLocation {
910
+ city?: string;
911
+
912
+ /**
913
+ * ISO 3166-1 alpha-2 country code
914
+ */
915
+ country?: string;
916
+
917
+ latitude?: number;
918
+
919
+ longitude?: number;
920
+
921
+ region?: string;
922
+ }
923
+ }
924
+
925
+ export interface FetchURLTool {
926
+ type: 'fetch_url';
927
+
928
+ /**
929
+ * Maximum number of URLs to fetch per tool call
930
+ */
931
+ max_urls?: number;
932
+ }
933
+
934
+ export interface PeopleSearchTool {
935
+ /**
936
+ * Enables the `people_search` tool.
937
+ */
938
+ type: 'people_search';
939
+ }
940
+
941
+ export interface FinanceSearchTool {
942
+ /**
943
+ * Enables the `finance_search` tool. The model can request structured financial
944
+ * data (quotes, financials, segments, earnings transcripts, etc.) via
945
+ * category-based fan-out to FMP, Finchat, and Quartr.
946
+ */
947
+ type: 'finance_search';
948
+ }
949
+
950
+ export interface SandboxTool {
951
+ /**
952
+ * Enables the `sandbox` tool. The model can execute code in an isolated container
953
+ * during the request and use the result in its final answer.
954
+ */
955
+ type: 'sandbox';
956
+ }
957
+ }
958
+
959
+ export interface ResponsesUsage {
960
+ input_tokens: number;
961
+
962
+ output_tokens: number;
963
+
964
+ total_tokens: number;
965
+
966
+ cost?: ResponsesUsage.Cost;
967
+
968
+ input_tokens_details?: ResponsesUsage.InputTokensDetails;
969
+
970
+ tool_calls_details?: { [key: string]: ResponsesUsage.ToolCallsDetails };
971
+ }
972
+
973
+ export namespace ResponsesUsage {
974
+ export interface Cost {
975
+ /**
976
+ * Currency code for cost values
977
+ */
978
+ currency: 'USD';
979
+
980
+ input_cost: number;
981
+
982
+ output_cost: number;
983
+
984
+ total_cost: number;
985
+
986
+ cache_creation_cost?: number;
987
+
988
+ cache_read_cost?: number;
989
+
990
+ tool_calls_cost?: number;
991
+ }
992
+
993
+ export interface InputTokensDetails {
994
+ cache_creation_input_tokens?: number;
995
+
996
+ cache_read_input_tokens?: number;
997
+ }
998
+
999
+ export interface ToolCallsDetails {
1000
+ /**
1001
+ * Number of times this tool was invoked
1002
+ */
1003
+ invocation?: number;
1004
+ }
1005
+ }
1006
+
1007
+ /**
1008
+ * Non-streaming response returned when stream is false
1009
+ */
1010
+ export interface ResponseCreateResponse {
1011
+ id: string;
1012
+
1013
+ created_at: number;
1014
+
1015
+ model: string;
1016
+
1017
+ /**
1018
+ * Object type in API responses
1019
+ */
1020
+ object: 'response';
1021
+
1022
+ output: Array<OutputItem>;
1023
+
1024
+ /**
1025
+ * Status of a response or output item
1026
+ */
1027
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
1028
+
1029
+ /**
1030
+ * Whether the response was created in background mode.
1031
+ */
1032
+ background?: boolean;
1033
+
1034
+ error?: ErrorInfo;
1035
+
1036
+ usage?: ResponsesUsage;
1037
+
1038
+ /**
1039
+ * Convenience property that aggregates all `output_text` items from the `output` list.
1040
+ * If no `output_text` content blocks exist, then an empty string is returned.
1041
+ */
1042
+ output_text?: string;
1043
+ }
1044
+
1045
+ /**
1046
+ * Non-streaming response returned when stream is false
1047
+ */
1048
+ export interface ResponseRetrieveResponse {
1049
+ id: string;
1050
+
1051
+ created_at: number;
1052
+
1053
+ model: string;
1054
+
1055
+ /**
1056
+ * Object type in API responses
1057
+ */
1058
+ object: 'response';
1059
+
1060
+ output: Array<OutputItem>;
1061
+
1062
+ /**
1063
+ * Status of a response or output item
1064
+ */
1065
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
1066
+
1067
+ /**
1068
+ * Whether the response was created in background mode.
1069
+ */
1070
+ background?: boolean;
1071
+
1072
+ error?: ErrorInfo;
1073
+
1074
+ usage?: ResponsesUsage;
1075
+
1076
+ /**
1077
+ * Convenience property that aggregates all `output_text` items from the `output` list.
1078
+ * If no `output_text` content blocks exist, then an empty string is returned.
1079
+ */
1080
+ output_text?: string;
1081
+ }
1082
+
1083
+ export type ResponseCreateParams = ResponseCreateParamsNonStreaming | ResponseCreateParamsStreaming;
1084
+
1085
+ export interface ResponseCreateParamsBase {
1086
+ /**
1087
+ * Input content - either a string or array of input items
1088
+ */
1089
+ input: string | Array<InputItem>;
1090
+
1091
+ /**
1092
+ * Run the response asynchronously. When true, the request is queued and the
1093
+ * response object's `status` will be `queued` or `in_progress`. Poll GET
1094
+ * /v1/responses/{response_id} to retrieve the final result.
1095
+ */
1096
+ background?: boolean | null;
1097
+
1098
+ /**
1099
+ * System instructions for the model
1100
+ */
1101
+ instructions?: string;
1102
+
1103
+ /**
1104
+ * ISO 639-1 language code for response language
1105
+ */
1106
+ language_preference?: string;
1107
+
1108
+ /**
1109
+ * Maximum tokens to generate
1110
+ */
1111
+ max_output_tokens?: number;
1112
+
1113
+ /**
1114
+ * Maximum number of research loop steps. If provided, overrides the preset's
1115
+ * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
1116
+ */
1117
+ max_steps?: number;
1118
+
1119
+ /**
1120
+ * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
1121
+ * models is also provided, models takes precedence. Required if neither models nor
1122
+ * preset is provided.
1123
+ */
1124
+ model?: string;
1125
+
1126
+ /**
1127
+ * Model fallback chain. Each model is in provider/model format. Models are tried
1128
+ * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
1129
+ * single model field. The response.model will reflect the model that actually
1130
+ * succeeded.
1131
+ */
1132
+ models?: Array<string>;
1133
+
1134
+ /**
1135
+ * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
1136
+ * model with system prompt and search parameters. Required if model is not
1137
+ * provided.
1138
+ */
1139
+ preset?: string;
1140
+
1141
+ reasoning?: ResponseCreateParams.Reasoning;
1142
+
1143
+ /**
1144
+ * Specifies the desired output format for the model response
1145
+ */
1146
+ response_format?: Shared.ResponseFormat;
1147
+
1148
+ /**
1149
+ * If true, returns SSE stream instead of JSON
1150
+ */
1151
+ stream?: boolean;
1152
+
1153
+ /**
1154
+ * Tools available to the model
1155
+ */
1156
+ tools?: Array<
1157
+ | ResponseCreateParams.WebSearchTool
1158
+ | ResponseCreateParams.FetchURLTool
1159
+ | ResponseCreateParams.PeopleSearchTool
1160
+ | FunctionTool
1161
+ | ResponseCreateParams.FinanceSearchTool
1162
+ | ResponseCreateParams.SandboxTool
1163
+ >;
1164
+ }
1165
+
1166
+ export namespace ResponseCreateParams {
1167
+ export interface Reasoning {
1168
+ /**
1169
+ * How much effort the model should spend on reasoning
1170
+ */
1171
+ effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
1172
+ }
1173
+
1174
+ export interface WebSearchTool {
1175
+ type: 'web_search';
1176
+
1177
+ filters?: WebSearchTool.Filters;
1178
+
1179
+ max_tokens?: number;
1180
+
1181
+ max_tokens_per_page?: number;
1182
+
1183
+ /**
1184
+ * Search context size (low, medium, high). Omit when supplying explicit max_tokens
1185
+ * / max_tokens_per_page.
1186
+ */
1187
+ search_context_size?: 'low' | 'medium' | 'high';
1188
+
1189
+ /**
1190
+ * User's geographic location for search personalization
1191
+ */
1192
+ user_location?: WebSearchTool.UserLocation;
1193
+ }
1194
+
1195
+ export namespace WebSearchTool {
1196
+ export interface Filters {
1197
+ /**
1198
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
1199
+ */
1200
+ last_updated_after_filter?: string;
1201
+
1202
+ /**
1203
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
1204
+ */
1205
+ last_updated_before_filter?: string;
1206
+
1207
+ /**
1208
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
1209
+ */
1210
+ search_after_date_filter?: string;
1211
+
1212
+ /**
1213
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
1214
+ */
1215
+ search_before_date_filter?: string;
1216
+
1217
+ search_domain_filter?: Array<string>;
1218
+
1219
+ search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
1220
+ }
1221
+
1222
+ /**
1223
+ * User's geographic location for search personalization
1224
+ */
1225
+ export interface UserLocation {
1226
+ city?: string;
1227
+
1228
+ /**
1229
+ * ISO 3166-1 alpha-2 country code
1230
+ */
1231
+ country?: string;
1232
+
1233
+ latitude?: number;
1234
+
1235
+ longitude?: number;
1236
+
1237
+ region?: string;
1238
+ }
1239
+ }
1240
+
1241
+ export interface FetchURLTool {
1242
+ type: 'fetch_url';
1243
+
1244
+ /**
1245
+ * Maximum number of URLs to fetch per tool call
1246
+ */
1247
+ max_urls?: number;
1248
+ }
1249
+
1250
+ export interface PeopleSearchTool {
1251
+ /**
1252
+ * Enables the `people_search` tool.
1253
+ */
1254
+ type: 'people_search';
1255
+ }
1256
+
1257
+ export interface FinanceSearchTool {
1258
+ /**
1259
+ * Enables the `finance_search` tool. The model can request structured financial
1260
+ * data (quotes, financials, segments, earnings transcripts, etc.) via
1261
+ * category-based fan-out to FMP, Finchat, and Quartr.
1262
+ */
1263
+ type: 'finance_search';
1264
+ }
1265
+
1266
+ export interface SandboxTool {
1267
+ /**
1268
+ * Enables the `sandbox` tool. The model can execute code in an isolated container
1269
+ * during the request and use the result in its final answer.
1270
+ */
1271
+ type: 'sandbox';
1272
+ }
1273
+
1274
+ export type ResponseCreateParamsNonStreaming = ResponsesAPI.ResponseCreateParamsNonStreaming;
1275
+ export type ResponseCreateParamsStreaming = ResponsesAPI.ResponseCreateParamsStreaming;
1276
+ }
1277
+
1278
+ export interface ResponseCreateParamsNonStreaming extends ResponseCreateParamsBase {
1279
+ /**
1280
+ * If true, returns SSE stream instead of JSON
1281
+ */
1282
+ stream?: false;
1283
+ }
1284
+
1285
+ export interface ResponseCreateParamsStreaming extends ResponseCreateParamsBase {
1286
+ /**
1287
+ * If true, returns SSE stream instead of JSON
1288
+ */
1289
+ stream: true;
1290
+ }
1291
+
1292
+ Responses.Files = Files;
1293
+
1294
+ export declare namespace Responses {
1295
+ export {
1296
+ type Annotation as Annotation,
1297
+ type ContentPart as ContentPart,
1298
+ type ErrorInfo as ErrorInfo,
1299
+ type FunctionCallOutputItem as FunctionCallOutputItem,
1300
+ type FunctionTool as FunctionTool,
1301
+ type InputItem as InputItem,
1302
+ type OutputItem as OutputItem,
1303
+ type ResponseFile as ResponseFile,
1304
+ type ResponseFileList as ResponseFileList,
1305
+ type ResponseStreamChunk as ResponseStreamChunk,
1306
+ type ResponsesCreateParams as ResponsesCreateParams,
1307
+ type ResponsesUsage as ResponsesUsage,
1308
+ type ResponseCreateResponse as ResponseCreateResponse,
1309
+ type ResponseRetrieveResponse as ResponseRetrieveResponse,
1310
+ type ResponseCreateParams as ResponseCreateParams,
1311
+ type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming,
1312
+ type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
1313
+ };
1314
+
1315
+ export { Files as Files, type FileContentParams as FileContentParams };
1316
+ }