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