@perplexity-ai/perplexity_ai 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +21 -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 +10 -2
  7. package/client.js.map +1 -1
  8. package/client.mjs +10 -2
  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 +1096 -0
  36. package/resources/responses/responses.d.mts.map +1 -0
  37. package/resources/responses/responses.d.ts +1096 -0
  38. package/resources/responses/responses.d.ts.map +1 -0
  39. package/resources/responses/responses.js +38 -0
  40. package/resources/responses/responses.js.map +1 -0
  41. package/resources/responses/responses.mjs +33 -0
  42. package/resources/responses/responses.mjs.map +1 -0
  43. package/resources/responses.d.mts +1 -927
  44. package/resources/responses.d.mts.map +1 -1
  45. package/resources/responses.d.ts +1 -927
  46. package/resources/responses.d.ts.map +1 -1
  47. package/resources/responses.js +2 -26
  48. package/resources/responses.js.map +1 -1
  49. package/resources/responses.mjs +1 -24
  50. package/resources/responses.mjs.map +1 -1
  51. package/src/client.ts +18 -6
  52. package/src/resources/index.ts +3 -1
  53. package/src/resources/responses/files.ts +42 -0
  54. package/src/resources/responses/index.ts +23 -0
  55. package/src/resources/responses/responses.ts +1468 -0
  56. package/src/resources/responses.ts +1 -1259
  57. package/src/version.ts +1 -1
  58. package/version.d.mts +1 -1
  59. package/version.d.ts +1 -1
  60. package/version.js +1 -1
  61. package/version.mjs +1 -1
