openai 5.2.0 → 5.4.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 (118) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/client.d.mts +5 -5
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +5 -5
  5. package/client.d.ts.map +1 -1
  6. package/client.js +26 -23
  7. package/client.js.map +1 -1
  8. package/client.mjs +15 -12
  9. package/client.mjs.map +1 -1
  10. package/core/resource.d.mts +1 -1
  11. package/core/resource.d.mts.map +1 -1
  12. package/core/resource.d.ts +1 -1
  13. package/core/resource.d.ts.map +1 -1
  14. package/core/resource.js.map +1 -1
  15. package/core/resource.mjs.map +1 -1
  16. package/internal/headers.d.mts.map +1 -1
  17. package/internal/headers.d.ts.map +1 -1
  18. package/internal/headers.js +4 -4
  19. package/internal/headers.js.map +1 -1
  20. package/internal/headers.mjs +4 -4
  21. package/internal/headers.mjs.map +1 -1
  22. package/internal/qs/formats.d.mts +1 -0
  23. package/internal/qs/formats.d.mts.map +1 -1
  24. package/internal/qs/formats.d.ts +1 -0
  25. package/internal/qs/formats.d.ts.map +1 -1
  26. package/internal/qs/formats.js +4 -2
  27. package/internal/qs/formats.js.map +1 -1
  28. package/internal/qs/formats.mjs +2 -1
  29. package/internal/qs/formats.mjs.map +1 -1
  30. package/internal/qs/stringify.d.mts.map +1 -1
  31. package/internal/qs/stringify.d.ts.map +1 -1
  32. package/internal/qs/stringify.js +15 -17
  33. package/internal/qs/stringify.js.map +1 -1
  34. package/internal/qs/stringify.mjs +17 -19
  35. package/internal/qs/stringify.mjs.map +1 -1
  36. package/internal/qs/utils.d.mts +1 -0
  37. package/internal/qs/utils.d.mts.map +1 -1
  38. package/internal/qs/utils.d.ts +1 -0
  39. package/internal/qs/utils.d.ts.map +1 -1
  40. package/internal/qs/utils.js +14 -13
  41. package/internal/qs/utils.js.map +1 -1
  42. package/internal/qs/utils.mjs +12 -12
  43. package/internal/qs/utils.mjs.map +1 -1
  44. package/internal/request-options.d.mts +1 -0
  45. package/internal/request-options.d.mts.map +1 -1
  46. package/internal/request-options.d.ts +1 -0
  47. package/internal/request-options.d.ts.map +1 -1
  48. package/internal/request-options.js.map +1 -1
  49. package/internal/request-options.mjs.map +1 -1
  50. package/internal/uploads.js +1 -1
  51. package/internal/uploads.js.map +1 -1
  52. package/internal/uploads.mjs +1 -1
  53. package/internal/uploads.mjs.map +1 -1
  54. package/internal/utils/log.js +1 -1
  55. package/internal/utils/log.js.map +1 -1
  56. package/internal/utils/log.mjs +1 -1
  57. package/internal/utils/log.mjs.map +1 -1
  58. package/internal/utils/path.d.mts.map +1 -1
  59. package/internal/utils/path.d.ts.map +1 -1
  60. package/internal/utils/path.js.map +1 -1
  61. package/internal/utils/path.mjs +1 -1
  62. package/internal/utils/path.mjs.map +1 -1
  63. package/internal/utils/values.d.mts +2 -0
  64. package/internal/utils/values.d.mts.map +1 -1
  65. package/internal/utils/values.d.ts +2 -0
  66. package/internal/utils/values.d.ts.map +1 -1
  67. package/internal/utils/values.js +4 -1
  68. package/internal/utils/values.js.map +1 -1
  69. package/internal/utils/values.mjs +2 -0
  70. package/internal/utils/values.mjs.map +1 -1
  71. package/package.json +1 -1
  72. package/resources/chat/completions/completions.d.mts +3 -3
  73. package/resources/chat/completions/completions.d.mts.map +1 -1
  74. package/resources/chat/completions/completions.d.ts +3 -3
  75. package/resources/chat/completions/completions.d.ts.map +1 -1
  76. package/resources/fine-tuning/jobs/jobs.d.mts +6 -4
  77. package/resources/fine-tuning/jobs/jobs.d.mts.map +1 -1
  78. package/resources/fine-tuning/jobs/jobs.d.ts +6 -4
  79. package/resources/fine-tuning/jobs/jobs.d.ts.map +1 -1
  80. package/resources/fine-tuning/jobs/jobs.js +2 -2
  81. package/resources/fine-tuning/jobs/jobs.js.map +1 -1
  82. package/resources/fine-tuning/jobs/jobs.mjs +2 -2
  83. package/resources/fine-tuning/jobs/jobs.mjs.map +1 -1
  84. package/resources/images.d.mts +12 -0
  85. package/resources/images.d.mts.map +1 -1
  86. package/resources/images.d.ts +12 -0
  87. package/resources/images.d.ts.map +1 -1
  88. package/resources/responses/responses.d.mts +36 -8
  89. package/resources/responses/responses.d.mts.map +1 -1
  90. package/resources/responses/responses.d.ts +36 -8
  91. package/resources/responses/responses.d.ts.map +1 -1
  92. package/resources/responses/responses.js.map +1 -1
  93. package/resources/responses/responses.mjs.map +1 -1
  94. package/resources/shared.d.mts +2 -2
  95. package/resources/shared.d.mts.map +1 -1
  96. package/resources/shared.d.ts +2 -2
  97. package/resources/shared.d.ts.map +1 -1
  98. package/src/client.ts +29 -12
  99. package/src/core/resource.ts +1 -1
  100. package/src/internal/headers.ts +5 -5
  101. package/src/internal/qs/formats.ts +2 -1
  102. package/src/internal/qs/stringify.ts +17 -20
  103. package/src/internal/qs/utils.ts +14 -14
  104. package/src/internal/request-options.ts +1 -0
  105. package/src/internal/uploads.ts +1 -1
  106. package/src/internal/utils/log.ts +1 -1
  107. package/src/internal/utils/path.ts +1 -1
  108. package/src/internal/utils/values.ts +3 -0
  109. package/src/resources/chat/completions/completions.ts +3 -3
  110. package/src/resources/fine-tuning/jobs/jobs.ts +6 -4
  111. package/src/resources/images.ts +14 -0
  112. package/src/resources/responses/responses.ts +41 -7
  113. package/src/resources/shared.ts +4 -0
  114. package/src/version.ts +1 -1
  115. package/version.d.mts +1 -1
  116. package/version.d.ts +1 -1
  117. package/version.js +1 -1
  118. package/version.mjs +1 -1
