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