@@ -0,0 +1,1096 @@
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
+ /**
145
+ * One item in the response output: an assistant message, retrieved tool results,
146
+ * or a record of a tool call.
147
+ */
148
+ export type OutputItem = OutputItem.MessageOutputItem | OutputItem.SearchResultsOutputItem | OutputItem.FetchURLResultsOutputItem | FunctionCallOutputItem | OutputItem.McpListToolsOutputItem | OutputItem.McpCallOutputItem;
149
+ export declare namespace OutputItem {
150
+ interface MessageOutputItem {
151
+ id: string;
152
+ content: Array<ResponsesAPI.ContentPart>;
153
+ /**
154
+ * Role in a message
155
+ */
156
+ role: 'assistant';
157
+ /**
158
+ * Status of a response or output item
159
+ */
160
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
161
+ type: 'message';
162
+ }
163
+ interface SearchResultsOutputItem {
164
+ results: Array<Shared.SearchResult>;
165
+ type: 'search_results';
166
+ queries?: Array<string>;
167
+ }
168
+ interface FetchURLResultsOutputItem {
169
+ contents: Array<FetchURLResultsOutputItem.Content>;
170
+ type: 'fetch_url_results';
171
+ }
172
+ namespace FetchURLResultsOutputItem {
173
+ /**
174
+ * Content fetched from a URL
175
+ */
176
+ interface Content {
177
+ /**
178
+ * The fetched content snippet
179
+ */
180
+ snippet: string;
181
+ /**
182
+ * The title of the page
183
+ */
184
+ title: string;
185
+ /**
186
+ * The URL from which content was fetched
187
+ */
188
+ url: string;
189
+ }
190
+ }
191
+ /**
192
+ * Tools discovered on one external MCP server at boot. Matches OpenAI's
193
+ * mcp_list_tools item.
194
+ */
195
+ interface McpListToolsOutputItem {
196
+ id: string;
197
+ server_label: string;
198
+ tools: Array<McpListToolsOutputItem.Tool>;
199
+ type: 'mcp_list_tools';
200
+ error?: string;
201
+ }
202
+ namespace McpListToolsOutputItem {
203
+ /**
204
+ * One tool discovered on a remote MCP server.
205
+ */
206
+ interface Tool {
207
+ /**
208
+ * The server's JSON Schema for the tool, passed through unmodified.
209
+ */
210
+ input_schema: {
211
+ [key: string]: unknown;
212
+ };
213
+ name: string;
214
+ description?: string;
215
+ }
216
+ }
217
+ /**
218
+ * One tool call executed against an external MCP server, modeled on OpenAI's
219
+ * mcp_call item.
220
+ */
221
+ interface McpCallOutputItem {
222
+ id: string;
223
+ /**
224
+ * JSON-encoded arguments the model passed.
225
+ */
226
+ arguments: string;
227
+ name: string;
228
+ server_label: string;
229
+ type: 'mcp_call';
230
+ /**
231
+ * The failure string when the call failed (also returned to the model in-band);
232
+ * null on success, matching OpenAI's mcp_call.
233
+ */
234
+ error?: string | null;
235
+ /**
236
+ * Tool output text; empty when the call failed.
237
+ */
238
+ output?: string;
239
+ }
240
+ }
241
+ /**
242
+ * Metadata for a file shared from a response sandbox via the share_file tool.
243
+ */
244
+ export interface ResponseFile {
245
+ /**
246
+ * File identifier, scoped to the parent response.
247
+ */
248
+ id: string;
249
+ /**
250
+ * Size of the file in bytes.
251
+ */
252
+ bytes: number;
253
+ /**
254
+ * Unix timestamp (seconds) when the file was produced.
255
+ */
256
+ created_at: number;
257
+ /**
258
+ * Original filename set by the share_file tool call.
259
+ */
260
+ filename: string;
261
+ /**
262
+ * Object type. Always `file`.
263
+ */
264
+ object: 'file';
265
+ }
266
+ export interface ResponseFileList {
267
+ data: Array<ResponseFile>;
268
+ /**
269
+ * Object type. Always `list`.
270
+ */
271
+ object: 'list';
272
+ }
273
+ /**
274
+ * SSE stream event. Discriminate by the `type` field:
275
+ *
276
+ * - `response.created`: Initial response object
277
+ * - `response.in_progress`: Response processing started
278
+ * - `response.completed`: Final response with output
279
+ * - `response.failed`: Error occurred
280
+ * - `response.output_item.added`: New output item started
281
+ * - `response.output_item.done`: Output item completed
282
+ * - `response.output_text.delta`: Streaming text delta
283
+ * - `response.output_text.done`: Final text content
284
+ * - `response.reasoning.started`: Reasoning phase started
285
+ * - `response.reasoning.search_queries`: Search queries issued
286
+ * - `response.reasoning.search_results`: Search results received
287
+ * - `response.reasoning.fetch_url_queries`: URL fetch queries issued
288
+ * - `response.reasoning.fetch_url_results`: URL fetch results received
289
+ * - `response.reasoning.stopped`: Reasoning phase complete
290
+ */
291
+ 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;
292
+ export declare namespace ResponseStreamChunk {
293
+ /**
294
+ * Response created event (type: "response.created"). Contains the initial response
295
+ * object.
296
+ */
297
+ interface ResponseCreatedEvent {
298
+ /**
299
+ * Monotonically increasing sequence number for event ordering
300
+ */
301
+ sequence_number: number;
302
+ /**
303
+ * SSE event type discriminator (always "response.created")
304
+ */
305
+ type: 'response.created';
306
+ /**
307
+ * Non-streaming response returned when stream is false
308
+ */
309
+ response?: ResponseCreatedEvent.Response;
310
+ }
311
+ namespace ResponseCreatedEvent {
312
+ /**
313
+ * Non-streaming response returned when stream is false
314
+ */
315
+ interface Response {
316
+ id: string;
317
+ created_at: number;
318
+ model: string;
319
+ /**
320
+ * Object type in API responses
321
+ */
322
+ object: 'response';
323
+ output: Array<ResponsesAPI.OutputItem>;
324
+ /**
325
+ * Status of a response or output item
326
+ */
327
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
328
+ /**
329
+ * Whether the response was created in background mode.
330
+ */
331
+ background?: boolean;
332
+ error?: ResponsesAPI.ErrorInfo;
333
+ usage?: ResponsesAPI.ResponsesUsage;
334
+ }
335
+ }
336
+ /**
337
+ * Response in progress event (type: "response.in_progress"). Emitted when response
338
+ * processing has started.
339
+ */
340
+ interface ResponseInProgressEvent {
341
+ /**
342
+ * Monotonically increasing sequence number for event ordering
343
+ */
344
+ sequence_number: number;
345
+ /**
346
+ * SSE event type discriminator (always "response.in_progress")
347
+ */
348
+ type: 'response.in_progress';
349
+ /**
350
+ * Non-streaming response returned when stream is false
351
+ */
352
+ response?: ResponseInProgressEvent.Response;
353
+ }
354
+ namespace ResponseInProgressEvent {
355
+ /**
356
+ * Non-streaming response returned when stream is false
357
+ */
358
+ interface Response {
359
+ id: string;
360
+ created_at: number;
361
+ model: string;
362
+ /**
363
+ * Object type in API responses
364
+ */
365
+ object: 'response';
366
+ output: Array<ResponsesAPI.OutputItem>;
367
+ /**
368
+ * Status of a response or output item
369
+ */
370
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
371
+ /**
372
+ * Whether the response was created in background mode.
373
+ */
374
+ background?: boolean;
375
+ error?: ResponsesAPI.ErrorInfo;
376
+ usage?: ResponsesAPI.ResponsesUsage;
377
+ }
378
+ }
379
+ /**
380
+ * Response event Contains the full or partial response object.
381
+ */
382
+ interface ResponseCompletedEvent {
383
+ /**
384
+ * Monotonically increasing sequence number for event ordering
385
+ */
386
+ sequence_number: number;
387
+ /**
388
+ * SSE event type discriminator (always "response.completed")
389
+ */
390
+ type: 'response.completed';
391
+ /**
392
+ * Non-streaming response returned when stream is false
393
+ */
394
+ response?: ResponseCompletedEvent.Response;
395
+ }
396
+ namespace ResponseCompletedEvent {
397
+ /**
398
+ * Non-streaming response returned when stream is false
399
+ */
400
+ interface Response {
401
+ id: string;
402
+ created_at: number;
403
+ model: string;
404
+ /**
405
+ * Object type in API responses
406
+ */
407
+ object: 'response';
408
+ output: Array<ResponsesAPI.OutputItem>;
409
+ /**
410
+ * Status of a response or output item
411
+ */
412
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
413
+ /**
414
+ * Whether the response was created in background mode.
415
+ */
416
+ background?: boolean;
417
+ error?: ResponsesAPI.ErrorInfo;
418
+ usage?: ResponsesAPI.ResponsesUsage;
419
+ }
420
+ }
421
+ /**
422
+ * Response failed event (type: "response.failed"). Contains error details when
423
+ * streaming fails.
424
+ */
425
+ interface ResponseFailedEvent {
426
+ error: ResponsesAPI.ErrorInfo;
427
+ /**
428
+ * Monotonically increasing sequence number for event ordering
429
+ */
430
+ sequence_number: number;
431
+ /**
432
+ * SSE event type discriminator (always "response.failed")
433
+ */
434
+ type: 'response.failed';
435
+ }
436
+ /**
437
+ * Output item added event (type: "response.output_item.added"). Emitted when a new
438
+ * output item (message or tool call) starts.
439
+ */
440
+ interface OutputItemAddedEvent {
441
+ /**
442
+ * One item in the response output: an assistant message, retrieved tool results,
443
+ * or a record of a tool call.
444
+ */
445
+ item: ResponsesAPI.OutputItem;
446
+ output_index: number;
447
+ /**
448
+ * Monotonically increasing sequence number for event ordering
449
+ */
450
+ sequence_number: number;
451
+ /**
452
+ * SSE event type discriminator (always "response.output_item.added")
453
+ */
454
+ type: 'response.output_item.added';
455
+ }
456
+ /**
457
+ * Output item done event (type: "response.output_item.done"). Emitted when an
458
+ * output item (message or tool call) completes.
459
+ */
460
+ interface OutputItemDoneEvent {
461
+ /**
462
+ * One item in the response output: an assistant message, retrieved tool results,
463
+ * or a record of a tool call.
464
+ */
465
+ item: ResponsesAPI.OutputItem;
466
+ output_index: number;
467
+ /**
468
+ * Monotonically increasing sequence number for event ordering
469
+ */
470
+ sequence_number: number;
471
+ /**
472
+ * SSE event type discriminator (always "response.output_item.done")
473
+ */
474
+ type: 'response.output_item.done';
475
+ }
476
+ /**
477
+ * Text delta event (type: "response.output_text.delta"). Contains incremental text
478
+ * content.
479
+ */
480
+ interface TextDeltaEvent {
481
+ content_index: number;
482
+ delta: string;
483
+ item_id: string;
484
+ output_index: number;
485
+ /**
486
+ * Monotonically increasing sequence number for event ordering
487
+ */
488
+ sequence_number: number;
489
+ /**
490
+ * SSE event type discriminator (always "response.output_text.delta")
491
+ */
492
+ type: 'response.output_text.delta';
493
+ }
494
+ /**
495
+ * Text done event (type: "response.output_text.done"). Contains the final text
496
+ * content.
497
+ */
498
+ interface TextDoneEvent {
499
+ content_index: number;
500
+ item_id: string;
501
+ output_index: number;
502
+ /**
503
+ * Monotonically increasing sequence number for event ordering
504
+ */
505
+ sequence_number: number;
506
+ text: string;
507
+ /**
508
+ * SSE event type discriminator (always "response.output_text.done")
509
+ */
510
+ type: 'response.output_text.done';
511
+ }
512
+ /**
513
+ * Reasoning started event (type: "response.reasoning.started"). Signals the model
514
+ * has started reasoning/searching.
515
+ */
516
+ interface ReasoningStartedEvent {
517
+ /**
518
+ * Monotonically increasing sequence number for event ordering
519
+ */
520
+ sequence_number: number;
521
+ /**
522
+ * SSE event type discriminator (always "response.reasoning.started")
523
+ */
524
+ type: 'response.reasoning.started';
525
+ thought?: string;
526
+ }
527
+ /**
528
+ * Search queries event (type: "response.reasoning.search_queries"). Contains
529
+ * search queries being executed.
530
+ */
531
+ interface SearchQueriesEvent {
532
+ queries: Array<string>;
533
+ /**
534
+ * Monotonically increasing sequence number for event ordering
535
+ */
536
+ sequence_number: number;
537
+ /**
538
+ * SSE event type discriminator (always "response.reasoning.search_queries")
539
+ */
540
+ type: 'response.reasoning.search_queries';
541
+ thought?: string;
542
+ }
543
+ /**
544
+ * Search results event (type: "response.reasoning.search_results"). Contains
545
+ * search results returned.
546
+ */
547
+ interface SearchResultsEvent {
548
+ results: Array<Shared.SearchResult>;
549
+ /**
550
+ * Monotonically increasing sequence number for event ordering
551
+ */
552
+ sequence_number: number;
553
+ /**
554
+ * SSE event type discriminator (always "response.reasoning.search_results")
555
+ */
556
+ type: 'response.reasoning.search_results';
557
+ thought?: string;
558
+ usage?: ResponsesAPI.ResponsesUsage;
559
+ }
560
+ /**
561
+ * URL fetch queries event (type: "response.reasoning.fetch_url_queries"). Contains
562
+ * URLs being fetched.
563
+ */
564
+ interface FetchURLQueriesEvent {
565
+ /**
566
+ * Monotonically increasing sequence number for event ordering
567
+ */
568
+ sequence_number: number;
569
+ /**
570
+ * SSE event type discriminator (always "response.reasoning.fetch_url_queries")
571
+ */
572
+ type: 'response.reasoning.fetch_url_queries';
573
+ urls: Array<string>;
574
+ thought?: string;
575
+ }
576
+ /**
577
+ * URL fetch results event (type: "response.reasoning.fetch_url_results"). Contains
578
+ * fetched URL contents.
579
+ */
580
+ interface FetchURLResultsEvent {
581
+ contents: Array<FetchURLResultsEvent.Content>;
582
+ /**
583
+ * Monotonically increasing sequence number for event ordering
584
+ */
585
+ sequence_number: number;
586
+ /**
587
+ * SSE event type discriminator (always "response.reasoning.fetch_url_results")
588
+ */
589
+ type: 'response.reasoning.fetch_url_results';
590
+ thought?: string;
591
+ }
592
+ namespace FetchURLResultsEvent {
593
+ /**
594
+ * Content fetched from a URL
595
+ */
596
+ interface Content {
597
+ /**
598
+ * The fetched content snippet
599
+ */
600
+ snippet: string;
601
+ /**
602
+ * The title of the page
603
+ */
604
+ title: string;
605
+ /**
606
+ * The URL from which content was fetched
607
+ */
608
+ url: string;
609
+ }
610
+ }
611
+ /**
612
+ * Reasoning stopped event (type: "response.reasoning.stopped"). Signals the model
613
+ * has finished reasoning/searching.
614
+ */
615
+ interface ReasoningStoppedEvent {
616
+ /**
617
+ * Monotonically increasing sequence number for event ordering
618
+ */
619
+ sequence_number: number;
620
+ /**
621
+ * SSE event type discriminator (always "response.reasoning.stopped")
622
+ */
623
+ type: 'response.reasoning.stopped';
624
+ thought?: string;
625
+ }
626
+ }
627
+ export interface ResponsesCreateParams {
628
+ /**
629
+ * Input content - either a string or array of input items
630
+ */
631
+ input: string | Array<InputItem>;
632
+ /**
633
+ * Run the response asynchronously. When true, the request is queued and the
634
+ * response object's `status` will be `queued` or `in_progress`. Poll GET
635
+ * /v1/responses/{response_id} to retrieve the final result.
636
+ */
637
+ background?: boolean | null;
638
+ /**
639
+ * System instructions for the model
640
+ */
641
+ instructions?: string;
642
+ /**
643
+ * ISO 639-1 language code for response language
644
+ */
645
+ language_preference?: string;
646
+ /**
647
+ * Maximum tokens to generate
648
+ */
649
+ max_output_tokens?: number;
650
+ /**
651
+ * Maximum number of research loop steps. If provided, overrides the preset's
652
+ * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
653
+ */
654
+ max_steps?: number;
655
+ /**
656
+ * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
657
+ * models is also provided, models takes precedence. Required if neither models nor
658
+ * preset is provided.
659
+ */
660
+ model?: string;
661
+ /**
662
+ * Model fallback chain. Each model is in provider/model format. Models are tried
663
+ * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
664
+ * single model field. The response.model will reflect the model that actually
665
+ * succeeded.
666
+ */
667
+ models?: Array<string>;
668
+ /**
669
+ * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
670
+ * model with system prompt and search parameters. Required if model is not
671
+ * provided.
672
+ */
673
+ preset?: string;
674
+ reasoning?: ResponsesCreateParams.Reasoning;
675
+ /**
676
+ * Specifies the desired output format for the model response
677
+ */
678
+ response_format?: Shared.ResponseFormat;
679
+ /**
680
+ * If true, returns SSE stream instead of JSON
681
+ */
682
+ stream?: boolean;
683
+ /**
684
+ * Tools available to the model
685
+ */
686
+ tools?: Array<ResponsesCreateParams.WebSearchTool | ResponsesCreateParams.FetchURLTool | ResponsesCreateParams.PeopleSearchTool | FunctionTool | ResponsesCreateParams.FinanceSearchTool | ResponsesCreateParams.SandboxTool | ResponsesCreateParams.McpTool>;
687
+ }
688
+ export declare namespace ResponsesCreateParams {
689
+ interface Reasoning {
690
+ /**
691
+ * How much effort the model should spend on reasoning
692
+ */
693
+ effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
694
+ }
695
+ interface WebSearchTool {
696
+ type: 'web_search';
697
+ filters?: WebSearchTool.Filters;
698
+ max_tokens?: number;
699
+ max_tokens_per_page?: number;
700
+ /**
701
+ * Search context size (low, medium, high). Omit when supplying explicit max_tokens
702
+ * / max_tokens_per_page.
703
+ */
704
+ search_context_size?: 'low' | 'medium' | 'high';
705
+ /**
706
+ * User's geographic location for search personalization
707
+ */
708
+ user_location?: WebSearchTool.UserLocation;
709
+ }
710
+ namespace WebSearchTool {
711
+ interface Filters {
712
+ /**
713
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
714
+ */
715
+ last_updated_after_filter?: string;
716
+ /**
717
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
718
+ */
719
+ last_updated_before_filter?: string;
720
+ /**
721
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
722
+ */
723
+ search_after_date_filter?: string;
724
+ /**
725
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
726
+ */
727
+ search_before_date_filter?: string;
728
+ search_domain_filter?: Array<string>;
729
+ search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
730
+ }
731
+ /**
732
+ * User's geographic location for search personalization
733
+ */
734
+ interface UserLocation {
735
+ city?: string;
736
+ /**
737
+ * ISO 3166-1 alpha-2 country code
738
+ */
739
+ country?: string;
740
+ latitude?: number;
741
+ longitude?: number;
742
+ region?: string;
743
+ }
744
+ }
745
+ interface FetchURLTool {
746
+ type: 'fetch_url';
747
+ /**
748
+ * Maximum number of URLs to fetch per tool call
749
+ */
750
+ max_urls?: number;
751
+ }
752
+ interface PeopleSearchTool {
753
+ /**
754
+ * Enables the `people_search` tool.
755
+ */
756
+ type: 'people_search';
757
+ }
758
+ interface FinanceSearchTool {
759
+ /**
760
+ * Enables the `finance_search` tool. The model can request structured financial
761
+ * data (quotes, financials, segments, earnings transcripts, etc.) via
762
+ * category-based fan-out to FMP, Finchat, and Quartr.
763
+ */
764
+ type: 'finance_search';
765
+ }
766
+ interface SandboxTool {
767
+ /**
768
+ * Enables the `sandbox` tool. The model can execute code in an isolated container
769
+ * during the request and use the result in its final answer.
770
+ */
771
+ type: 'sandbox';
772
+ }
773
+ /**
774
+ * Connects a user-supplied remote MCP server. The worker discovers the server's
775
+ * tools at boot and calls them like native tools. Matches OpenAI's mcp tool.
776
+ * `require_approval`, `connector_id`, and `defer_loading` are not supported in v1
777
+ * and are ignored if sent: every call auto-runs, and only bring-your-own
778
+ * `server_url` is honored.
779
+ */
780
+ interface McpTool {
781
+ /**
782
+ * Unique per request, ^[a-zA-Z0-9_-]{1,64}$. Namespaces the server's tools.
783
+ */
784
+ server_label: string;
785
+ /**
786
+ * HTTPS URL of the remote MCP server.
787
+ */
788
+ server_url: string;
789
+ type: 'mcp';
790
+ /**
791
+ * Optional allowlist of tool names. Empty exposes all discovered tools.
792
+ */
793
+ allowed_tools?: Array<string>;
794
+ /**
795
+ * An OAuth access token that can be used with a remote MCP server, with a custom
796
+ * MCP server URL. Never logged or echoed.
797
+ */
798
+ authorization?: string;
799
+ /**
800
+ * Extra request headers. Never logged or echoed.
801
+ */
802
+ headers?: {
803
+ [key: string]: string;
804
+ };
805
+ }
806
+ }
807
+ export interface ResponsesUsage {
808
+ input_tokens: number;
809
+ output_tokens: number;
810
+ total_tokens: number;
811
+ cost?: ResponsesUsage.Cost;
812
+ input_tokens_details?: ResponsesUsage.InputTokensDetails;
813
+ tool_calls_details?: {
814
+ [key: string]: ResponsesUsage.ToolCallsDetails;
815
+ };
816
+ }
817
+ export declare namespace ResponsesUsage {
818
+ interface Cost {
819
+ /**
820
+ * Currency code for cost values
821
+ */
822
+ currency: 'USD';
823
+ input_cost: number;
824
+ output_cost: number;
825
+ total_cost: number;
826
+ cache_creation_cost?: number;
827
+ cache_read_cost?: number;
828
+ tool_calls_cost?: number;
829
+ }
830
+ interface InputTokensDetails {
831
+ cache_creation_input_tokens?: number;
832
+ cache_read_input_tokens?: number;
833
+ }
834
+ interface ToolCallsDetails {
835
+ /**
836
+ * Number of times this tool was invoked
837
+ */
838
+ invocation?: number;
839
+ }
840
+ }
841
+ /**
842
+ * Non-streaming response returned when stream is false
843
+ */
844
+ export interface ResponseCreateResponse {
845
+ id: string;
846
+ created_at: number;
847
+ model: string;
848
+ /**
849
+ * Object type in API responses
850
+ */
851
+ object: 'response';
852
+ output: Array<OutputItem>;
853
+ /**
854
+ * Status of a response or output item
855
+ */
856
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
857
+ /**
858
+ * Whether the response was created in background mode.
859
+ */
860
+ background?: boolean;
861
+ error?: ErrorInfo;
862
+ usage?: ResponsesUsage;
863
+ /**
864
+ * Convenience property that aggregates all `output_text` items from the `output` list.
865
+ * If no `output_text` content blocks exist, then an empty string is returned.
866
+ */
867
+ output_text?: string;
868
+ }
869
+ /**
870
+ * Non-streaming response returned when stream is false
871
+ */
872
+ export interface ResponseRetrieveResponse {
873
+ id: string;
874
+ created_at: number;
875
+ model: string;
876
+ /**
877
+ * Object type in API responses
878
+ */
879
+ object: 'response';
880
+ output: Array<OutputItem>;
881
+ /**
882
+ * Status of a response or output item
883
+ */
884
+ status: 'completed' | 'failed' | 'in_progress' | 'queued' | 'cancelled' | 'requires_action';
885
+ /**
886
+ * Whether the response was created in background mode.
887
+ */
888
+ background?: boolean;
889
+ error?: ErrorInfo;
890
+ usage?: ResponsesUsage;
891
+ /**
892
+ * Convenience property that aggregates all `output_text` items from the `output` list.
893
+ * If no `output_text` content blocks exist, then an empty string is returned.
894
+ */
895
+ output_text?: string;
896
+ }
897
+ export type ResponseCreateParams = ResponseCreateParamsNonStreaming | ResponseCreateParamsStreaming;
898
+ export interface ResponseCreateParamsBase {
899
+ /**
900
+ * Input content - either a string or array of input items
901
+ */
902
+ input: string | Array<InputItem>;
903
+ /**
904
+ * Run the response asynchronously. When true, the request is queued and the
905
+ * response object's `status` will be `queued` or `in_progress`. Poll GET
906
+ * /v1/responses/{response_id} to retrieve the final result.
907
+ */
908
+ background?: boolean | null;
909
+ /**
910
+ * System instructions for the model
911
+ */
912
+ instructions?: string;
913
+ /**
914
+ * ISO 639-1 language code for response language
915
+ */
916
+ language_preference?: string;
917
+ /**
918
+ * Maximum tokens to generate
919
+ */
920
+ max_output_tokens?: number;
921
+ /**
922
+ * Maximum number of research loop steps. If provided, overrides the preset's
923
+ * max_steps value. Must be >= 1 if specified. Maximum allowed is 10.
924
+ */
925
+ max_steps?: number;
926
+ /**
927
+ * Model ID in provider/model format (e.g., "xai/grok-4-1", "openai/gpt-4o"). If
928
+ * models is also provided, models takes precedence. Required if neither models nor
929
+ * preset is provided.
930
+ */
931
+ model?: string;
932
+ /**
933
+ * Model fallback chain. Each model is in provider/model format. Models are tried
934
+ * in order until one succeeds. Max 5 models allowed. If set, takes precedence over
935
+ * single model field. The response.model will reflect the model that actually
936
+ * succeeded.
937
+ */
938
+ models?: Array<string>;
939
+ /**
940
+ * Preset configuration name (e.g., "sonar-pro", "sonar-reasoning"). Pre-configured
941
+ * model with system prompt and search parameters. Required if model is not
942
+ * provided.
943
+ */
944
+ preset?: string;
945
+ reasoning?: ResponseCreateParams.Reasoning;
946
+ /**
947
+ * Specifies the desired output format for the model response
948
+ */
949
+ response_format?: Shared.ResponseFormat;
950
+ /**
951
+ * If true, returns SSE stream instead of JSON
952
+ */
953
+ stream?: boolean;
954
+ /**
955
+ * Tools available to the model
956
+ */
957
+ tools?: Array<ResponseCreateParams.WebSearchTool | ResponseCreateParams.FetchURLTool | ResponseCreateParams.PeopleSearchTool | FunctionTool | ResponseCreateParams.FinanceSearchTool | ResponseCreateParams.SandboxTool | ResponseCreateParams.McpTool>;
958
+ }
959
+ export declare namespace ResponseCreateParams {
960
+ interface Reasoning {
961
+ /**
962
+ * How much effort the model should spend on reasoning
963
+ */
964
+ effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
965
+ }
966
+ interface WebSearchTool {
967
+ type: 'web_search';
968
+ filters?: WebSearchTool.Filters;
969
+ max_tokens?: number;
970
+ max_tokens_per_page?: number;
971
+ /**
972
+ * Search context size (low, medium, high). Omit when supplying explicit max_tokens
973
+ * / max_tokens_per_page.
974
+ */
975
+ search_context_size?: 'low' | 'medium' | 'high';
976
+ /**
977
+ * User's geographic location for search personalization
978
+ */
979
+ user_location?: WebSearchTool.UserLocation;
980
+ }
981
+ namespace WebSearchTool {
982
+ interface Filters {
983
+ /**
984
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
985
+ */
986
+ last_updated_after_filter?: string;
987
+ /**
988
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
989
+ */
990
+ last_updated_before_filter?: string;
991
+ /**
992
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
993
+ */
994
+ search_after_date_filter?: string;
995
+ /**
996
+ * Input: MM/DD/YYYY, Output: YYYY-MM-DD
997
+ */
998
+ search_before_date_filter?: string;
999
+ search_domain_filter?: Array<string>;
1000
+ search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year';
1001
+ }
1002
+ /**
1003
+ * User's geographic location for search personalization
1004
+ */
1005
+ interface UserLocation {
1006
+ city?: string;
1007
+ /**
1008
+ * ISO 3166-1 alpha-2 country code
1009
+ */
1010
+ country?: string;
1011
+ latitude?: number;
1012
+ longitude?: number;
1013
+ region?: string;
1014
+ }
1015
+ }
1016
+ interface FetchURLTool {
1017
+ type: 'fetch_url';
1018
+ /**
1019
+ * Maximum number of URLs to fetch per tool call
1020
+ */
1021
+ max_urls?: number;
1022
+ }
1023
+ interface PeopleSearchTool {
1024
+ /**
1025
+ * Enables the `people_search` tool.
1026
+ */
1027
+ type: 'people_search';
1028
+ }
1029
+ interface FinanceSearchTool {
1030
+ /**
1031
+ * Enables the `finance_search` tool. The model can request structured financial
1032
+ * data (quotes, financials, segments, earnings transcripts, etc.) via
1033
+ * category-based fan-out to FMP, Finchat, and Quartr.
1034
+ */
1035
+ type: 'finance_search';
1036
+ }
1037
+ interface SandboxTool {
1038
+ /**
1039
+ * Enables the `sandbox` tool. The model can execute code in an isolated container
1040
+ * during the request and use the result in its final answer.
1041
+ */
1042
+ type: 'sandbox';
1043
+ }
1044
+ /**
1045
+ * Connects a user-supplied remote MCP server. The worker discovers the server's
1046
+ * tools at boot and calls them like native tools. Matches OpenAI's mcp tool.
1047
+ * `require_approval`, `connector_id`, and `defer_loading` are not supported in v1
1048
+ * and are ignored if sent: every call auto-runs, and only bring-your-own
1049
+ * `server_url` is honored.
1050
+ */
1051
+ interface McpTool {
1052
+ /**
1053
+ * Unique per request, ^[a-zA-Z0-9_-]{1,64}$. Namespaces the server's tools.
1054
+ */
1055
+ server_label: string;
1056
+ /**
1057
+ * HTTPS URL of the remote MCP server.
1058
+ */
1059
+ server_url: string;
1060
+ type: 'mcp';
1061
+ /**
1062
+ * Optional allowlist of tool names. Empty exposes all discovered tools.
1063
+ */
1064
+ allowed_tools?: Array<string>;
1065
+ /**
1066
+ * An OAuth access token that can be used with a remote MCP server, with a custom
1067
+ * MCP server URL. Never logged or echoed.
1068
+ */
1069
+ authorization?: string;
1070
+ /**
1071
+ * Extra request headers. Never logged or echoed.
1072
+ */
1073
+ headers?: {
1074
+ [key: string]: string;
1075
+ };
1076
+ }
1077
+ type ResponseCreateParamsNonStreaming = ResponsesAPI.ResponseCreateParamsNonStreaming;
1078
+ type ResponseCreateParamsStreaming = ResponsesAPI.ResponseCreateParamsStreaming;
1079
+ }
1080
+ export interface ResponseCreateParamsNonStreaming extends ResponseCreateParamsBase {
1081
+ /**
1082
+ * If true, returns SSE stream instead of JSON
1083
+ */
1084
+ stream?: false;
1085
+ }
1086
+ export interface ResponseCreateParamsStreaming extends ResponseCreateParamsBase {
1087
+ /**
1088
+ * If true, returns SSE stream instead of JSON
1089
+ */
1090
+ stream: true;
1091
+ }
1092
+ export declare namespace Responses {
1093
+ 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, };
1094
+ export { Files as Files, type FileContentParams as FileContentParams };
1095
+ }
1096
+ //# sourceMappingURL=responses.d.ts.map