@@ -1,10 +1,13 @@
1
1
  import { RFC1738 } from './formats';
2
2
  import type { DefaultEncoder, Format } from './types';
3
+ import { isArray } from '../utils/values';
3
4
 
4
- const has = Object.prototype.hasOwnProperty;
5
- const is_array = Array.isArray;
5
+ export let has = (obj: object, key: PropertyKey): boolean => (
6
+ (has = (Object as any).hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty)),
7
+ has(obj, key)
8
+ );
6
9
 
7
- const hex_table = (() => {
10
+ const hex_table = /* @__PURE__ */ (() => {
8
11
  const array = [];
9
12
  for (let i = 0; i < 256; ++i) {
10
13
  array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
@@ -20,7 +23,7 @@ function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; pro
20
23
 
21
24
  const obj = item.obj[item.prop];
22
25
 
23
- if (is_array(obj)) {
26
+ if (isArray(obj)) {
24
27
  const compacted: unknown[] = [];
25
28
 
26
29
  for (let j = 0; j < obj.length; ++j) {
@@ -56,13 +59,10 @@ export function merge(
56
59
  }
57
60
 
58
61
  if (typeof source !== 'object') {
59
- if (is_array(target)) {
62
+ if (isArray(target)) {
60
63
  target.push(source);
61
64
  } else if (target && typeof target === 'object') {
62
- if (
63
- (options && (options.plainObjects || options.allowPrototypes)) ||
64
- !has.call(Object.prototype, source)
65
- ) {
65
+ if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
66
66
  target[source] = true;
67
67
  }
68
68
  } else {
@@ -77,14 +77,14 @@ export function merge(
77
77
  }
78
78
 
79
79
  let mergeTarget = target;
80
- if (is_array(target) && !is_array(source)) {
80
+ if (isArray(target) && !isArray(source)) {
81
81
  // @ts-ignore
82
82
  mergeTarget = array_to_object(target, options);
83
83
  }
84
84
 
85
- if (is_array(target) && is_array(source)) {
85
+ if (isArray(target) && isArray(source)) {
86
86
  source.forEach(function (item, i) {
87
- if (has.call(target, i)) {
87
+ if (has(target, i)) {
88
88
  const targetItem = target[i];
89
89
  if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
90
90
  target[i] = merge(targetItem, item, options);
@@ -101,7 +101,7 @@ export function merge(
101
101
  return Object.keys(source).reduce(function (acc, key) {
102
102
  const value = source[key];
103
103
 
104
- if (has.call(acc, key)) {
104
+ if (has(acc, key)) {
105
105
  acc[key] = merge(acc[key], value, options);
106
106
  } else {
107
107
  acc[key] = value;
@@ -254,7 +254,7 @@ export function combine(a: any, b: any) {
254
254
  }
255
255
 
256
256
  export function maybe_map<T>(val: T[], fn: (v: T) => T) {
257
- if (is_array(val)) {
257
+ if (isArray(val)) {
258
258
  const mapped = [];
259
259
  for (let i = 0; i < val.length; i += 1) {
260
260
  mapped.push(fn(val[i]!));
@@ -21,6 +21,7 @@ export type RequestOptions = {
21
21
  fetchOptions?: MergedRequestInit;
22
22
  signal?: AbortSignal | undefined | null;
23
23
  idempotencyKey?: string;
24
+ defaultBaseURL?: string | undefined;
24
25
 
25
26
  __metadata?: Record<string, unknown>;
26
27
  __binaryResponse?: boolean | undefined;
@@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async (
90
90
  return { ...opts, body: await createForm(opts.body, fetch) };
91
91
  };
92
92
 
93
- const supportsFormDataMap = new WeakMap<Fetch, Promise<boolean>>();
93
+ const supportsFormDataMap = /** @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
94
94
 
95
95
  /**
96
96
  * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending
@@ -58,7 +58,7 @@ const noopLogger = {
58
58
  debug: noop,
59
59
  };
60
60
 
61
- let cachedLoggers = new WeakMap<Logger, [LogLevel, Logger]>();
61
+ let cachedLoggers = /** @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
62
62
 
63
63
  export function loggerFor(client: OpenAI): Logger {
64
64
  const logger = client.logger;
@@ -60,4 +60,4 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
60
60
  /**
61
61
  * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
62
62
  */
63
- export const path = createPathTagFunction(encodeURIPath);
63
+ export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
@@ -9,6 +9,9 @@ export const isAbsoluteURL = (url: string): boolean => {
9
9
  return startsWithSchemeRegexp.test(url);
10
10
  };
11
11
 
12
+ export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val));
13
+ export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[];
14
+
12
15
  /** Returns an object if the given value isn't an object, otherwise returns as-is */
13
16
  export function maybeObj(x: unknown): object {
14
17
  if (typeof x !== 'object') {
@@ -291,7 +291,7 @@ export interface ChatCompletion {
291
291
  * When this parameter is set, the response body will include the `service_tier`
292
292
  * utilized.
293
293
  */
294
- service_tier?: 'auto' | 'default' | 'flex' | null;
294
+ service_tier?: 'auto' | 'default' | 'flex' | 'scale' | null;
295
295
 
296
296
  /**
297
297
  * This fingerprint represents the backend configuration that the model runs with.
@@ -542,7 +542,7 @@ export interface ChatCompletionChunk {
542
542
  * When this parameter is set, the response body will include the `service_tier`
543
543
  * utilized.
544
544
  */
545
- service_tier?: 'auto' | 'default' | 'flex' | null;
545
+ service_tier?: 'auto' | 'default' | 'flex' | 'scale' | null;
546
546
 
547
547
  /**
548
548
  * This fingerprint represents the backend configuration that the model runs with.
@@ -1464,7 +1464,7 @@ export interface ChatCompletionCreateParamsBase {
1464
1464
  * When this parameter is set, the response body will include the `service_tier`
1465
1465
  * utilized.
1466
1466
  */
1467
- service_tier?: 'auto' | 'default' | 'flex' | null;
1467
+ service_tier?: 'auto' | 'default' | 'flex' | 'scale' | null;
1468
1468
 
1469
1469
  /**
1470
1470
  * Not supported with latest reasoning models `o3` and `o4-mini`.
@@ -25,7 +25,7 @@ export class Jobs extends APIResource {
25
25
  * Response includes details of the enqueued job including job status and the name
26
26
  * of the fine-tuned models once complete.
27
27
  *
28
- * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
28
+ * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
29
29
  *
30
30
  * @example
31
31
  * ```ts
@@ -42,7 +42,7 @@ export class Jobs extends APIResource {
42
42
  /**
43
43
  * Get info about a fine-tuning job.
44
44
  *
45
- * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
45
+ * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
46
46
  *
47
47
  * @example
48
48
  * ```ts
@@ -449,7 +449,8 @@ export interface JobCreateParams {
449
449
  * [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
450
450
  * format.
451
451
  *
452
- * See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
452
+ * See the
453
+ * [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
453
454
  * for more details.
454
455
  */
455
456
  training_file: string;
@@ -508,7 +509,8 @@ export interface JobCreateParams {
508
509
  * Your dataset must be formatted as a JSONL file. You must upload your file with
509
510
  * the purpose `fine-tune`.
510
511
  *
511
- * See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
512
+ * See the
513
+ * [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
512
514
  * for more details.
513
515
  */
514
516
  validation_file?: string | null;
@@ -237,6 +237,20 @@ export interface ImageEditParams {
237
237
  */
238
238
  n?: number | null;
239
239
 
240
+ /**
241
+ * The compression level (0-100%) for the generated images. This parameter is only
242
+ * supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
243
+ * defaults to 100.
244
+ */
245
+ output_compression?: number | null;
246
+
247
+ /**
248
+ * The format in which the generated images are returned. This parameter is only
249
+ * supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
250
+ * default value is `png`.
251
+ */
252
+ output_format?: 'png' | 'jpeg' | 'webp' | null;
253
+
240
254
  /**
241
255
  * The quality of the image that will be generated. `high`, `medium` and `low` are
242
256
  * only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
@@ -358,14 +358,13 @@ export interface Response {
358
358
  incomplete_details: Response.IncompleteDetails | null;
359
359
 
360
360
  /**
361
- * Inserts a system (or developer) message as the first item in the model's
362
- * context.
361
+ * A system (or developer) message inserted into the model's context.
363
362
  *
364
363
  * When using along with `previous_response_id`, the instructions from a previous
365
364
  * response will not be carried over to the next response. This makes it simple to
366
365
  * swap out system (or developer) messages in new responses.
367
366
  */
368
- instructions: string | null;
367
+ instructions: string | Array<ResponseInputItem> | null;
369
368
 
370
369
  /**
371
370
  * Set of 16 key-value pairs that can be attached to an object. This can be useful
@@ -469,6 +468,12 @@ export interface Response {
469
468
  */
470
469
  previous_response_id?: string | null;
471
470
 
471
+ /**
472
+ * Reference to a prompt template and its variables.
473
+ * [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
474
+ */
475
+ prompt?: ResponsePrompt | null;
476
+
472
477
  /**
473
478
  * **o-series models only**
474
479
  *
@@ -496,7 +501,7 @@ export interface Response {
496
501
  * When this parameter is set, the response body will include the `service_tier`
497
502
  * utilized.
498
503
  */
499
- service_tier?: 'auto' | 'default' | 'flex' | null;
504
+ service_tier?: 'auto' | 'default' | 'flex' | 'scale' | null;
500
505
 
501
506
  /**
502
507
  * The status of the response generation. One of `completed`, `failed`,
@@ -3483,6 +3488,29 @@ export interface ResponseOutputTextAnnotationAddedEvent {
3483
3488
  type: 'response.output_text_annotation.added';
3484
3489
  }
3485
3490
 
3491
+ /**
3492
+ * Reference to a prompt template and its variables.
3493
+ * [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
3494
+ */
3495
+ export interface ResponsePrompt {
3496
+ /**
3497
+ * The unique identifier of the prompt template to use.
3498
+ */
3499
+ id: string;
3500
+
3501
+ /**
3502
+ * Optional map of values to substitute in for variables in your prompt. The
3503
+ * substitution values can either be strings, or other Response input types like
3504
+ * images or files.
3505
+ */
3506
+ variables?: Record<string, string | ResponseInputText | ResponseInputImage | ResponseInputFile> | null;
3507
+
3508
+ /**
3509
+ * Optional version of the prompt template.
3510
+ */
3511
+ version?: string | null;
3512
+ }
3513
+
3486
3514
  /**
3487
3515
  * Emitted when a response is queued and waiting to be processed.
3488
3516
  */
@@ -4612,8 +4640,7 @@ export interface ResponseCreateParamsBase {
4612
4640
  include?: Array<ResponseIncludable> | null;
4613
4641
 
4614
4642
  /**
4615
- * Inserts a system (or developer) message as the first item in the model's
4616
- * context.
4643
+ * A system (or developer) message inserted into the model's context.
4617
4644
  *
4618
4645
  * When using along with `previous_response_id`, the instructions from a previous
4619
4646
  * response will not be carried over to the next response. This makes it simple to
@@ -4650,6 +4677,12 @@ export interface ResponseCreateParamsBase {
4650
4677
  */
4651
4678
  previous_response_id?: string | null;
4652
4679
 
4680
+ /**
4681
+ * Reference to a prompt template and its variables.
4682
+ * [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
4683
+ */
4684
+ prompt?: ResponsePrompt | null;
4685
+
4653
4686
  /**
4654
4687
  * **o-series models only**
4655
4688
  *
@@ -4677,7 +4710,7 @@ export interface ResponseCreateParamsBase {
4677
4710
  * When this parameter is set, the response body will include the `service_tier`
4678
4711
  * utilized.
4679
4712
  */
4680
- service_tier?: 'auto' | 'default' | 'flex' | null;
4713
+ service_tier?: 'auto' | 'default' | 'flex' | 'scale' | null;
4681
4714
 
4682
4715
  /**
4683
4716
  * Whether to store the generated model response for later retrieval via API.
@@ -4922,6 +4955,7 @@ export declare namespace Responses {
4922
4955
  type ResponseOutputRefusal as ResponseOutputRefusal,
4923
4956
  type ResponseOutputText as ResponseOutputText,
4924
4957
  type ResponseOutputTextAnnotationAddedEvent as ResponseOutputTextAnnotationAddedEvent,
4958
+ type ResponsePrompt as ResponsePrompt,
4925
4959
  type ResponseQueuedEvent as ResponseQueuedEvent,
4926
4960
  type ResponseReasoningDeltaEvent as ResponseReasoningDeltaEvent,
4927
4961
  type ResponseReasoningDoneEvent as ResponseReasoningDoneEvent,
@@ -5,6 +5,8 @@ export type AllModels =
5
5
  | ChatModel
6
6
  | 'o1-pro'
7
7
  | 'o1-pro-2025-03-19'
8
+ | 'o3-pro'
9
+ | 'o3-pro-2025-06-10'
8
10
  | 'computer-use-preview'
9
11
  | 'computer-use-preview-2025-03-11';
10
12
 
@@ -297,5 +299,7 @@ export type ResponsesModel =
297
299
  | ChatModel
298
300
  | 'o1-pro'
299
301
  | 'o1-pro-2025-03-19'
302
+ | 'o3-pro'
303
+ | 'o3-pro-2025-06-10'
300
304
  | 'computer-use-preview'
301
305
  | 'computer-use-preview-2025-03-11';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '5.2.0'; // x-release-please-version
1
+ export const VERSION = '5.4.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.2.0";
1
+ export declare const VERSION = "5.4.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.2.0";
1
+ export declare const VERSION = "5.4.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '5.2.0'; // x-release-please-version
4
+ exports.VERSION = '5.4.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '5.2.0'; // x-release-please-version
1
+ export const VERSION = '5.4.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map