@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,918 +1,2 @@
1
- import { APIResource } from "../core/resource.js";
2
- import * as ResponsesAPI from "./responses.js";
3
- import * as Shared from "./shared.js";
4
- import { APIPromise } from "../core/api-promise.js";
5
- import { Stream } from "../core/streaming.js";
6
- import { RequestOptions } from "../internal/request-options.js";
7
- export declare class Responses extends APIResource {
8
- /**
9
- * Generate a response for the provided input with optional web search and
10
- * reasoning.
11
- */
12
- create(body: ResponseCreateParamsNonStreaming, options?: RequestOptions): APIPromise<ResponseCreateResponse>;
13
- create(body: ResponseCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<ResponseStreamChunk>>;
14
- create(body: ResponseCreateParamsBase, options?: RequestOptions): APIPromise<Stream<ResponseStreamChunk> | ResponseCreateResponse>;
15
- /**
16
- * Retrieve a response by its ID. Use this to poll the status of background tasks.
17
- */
18
- retrieve(responseID: string, options?: RequestOptions): APIPromise<ResponseRetrieveResponse>;
19
- }
20
- /**
21
- * Text annotation (e.g., URL citation)
22
- */
23
- export interface Annotation {
24
- end_index?: number;
25
- start_index?: number;
26
- title?: string;
27
- type?: string;
28
- url?: string;
29
- }
30
- export interface ContentPart {
31
- text: string;
32
- /**
33
- * Type of a content part
34
- */
35
- type: 'output_text';
36
- annotations?: Array<Annotation>;
37
- }
38
- export interface ErrorInfo {
39
- message: string;
40
- code?: string;
41
- type?: string;
42
- }
43
- export interface FunctionCallOutputItem {
44
- id: string;
45
- /**
46
- * JSON string of arguments
47
- */
48
- arguments: string;
49
- /**
50
- * Correlates with function_call_output input
51
- */
52
- call_id: string;
53
- name: string;
54
- /**
55
- * Status of a response or output item
56
- */
57
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
58
- type: 'function_call';
59
- /**
60
- * Base64-encoded opaque signature for thinking models
61
- */
62
- thought_signature?: string;
63
- }
64
- export interface FunctionTool {
65
- /**
66
- * The name of the function
67
- */
68
- name: string;
69
- type: 'function';
70
- /**
71
- * A description of what the function does
72
- */
73
- description?: string;
74
- /**
75
- * JSON Schema defining the function's parameters
76
- */
77
- parameters?: {
78
- [key: string]: unknown;
79
- };
80
- /**
81
- * Whether to enable strict schema validation
82
- */
83
- strict?: boolean;
84
- }
85
- export type InputItem = InputItem.InputMessage | InputItem.FunctionCallOutputInput | InputItem.FunctionCallInput;
86
- export declare namespace InputItem {
87
- interface InputMessage {
88
- /**
89
- * Message content - either a string or array of content parts
90
- */
91
- content: string | Array<InputMessage.ContentPartArray>;
92
- role: 'user' | 'assistant' | 'system' | 'developer';
93
- type: 'message';
94
- }
95
- namespace InputMessage {
96
- interface ContentPartArray {
97
- type: 'input_text' | 'input_image';
98
- image_url?: string;
99
- text?: string;
100
- }
101
- }
102
- interface FunctionCallOutputInput {
103
- /**
104
- * The call_id from function_call output
105
- */
106
- call_id: string;
107
- /**
108
- * Function result (JSON string)
109
- */
110
- output: string;
111
- type: 'function_call_output';
112
- /**
113
- * Function name (required by some providers)
114
- */
115
- name?: string;
116
- /**
117
- * Base64-encoded signature from function_call
118
- */
119
- thought_signature?: string;
120
- }
121
- interface FunctionCallInput {
122
- /**
123
- * Function arguments (JSON string)
124
- */
125
- arguments: string;
126
- /**
127
- * The call_id that correlates with function_call_output
128
- */
129
- call_id: string;
130
- /**
131
- * The function name
132
- */
133
- name: string;
134
- type: 'function_call';
135
- /**
136
- * Base64-encoded signature for thinking models
137
- */
138
- thought_signature?: string;
139
- }
140
- }
141
- export type OutputItem = OutputItem.MessageOutputItem | OutputItem.SearchResultsOutputItem | OutputItem.FetchURLResultsOutputItem | FunctionCallOutputItem;
142
- export declare namespace OutputItem {
143
- interface MessageOutputItem {
144
- id: string;
145
- content: Array<ResponsesAPI.ContentPart>;
146
- /**
147
- * Role in a message
148
- */
149
- role: 'assistant';
150
- /**
151
- * Status of a response or output item
152
- */
153
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
154
- type: 'message';
155
- }
156
- interface SearchResultsOutputItem {
157
- results: Array<Shared.SearchResult>;
158
- type: 'search_results';
159
- queries?: Array<string>;
160
- }
161
- interface FetchURLResultsOutputItem {
162
- contents: Array<FetchURLResultsOutputItem.Content>;
163
- type: 'fetch_url_results';
164
- }
165
- namespace FetchURLResultsOutputItem {
166
- /**
167
- * Content fetched from a URL
168
- */
169
- interface Content {
170
- /**
171
- * The fetched content snippet
172
- */
173
- snippet: string;
174
- /**
175
- * The title of the page
176
- */
177
- title: string;
178
- /**
179
- * The URL from which content was fetched
180
- */
181
- url: string;
182
- }
183
- }
184
- }
185
- /**
186
- * SSE stream event. Discriminate by the `type` field:
187
- *
188
- * - `response.created`: Initial response object
189
- * - `response.in_progress`: Response processing started
190
- * - `response.completed`: Final response with output
191
- * - `response.failed`: Error occurred
192
- * - `response.output_item.added`: New output item started
193
- * - `response.output_item.done`: Output item completed
194
- * - `response.output_text.delta`: Streaming text delta
195
- * - `response.output_text.done`: Final text content
196
- * - `response.reasoning.started`: Reasoning phase started
197
- * - `response.reasoning.search_queries`: Search queries issued
198
- * - `response.reasoning.search_results`: Search results received
199
- * - `response.reasoning.fetch_url_queries`: URL fetch queries issued
200
- * - `response.reasoning.fetch_url_results`: URL fetch results received
201
- * - `response.reasoning.stopped`: Reasoning phase complete
202
- */
203
- export type ResponseStreamChunk = ResponseStreamChunk.ResponseCreatedEvent | ResponseStreamChunk.ResponseInProgressEvent | ResponseStreamChunk.ResponseCompletedEvent | ResponseStreamChunk.ResponseFailedEvent | ResponseStreamChunk.OutputItemAddedEvent | ResponseStreamChunk.OutputItemDoneEvent | ResponseStreamChunk.TextDeltaEvent | ResponseStreamChunk.TextDoneEvent | ResponseStreamChunk.ReasoningStartedEvent | ResponseStreamChunk.SearchQueriesEvent | ResponseStreamChunk.SearchResultsEvent | ResponseStreamChunk.FetchURLQueriesEvent | ResponseStreamChunk.FetchURLResultsEvent | ResponseStreamChunk.ReasoningStoppedEvent;
204
- export declare namespace ResponseStreamChunk {
205
- /**
206
- * Response created event (type: "response.created"). Contains the initial response
207
- * object.
208
- */
209
- interface ResponseCreatedEvent {
210
- /**
211
- * Monotonically increasing sequence number for event ordering
212
- */
213
- sequence_number: number;
214
- /**
215
- * SSE event type discriminator (always "response.created")
216
- */
217
- type: 'response.created';
218
- /**
219
- * Non-streaming response returned when stream is false
220
- */
221
- response?: ResponseCreatedEvent.Response;
222
- }
223
- namespace ResponseCreatedEvent {
224
- /**
225
- * Non-streaming response returned when stream is false
226
- */
227
- interface Response {
228
- id: string;
229
- created_at: number;
230
- model: string;
231
- /**
232
- * Object type in API responses
233
- */
234
- object: 'response';
235
- output: Array<ResponsesAPI.OutputItem>;
236
- /**
237
- * Status of a response or output item
238
- */
239
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
240
- /**
241
- * Whether the response was created in background mode.
242
- */
243
- background?: boolean;
244
- error?: ResponsesAPI.ErrorInfo;
245
- usage?: ResponsesAPI.ResponsesUsage;
246
- }
247
- }
248
- /**
249
- * Response in progress event (type: "response.in_progress"). Emitted when response
250
- * processing has started.
251
- */
252
- interface ResponseInProgressEvent {
253
- /**
254
- * Monotonically increasing sequence number for event ordering
255
- */
256
- sequence_number: number;
257
- /**
258
- * SSE event type discriminator (always "response.in_progress")
259
- */
260
- type: 'response.in_progress';
261
- /**
262
- * Non-streaming response returned when stream is false
263
- */
264
- response?: ResponseInProgressEvent.Response;
265
- }
266
- namespace ResponseInProgressEvent {
267
- /**
268
- * Non-streaming response returned when stream is false
269
- */
270
- interface Response {
271
- id: string;
272
- created_at: number;
273
- model: string;
274
- /**
275
- * Object type in API responses
276
- */
277
- object: 'response';
278
- output: Array<ResponsesAPI.OutputItem>;
279
- /**
280
- * Status of a response or output item
281
- */
282
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
283
- /**
284
- * Whether the response was created in background mode.
285
- */
286
- background?: boolean;
287
- error?: ResponsesAPI.ErrorInfo;
288
- usage?: ResponsesAPI.ResponsesUsage;
289
- }
290
- }
291
- /**
292
- * Response event Contains the full or partial response object.
293
- */
294
- interface ResponseCompletedEvent {
295
- /**
296
- * Monotonically increasing sequence number for event ordering
297
- */
298
- sequence_number: number;
299
- /**
300
- * SSE event type discriminator (always "response.completed")
301
- */
302
- type: 'response.completed';
303
- /**
304
- * Non-streaming response returned when stream is false
305
- */
306
- response?: ResponseCompletedEvent.Response;
307
- }
308
- namespace ResponseCompletedEvent {
309
- /**
310
- * Non-streaming response returned when stream is false
311
- */
312
- interface Response {
313
- id: string;
314
- created_at: number;
315
- model: string;
316
- /**
317
- * Object type in API responses
318
- */
319
- object: 'response';
320
- output: Array<ResponsesAPI.OutputItem>;
321
- /**
322
- * Status of a response or output item
323
- */
324
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
325
- /**
326
- * Whether the response was created in background mode.
327
- */
328
- background?: boolean;
329
- error?: ResponsesAPI.ErrorInfo;
330
- usage?: ResponsesAPI.ResponsesUsage;
331
- }
332
- }
333
- /**
334
- * Response failed event (type: "response.failed"). Contains error details when
335
- * streaming fails.
336
- */
337
- interface ResponseFailedEvent {
338
- error: ResponsesAPI.ErrorInfo;
339
- /**
340
- * Monotonically increasing sequence number for event ordering
341
- */
342
- sequence_number: number;
343
- /**
344
- * SSE event type discriminator (always "response.failed")
345
- */
346
- type: 'response.failed';
347
- }
348
- /**
349
- * Output item added event (type: "response.output_item.added"). Emitted when a new
350
- * output item (message or tool call) starts.
351
- */
352
- interface OutputItemAddedEvent {
353
- item: ResponsesAPI.OutputItem;
354
- output_index: number;
355
- /**
356
- * Monotonically increasing sequence number for event ordering
357
- */
358
- sequence_number: number;
359
- /**
360
- * SSE event type discriminator (always "response.output_item.added")
361
- */
362
- type: 'response.output_item.added';
363
- }
364
- /**
365
- * Output item done event (type: "response.output_item.done"). Emitted when an
366
- * output item (message or tool call) completes.
367
- */
368
- interface OutputItemDoneEvent {
369
- item: ResponsesAPI.OutputItem;
370
- output_index: number;
371
- /**
372
- * Monotonically increasing sequence number for event ordering
373
- */
374
- sequence_number: number;
375
- /**
376
- * SSE event type discriminator (always "response.output_item.done")
377
- */
378
- type: 'response.output_item.done';
379
- }
380
- /**
381
- * Text delta event (type: "response.output_text.delta"). Contains incremental text
382
- * content.
383
- */
384
- interface TextDeltaEvent {
385
- content_index: number;
386
- delta: string;
387
- item_id: string;
388
- output_index: number;
389
- /**
390
- * Monotonically increasing sequence number for event ordering
391
- */
392
- sequence_number: number;
393
- /**
394
- * SSE event type discriminator (always "response.output_text.delta")
395
- */
396
- type: 'response.output_text.delta';
397
- }
398
- /**
399
- * Text done event (type: "response.output_text.done"). Contains the final text
400
- * content.
401
- */
402
- interface TextDoneEvent {
403
- content_index: number;
404
- item_id: string;
405
- output_index: number;
406
- /**
407
- * Monotonically increasing sequence number for event ordering
408
- */
409
- sequence_number: number;
410
- text: string;
411
- /**
412
- * SSE event type discriminator (always "response.output_text.done")
413
- */
414
- type: 'response.output_text.done';
415
- }
416
- /**
417
- * Reasoning started event (type: "response.reasoning.started"). Signals the model
418
- * has started reasoning/searching.
419
- */
420
- interface ReasoningStartedEvent {
421
- /**
422
- * Monotonically increasing sequence number for event ordering
423
- */
424
- sequence_number: number;
425
- /**
426
- * SSE event type discriminator (always "response.reasoning.started")
427
- */
428
- type: 'response.reasoning.started';
429
- thought?: string;
430
- }
431
- /**
432
- * Search queries event (type: "response.reasoning.search_queries"). Contains
433
- * search queries being executed.
434
- */
435
- interface SearchQueriesEvent {
436
- queries: Array<string>;
437
- /**
438
- * Monotonically increasing sequence number for event ordering
439
- */
440
- sequence_number: number;
441
- /**
442
- * SSE event type discriminator (always "response.reasoning.search_queries")
443
- */
444
- type: 'response.reasoning.search_queries';
445
- thought?: string;
446
- }
447
- /**
448
- * Search results event (type: "response.reasoning.search_results"). Contains
449
- * search results returned.
450
- */
451
- interface SearchResultsEvent {
452
- results: Array<Shared.SearchResult>;
453
- /**
454
- * Monotonically increasing sequence number for event ordering
455
- */
456
- sequence_number: number;
457
- /**
458
- * SSE event type discriminator (always "response.reasoning.search_results")
459
- */
460
- type: 'response.reasoning.search_results';
461
- thought?: string;
462
- usage?: ResponsesAPI.ResponsesUsage;
463
- }
464
- /**
465
- * URL fetch queries event (type: "response.reasoning.fetch_url_queries"). Contains
466
- * URLs being fetched.
467
- */
468
- interface FetchURLQueriesEvent {
469
- /**
470
- * Monotonically increasing sequence number for event ordering
471
- */
472
- sequence_number: number;
473
- /**
474
- * SSE event type discriminator (always "response.reasoning.fetch_url_queries")
475
- */
476
- type: 'response.reasoning.fetch_url_queries';
477
- urls: Array<string>;
478
- thought?: string;
479
- }
480
- /**
481
- * URL fetch results event (type: "response.reasoning.fetch_url_results"). Contains
482
- * fetched URL contents.
483
- */
484
- interface FetchURLResultsEvent {
485
- contents: Array<FetchURLResultsEvent.Content>;
486
- /**
487
- * Monotonically increasing sequence number for event ordering
488
- */
489
- sequence_number: number;
490
- /**
491
- * SSE event type discriminator (always "response.reasoning.fetch_url_results")
492
- */
493
- type: 'response.reasoning.fetch_url_results';
494
- thought?: string;
495
- }
496
- namespace FetchURLResultsEvent {
497
- /**
498
- * Content fetched from a URL
499
- */
500
- interface Content {
501
- /**
502
- * The fetched content snippet
503
- */
504
- snippet: string;
505
- /**
506
- * The title of the page
507
- */
508
- title: string;
509
- /**
510
- * The URL from which content was fetched
511
- */
512
- url: string;
513
- }
514
- }
515
- /**
516
- * Reasoning stopped event (type: "response.reasoning.stopped"). Signals the model
517
- * has finished reasoning/searching.
518
- */
519
- interface ReasoningStoppedEvent {
520
- /**
521
- * Monotonically increasing sequence number for event ordering
522
- */
523
- sequence_number: number;
524
- /**
525
- * SSE event type discriminator (always "response.reasoning.stopped")
526
- */
527
- type: 'response.reasoning.stopped';
528
- thought?: string;
529
- }
530
- }
531
- export interface ResponsesCreateParams {
532
- /**
533
- * Input content - either a string or array of input items
534
- */
535
- input: string | Array<InputItem>;
536
- /**
537
- * Run the response asynchronously. When true, the request is queued and the
538
- * response object's `status` will be `queued` or `in_progress`. Poll GET
539
- * /v1/responses/{response_id} to retrieve the final result.
540
- */
541
- background?: boolean | null;
542
- /**
543
- * System instructions for the model
544
- */
545
- instructions?: string;
546
- /**
547
- * ISO 639-1 language code for response language
548
- */
549
- language_preference?: string;
550
- /**
551
- * Maximum tokens to generate
552
- */
553
- max_output_tokens?: number;
554
- /**
555
- * Maximum number of research loop steps. If provided, overrides the preset's
556
- * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
557
- */
558
- max_steps?: number;
559
- /**
560
- * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
561
- * models is also provided, models takes precedence. Required if neither models nor
562
- * preset is provided.
563
- */
564
- model?: string;
565
- /**
566
- * Model fallback chain. Each model is in provider/model format. Models are tried
567
- * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
568
- * single model field. The response.model will reflect the model that actually
569
- * succeeded.
570
- */
571
- models?: Array<string>;
572
- /**
573
- * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
574
- * model with system prompt and search parameters. Required if model is not
575
- * provided.
576
- */
577
- preset?: string;
578
- reasoning?: ResponsesCreateParams.Reasoning;
579
- /**
580
- * Specifies the desired output format for the model response
581
- */
582
- response_format?: Shared.ResponseFormat;
583
- /**
584
- * If true, returns SSE stream instead of JSON
585
- */
586
- stream?: boolean;
587
- /**
588
- * Tools available to the model
589
- */
590
- tools?: Array<ResponsesCreateParams.WebSearchTool | ResponsesCreateParams.FetchURLTool | ResponsesCreateParams.PeopleSearchTool | FunctionTool | ResponsesCreateParams.FinanceSearchTool | ResponsesCreateParams.SandboxTool>;
591
- }
592
- export declare namespace ResponsesCreateParams {
593
- interface Reasoning {
594
- /**
595
- * How much effort the model should spend on reasoning
596
- */
597
- effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
598
- }
599
- interface WebSearchTool {
600
- type: 'web_search';
601
- filters?: WebSearchTool.Filters;
602
- max_tokens?: number;
603
- max_tokens_per_page?: number;
604
- /**
605
- * User's geographic location for search personalization
606
- */
607
- user_location?: WebSearchTool.UserLocation;
608
- }
609
- namespace WebSearchTool {
610
- interface Filters {
611
- /**
612
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
613
- */
614
- last_updated_after_filter?: string;
615
- /**
616
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
617
- */
618
- last_updated_before_filter?: string;
619
- /**
620
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
621
- */
622
- search_after_date_filter?: string;
623
- /**
624
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
625
- */
626
- search_before_date_filter?: string;
627
- search_domain_filter?: Array<string>;
628
- search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
629
- }
630
- /**
631
- * User's geographic location for search personalization
632
- */
633
- interface UserLocation {
634
- city?: string;
635
- /**
636
- * ISO 3166-1 alpha-2 country code
637
- */
638
- country?: string;
639
- latitude?: number;
640
- longitude?: number;
641
- region?: string;
642
- }
643
- }
644
- interface FetchURLTool {
645
- type: 'fetch_url';
646
- /**
647
- * Maximum number of URLs to fetch per tool call
648
- */
649
- max_urls?: number;
650
- }
651
- interface PeopleSearchTool {
652
- /**
653
- * Enables the `people_search` tool.
654
- */
655
- type: 'people_search';
656
- }
657
- interface FinanceSearchTool {
658
- /**
659
- * Enables the `finance_search` tool. The model can request structured financial
660
- * data (quotes, financials, segments, earnings transcripts, etc.) via
661
- * category-based fan-out to FMP, Finchat, and Quartr.
662
- */
663
- type: 'finance_search';
664
- }
665
- interface SandboxTool {
666
- /**
667
- * Enables the `sandbox` tool. The model can execute code in an isolated container
668
- * during the request and use the result in its final answer.
669
- */
670
- type: 'sandbox';
671
- }
672
- }
673
- export interface ResponsesUsage {
674
- input_tokens: number;
675
- output_tokens: number;
676
- total_tokens: number;
677
- cost?: ResponsesUsage.Cost;
678
- input_tokens_details?: ResponsesUsage.InputTokensDetails;
679
- tool_calls_details?: {
680
- [key: string]: ResponsesUsage.ToolCallsDetails;
681
- };
682
- }
683
- export declare namespace ResponsesUsage {
684
- interface Cost {
685
- /**
686
- * Currency code for cost values
687
- */
688
- currency: 'USD';
689
- input_cost: number;
690
- output_cost: number;
691
- total_cost: number;
692
- cache_creation_cost?: number;
693
- cache_read_cost?: number;
694
- tool_calls_cost?: number;
695
- }
696
- interface InputTokensDetails {
697
- cache_creation_input_tokens?: number;
698
- cache_read_input_tokens?: number;
699
- }
700
- interface ToolCallsDetails {
701
- /**
702
- * Number of times this tool was invoked
703
- */
704
- invocation?: number;
705
- }
706
- }
707
- /**
708
- * Non-streaming response returned when stream is false
709
- */
710
- export interface ResponseCreateResponse {
711
- id: string;
712
- created_at: number;
713
- model: string;
714
- /**
715
- * Object type in API responses
716
- */
717
- object: 'response';
718
- output: Array<OutputItem>;
719
- /**
720
- * Status of a response or output item
721
- */
722
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
723
- /**
724
- * Whether the response was created in background mode.
725
- */
726
- background?: boolean;
727
- error?: ErrorInfo;
728
- usage?: ResponsesUsage;
729
- }
730
- /**
731
- * Non-streaming response returned when stream is false
732
- */
733
- export interface ResponseRetrieveResponse {
734
- id: string;
735
- created_at: number;
736
- model: string;
737
- /**
738
- * Object type in API responses
739
- */
740
- object: 'response';
741
- output: Array<OutputItem>;
742
- /**
743
- * Status of a response or output item
744
- */
745
- status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
746
- /**
747
- * Whether the response was created in background mode.
748
- */
749
- background?: boolean;
750
- error?: ErrorInfo;
751
- usage?: ResponsesUsage;
752
- /**
753
- * Convenience property that aggregates all `output_text` items from the `output` list.
754
- * If no `output_text` content blocks exist, then an empty string is returned.
755
- */
756
- output_text?: string;
757
- }
758
- export type ResponseCreateParams = ResponseCreateParamsNonStreaming | ResponseCreateParamsStreaming;
759
- export interface ResponseCreateParamsBase {
760
- /**
761
- * Input content - either a string or array of input items
762
- */
763
- input: string | Array<InputItem>;
764
- /**
765
- * Run the response asynchronously. When true, the request is queued and the
766
- * response object's `status` will be `queued` or `in_progress`. Poll GET
767
- * /v1/responses/{response_id} to retrieve the final result.
768
- */
769
- background?: boolean | null;
770
- /**
771
- * System instructions for the model
772
- */
773
- instructions?: string;
774
- /**
775
- * ISO 639-1 language code for response language
776
- */
777
- language_preference?: string;
778
- /**
779
- * Maximum tokens to generate
780
- */
781
- max_output_tokens?: number;
782
- /**
783
- * Maximum number of research loop steps. If provided, overrides the preset's
784
- * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
785
- */
786
- max_steps?: number;
787
- /**
788
- * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
789
- * models is also provided, models takes precedence. Required if neither models nor
790
- * preset is provided.
791
- */
792
- model?: string;
793
- /**
794
- * Model fallback chain. Each model is in provider/model format. Models are tried
795
- * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
796
- * single model field. The response.model will reflect the model that actually
797
- * succeeded.
798
- */
799
- models?: Array<string>;
800
- /**
801
- * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
802
- * model with system prompt and search parameters. Required if model is not
803
- * provided.
804
- */
805
- preset?: string;
806
- reasoning?: ResponseCreateParams.Reasoning;
807
- /**
808
- * Specifies the desired output format for the model response
809
- */
810
- response_format?: Shared.ResponseFormat;
811
- /**
812
- * If true, returns SSE stream instead of JSON
813
- */
814
- stream?: boolean;
815
- /**
816
- * Tools available to the model
817
- */
818
- tools?: Array<ResponseCreateParams.WebSearchTool | ResponseCreateParams.FetchURLTool | ResponseCreateParams.PeopleSearchTool | FunctionTool | ResponseCreateParams.FinanceSearchTool | ResponseCreateParams.SandboxTool>;
819
- }
820
- export declare namespace ResponseCreateParams {
821
- interface Reasoning {
822
- /**
823
- * How much effort the model should spend on reasoning
824
- */
825
- effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
826
- }
827
- interface WebSearchTool {
828
- type: 'web_search';
829
- filters?: WebSearchTool.Filters;
830
- max_tokens?: number;
831
- max_tokens_per_page?: number;
832
- /**
833
- * User's geographic location for search personalization
834
- */
835
- user_location?: WebSearchTool.UserLocation;
836
- }
837
- namespace WebSearchTool {
838
- interface Filters {
839
- /**
840
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
841
- */
842
- last_updated_after_filter?: string;
843
- /**
844
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
845
- */
846
- last_updated_before_filter?: string;
847
- /**
848
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
849
- */
850
- search_after_date_filter?: string;
851
- /**
852
- * Input: MM/DD/YYYY, Output: YYYY-MM-DD
853
- */
854
- search_before_date_filter?: string;
855
- search_domain_filter?: Array<string>;
856
- search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
857
- }
858
- /**
859
- * User's geographic location for search personalization
860
- */
861
- interface UserLocation {
862
- city?: string;
863
- /**
864
- * ISO 3166-1 alpha-2 country code
865
- */
866
- country?: string;
867
- latitude?: number;
868
- longitude?: number;
869
- region?: string;
870
- }
871
- }
872
- interface FetchURLTool {
873
- type: 'fetch_url';
874
- /**
875
- * Maximum number of URLs to fetch per tool call
876
- */
877
- max_urls?: number;
878
- }
879
- interface PeopleSearchTool {
880
- /**
881
- * Enables the `people_search` tool.
882
- */
883
- type: 'people_search';
884
- }
885
- interface FinanceSearchTool {
886
- /**
887
- * Enables the `finance_search` tool. The model can request structured financial
888
- * data (quotes, financials, segments, earnings transcripts, etc.) via
889
- * category-based fan-out to FMP, Finchat, and Quartr.
890
- */
891
- type: 'finance_search';
892
- }
893
- interface SandboxTool {
894
- /**
895
- * Enables the `sandbox` tool. The model can execute code in an isolated container
896
- * during the request and use the result in its final answer.
897
- */
898
- type: 'sandbox';
899
- }
900
- type ResponseCreateParamsNonStreaming = ResponsesAPI.ResponseCreateParamsNonStreaming;
901
- type ResponseCreateParamsStreaming = ResponsesAPI.ResponseCreateParamsStreaming;
902
- }
903
- export interface ResponseCreateParamsNonStreaming extends ResponseCreateParamsBase {
904
- /**
905
- * If true, returns SSE stream instead of JSON
906
- */
907
- stream?: false;
908
- }
909
- export interface ResponseCreateParamsStreaming extends ResponseCreateParamsBase {
910
- /**
911
- * If true, returns SSE stream instead of JSON
912
- */
913
- stream: true;
914
- }
915
- export declare namespace Responses {
916
- export { type Annotation as Annotation, type ContentPart as ContentPart, type ErrorInfo as ErrorInfo, type FunctionCallOutputItem as FunctionCallOutputItem, type FunctionTool as FunctionTool, type InputItem as InputItem, type OutputItem as OutputItem, type ResponseStreamChunk as ResponseStreamChunk, type ResponsesCreateParams as ResponsesCreateParams, type ResponsesUsage as ResponsesUsage, type ResponseCreateResponse as ResponseCreateResponse, type ResponseRetrieveResponse as ResponseRetrieveResponse, type ResponseCreateParams as ResponseCreateParams, type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming, type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming, };
917
- }
1
+ export * from "./responses/index.js";
918
2
  //# sourceMappingURL=responses.d.ts.map