openai 7.26.0 → 7.28.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 (170) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/helpers/beta/agents/filesystem.d.mts +17 -0
  3. package/helpers/beta/agents/filesystem.d.mts.map +1 -0
  4. package/helpers/beta/agents/filesystem.d.ts +17 -0
  5. package/helpers/beta/agents/filesystem.d.ts.map +1 -0
  6. package/helpers/beta/agents/filesystem.js +168 -0
  7. package/helpers/beta/agents/filesystem.js.map +1 -0
  8. package/helpers/beta/agents/filesystem.mjs +162 -0
  9. package/helpers/beta/agents/filesystem.mjs.map +1 -0
  10. package/internal/shim-types.d.mts +9 -0
  11. package/internal/shim-types.d.mts.map +1 -1
  12. package/internal/shim-types.d.ts +9 -0
  13. package/internal/shim-types.d.ts.map +1 -1
  14. package/internal/tslib.js +4 -0
  15. package/lib/beta/agents/files.d.mts +33 -0
  16. package/lib/beta/agents/files.d.mts.map +1 -0
  17. package/lib/beta/agents/files.d.ts +33 -0
  18. package/lib/beta/agents/files.d.ts.map +1 -0
  19. package/lib/beta/agents/files.js +93 -0
  20. package/lib/beta/agents/files.js.map +1 -0
  21. package/lib/beta/agents/files.mjs +86 -0
  22. package/lib/beta/agents/files.mjs.map +1 -0
  23. package/lib/beta/agents/pages.d.mts +9 -0
  24. package/lib/beta/agents/pages.d.mts.map +1 -0
  25. package/lib/beta/agents/pages.d.ts +9 -0
  26. package/lib/beta/agents/pages.d.ts.map +1 -0
  27. package/lib/beta/agents/pages.js +32 -0
  28. package/lib/beta/agents/pages.js.map +1 -0
  29. package/lib/beta/agents/pages.mjs +29 -0
  30. package/lib/beta/agents/pages.mjs.map +1 -0
  31. package/lib/beta/agents/parse-result.d.mts +2 -2
  32. package/lib/beta/agents/parse-result.d.ts +2 -2
  33. package/lib/beta/agents/result-artifacts.d.mts +19 -0
  34. package/lib/beta/agents/result-artifacts.d.mts.map +1 -0
  35. package/lib/beta/agents/result-artifacts.d.ts +19 -0
  36. package/lib/beta/agents/result-artifacts.d.ts.map +1 -0
  37. package/lib/beta/agents/result-artifacts.js +67 -0
  38. package/lib/beta/agents/result-artifacts.js.map +1 -0
  39. package/lib/beta/agents/result-artifacts.mjs +63 -0
  40. package/lib/beta/agents/result-artifacts.mjs.map +1 -0
  41. package/package.json +1 -1
  42. package/resources/admin/organization/usage.d.mts +77 -11
  43. package/resources/admin/organization/usage.d.mts.map +1 -1
  44. package/resources/admin/organization/usage.d.ts +77 -11
  45. package/resources/admin/organization/usage.d.ts.map +1 -1
  46. package/resources/audio/audio.d.mts +4 -0
  47. package/resources/audio/audio.d.mts.map +1 -1
  48. package/resources/audio/audio.d.ts +4 -0
  49. package/resources/audio/audio.d.ts.map +1 -1
  50. package/resources/audio/audio.js +4 -0
  51. package/resources/audio/audio.js.map +1 -1
  52. package/resources/audio/audio.mjs +4 -0
  53. package/resources/audio/audio.mjs.map +1 -1
  54. package/resources/audio/index.d.mts +1 -0
  55. package/resources/audio/index.d.mts.map +1 -1
  56. package/resources/audio/index.d.ts +1 -0
  57. package/resources/audio/index.d.ts.map +1 -1
  58. package/resources/audio/index.js +3 -1
  59. package/resources/audio/index.js.map +1 -1
  60. package/resources/audio/index.mjs +1 -0
  61. package/resources/audio/index.mjs.map +1 -1
  62. package/resources/audio/speech.d.mts +2 -0
  63. package/resources/audio/speech.d.mts.map +1 -1
  64. package/resources/audio/speech.d.ts +2 -0
  65. package/resources/audio/speech.d.ts.map +1 -1
  66. package/resources/audio/voices.d.mts +119 -0
  67. package/resources/audio/voices.d.mts.map +1 -0
  68. package/resources/audio/voices.d.ts +119 -0
  69. package/resources/audio/voices.d.ts.map +1 -0
  70. package/resources/audio/voices.js +41 -0
  71. package/resources/audio/voices.js.map +1 -0
  72. package/resources/audio/voices.mjs +37 -0
  73. package/resources/audio/voices.mjs.map +1 -0
  74. package/resources/beta/agents/agents.d.mts +2 -4
  75. package/resources/beta/agents/agents.d.mts.map +1 -1
  76. package/resources/beta/agents/agents.d.ts +2 -4
  77. package/resources/beta/agents/agents.d.ts.map +1 -1
  78. package/resources/beta/agents/agents.js.map +1 -1
  79. package/resources/beta/agents/agents.mjs.map +1 -1
  80. package/resources/beta/agents/environments/files.d.mts +12 -0
  81. package/resources/beta/agents/environments/files.d.mts.map +1 -1
  82. package/resources/beta/agents/environments/files.d.ts +12 -0
  83. package/resources/beta/agents/environments/files.d.ts.map +1 -1
  84. package/resources/beta/agents/environments/files.js +9 -0
  85. package/resources/beta/agents/environments/files.js.map +1 -1
  86. package/resources/beta/agents/environments/files.mjs +9 -0
  87. package/resources/beta/agents/environments/files.mjs.map +1 -1
  88. package/resources/beta/agents/sessions/artifacts.d.mts +4 -0
  89. package/resources/beta/agents/sessions/artifacts.d.mts.map +1 -1
  90. package/resources/beta/agents/sessions/artifacts.d.ts +4 -0
  91. package/resources/beta/agents/sessions/artifacts.d.ts.map +1 -1
  92. package/resources/beta/agents/sessions/artifacts.js +5 -0
  93. package/resources/beta/agents/sessions/artifacts.js.map +1 -1
  94. package/resources/beta/agents/sessions/artifacts.mjs +5 -0
  95. package/resources/beta/agents/sessions/artifacts.mjs.map +1 -1
  96. package/resources/beta/agents/sessions/sessions.d.mts +2 -4
  97. package/resources/beta/agents/sessions/sessions.d.mts.map +1 -1
  98. package/resources/beta/agents/sessions/sessions.d.ts +2 -4
  99. package/resources/beta/agents/sessions/sessions.d.ts.map +1 -1
  100. package/resources/beta/agents/sessions/sessions.js.map +1 -1
  101. package/resources/beta/agents/sessions/sessions.mjs.map +1 -1
  102. package/resources/beta/responses/responses.d.mts +1 -3
  103. package/resources/beta/responses/responses.d.mts.map +1 -1
  104. package/resources/beta/responses/responses.d.ts +1 -3
  105. package/resources/beta/responses/responses.d.ts.map +1 -1
  106. package/resources/beta/responses/responses.js.map +1 -1
  107. package/resources/beta/responses/responses.mjs.map +1 -1
  108. package/resources/chat/completions/completions.d.mts +2 -1
  109. package/resources/chat/completions/completions.d.mts.map +1 -1
  110. package/resources/chat/completions/completions.d.ts +2 -1
  111. package/resources/chat/completions/completions.d.ts.map +1 -1
  112. package/resources/chat/completions/completions.js.map +1 -1
  113. package/resources/chat/completions/completions.mjs.map +1 -1
  114. package/resources/images.d.mts +57 -72
  115. package/resources/images.d.mts.map +1 -1
  116. package/resources/images.d.ts +57 -72
  117. package/resources/images.d.ts.map +1 -1
  118. package/resources/images.js +4 -7
  119. package/resources/images.js.map +1 -1
  120. package/resources/images.mjs +4 -7
  121. package/resources/images.mjs.map +1 -1
  122. package/resources/realtime/realtime.d.mts +6 -4
  123. package/resources/realtime/realtime.d.mts.map +1 -1
  124. package/resources/realtime/realtime.d.ts +6 -4
  125. package/resources/realtime/realtime.d.ts.map +1 -1
  126. package/resources/realtime/realtime.js.map +1 -1
  127. package/resources/realtime/realtime.mjs.map +1 -1
  128. package/resources/responses/responses.d.mts +1 -3
  129. package/resources/responses/responses.d.mts.map +1 -1
  130. package/resources/responses/responses.d.ts +1 -3
  131. package/resources/responses/responses.d.ts.map +1 -1
  132. package/resources/responses/responses.js.map +1 -1
  133. package/resources/responses/responses.mjs.map +1 -1
  134. package/resources/shared.d.mts +64 -0
  135. package/resources/shared.d.mts.map +1 -1
  136. package/resources/shared.d.ts +64 -0
  137. package/resources/shared.d.ts.map +1 -1
  138. package/resources/webhooks/webhooks.d.mts +211 -6
  139. package/resources/webhooks/webhooks.d.mts.map +1 -1
  140. package/resources/webhooks/webhooks.d.ts +211 -6
  141. package/resources/webhooks/webhooks.d.ts.map +1 -1
  142. package/resources/webhooks/webhooks.js.map +1 -1
  143. package/resources/webhooks/webhooks.mjs.map +1 -1
  144. package/src/helpers/beta/agents/filesystem.ts +187 -0
  145. package/src/internal/shim-types.ts +17 -0
  146. package/src/lib/beta/agents/files.ts +119 -0
  147. package/src/lib/beta/agents/pages.ts +32 -0
  148. package/src/lib/beta/agents/result-artifacts.ts +76 -0
  149. package/src/resources/admin/organization/usage.ts +88 -11
  150. package/src/resources/audio/audio.ts +6 -0
  151. package/src/resources/audio/index.ts +1 -0
  152. package/src/resources/audio/speech.ts +2 -0
  153. package/src/resources/audio/voices.ts +152 -0
  154. package/src/resources/beta/agents/agents.ts +2 -4
  155. package/src/resources/beta/agents/environments/files.ts +16 -0
  156. package/src/resources/beta/agents/sessions/artifacts.ts +7 -0
  157. package/src/resources/beta/agents/sessions/sessions.ts +2 -4
  158. package/src/resources/beta/responses/responses.ts +1 -3
  159. package/src/resources/chat/completions/completions.ts +2 -1
  160. package/src/resources/images.ts +58 -73
  161. package/src/resources/realtime/realtime.ts +6 -4
  162. package/src/resources/responses/responses.ts +1 -3
  163. package/src/resources/shared.ts +64 -0
  164. package/src/resources/webhooks/api.md +5 -0
  165. package/src/resources/webhooks/webhooks.ts +273 -1
  166. package/src/version.ts +1 -1
  167. package/version.d.mts +1 -1
  168. package/version.d.ts +1 -1
  169. package/version.js +1 -1
  170. package/version.mjs +1 -1
@@ -0,0 +1,119 @@
1
+ import type { OpenAI } from '../../../client';
2
+ import { OpenAIError } from '../../../core/error';
3
+ import { buildHeaders } from '../../../internal/headers';
4
+ import type { RequestOptions } from '../../../internal/request-options';
5
+ import type { Uploadable } from '../../../internal/uploads';
6
+ import type { FileObject } from '../../../resources/files';
7
+ import type {
8
+ EnvironmentFile,
9
+ FileCreateParams,
10
+ Files,
11
+ } from '../../../resources/beta/agents/environments/files';
12
+
13
+ /** Beta: file references ready for a hosted environment, plus caller-owned uploads. */
14
+ export interface PreparedAgentFiles {
15
+ files: Extract<FileCreateParams, { type: 'file_id' }>[];
16
+ uploadedFiles: FileObject[];
17
+ }
18
+
19
+ /** Beta: uploaded file IDs remain available after partial preparation or staging failure. */
20
+ export class AgentFileUploadError extends OpenAIError {
21
+ override readonly name = 'AgentFileUploadError';
22
+ declare readonly cause: unknown;
23
+ readonly uploadedFiles: FileObject[];
24
+ constructor(uploadedFiles: FileObject[], cause: unknown) {
25
+ super('Agent file preparation or staging failed; uploaded files remain caller-owned.');
26
+ this.uploadedFiles = uploadedFiles;
27
+ Object.defineProperty(this, 'cause', { value: cause, configurable: true });
28
+ }
29
+ }
30
+
31
+ /** @internal */
32
+ export function validateAgentFilePath(path: string): void {
33
+ const parts = path.split('/');
34
+ const root = parts[2] ?? '';
35
+ if (
36
+ !path.startsWith('/workspace/') ||
37
+ path.includes('\\') ||
38
+ path.includes('\0') ||
39
+ parts.slice(1).some((part) => part === '' || part === '.' || part === '..') ||
40
+ root === '.codex' ||
41
+ root === '.managed-agents' ||
42
+ root.startsWith('.managed-agents-') ||
43
+ path === '/workspace/outputs'
44
+ ) {
45
+ throw new OpenAIError('Agent files require a non-reserved absolute file path inside /workspace');
46
+ }
47
+ }
48
+
49
+ function preflight(files: Record<string, Uploadable>, options: RequestOptions): [string, Uploadable][] {
50
+ const entries = Object.entries(files);
51
+ const headers = buildHeaders([options.headers]);
52
+ if (
53
+ entries.length > 1 &&
54
+ (headers.values.has('idempotency-key') ||
55
+ (!headers.nulls.has('idempotency-key') && options?.idempotencyKey !== undefined))
56
+ ) {
57
+ throw new OpenAIError('Do not reuse an Idempotency-Key across multiple file uploads');
58
+ }
59
+ const paths = new Set(entries.map(([path]) => path));
60
+ for (const [path] of entries) {
61
+ validateAgentFilePath(path);
62
+ for (let slash = path.lastIndexOf('/'); slash > 0; slash = path.lastIndexOf('/', slash - 1)) {
63
+ if (paths.has(path.slice(0, slash))) {
64
+ throw new OpenAIError('Agent file destinations conflict');
65
+ }
66
+ }
67
+ }
68
+ return entries;
69
+ }
70
+
71
+ /** @internal */
72
+ export async function prepareAgentFiles(
73
+ client: OpenAI,
74
+ files: Record<string, Uploadable>,
75
+ options?: RequestOptions,
76
+ ): Promise<PreparedAgentFiles> {
77
+ const requestOptions = { ...options };
78
+ // Internal SDK read: capture effective headers once, including defaults and explicit omissions.
79
+ const headers = buildHeaders([client['_options'].defaultHeaders, requestOptions.headers]);
80
+ requestOptions.headers = headers;
81
+ const entries = preflight(files, requestOptions);
82
+ if (entries.length > 1) {
83
+ // Keep a later mutation of client defaults from adding one key to this entire batch.
84
+ headers.nulls.add('idempotency-key');
85
+ }
86
+ const prepared: PreparedAgentFiles = { files: [], uploadedFiles: [] };
87
+ try {
88
+ for (const [path, file] of entries) {
89
+ // oxlint-disable-next-line no-await-in-loop -- Stop on the first failure and expose precisely the uploads already created.
90
+ const uploaded = await client.files.create({ file, purpose: 'user_data' }, requestOptions);
91
+ prepared.uploadedFiles.push(uploaded);
92
+ prepared.files.push({ type: 'file_id', file_id: uploaded.id, path });
93
+ }
94
+ return prepared;
95
+ } catch (error) {
96
+ throw new AgentFileUploadError(prepared.uploadedFiles, error);
97
+ }
98
+ }
99
+
100
+ /** @internal */
101
+ export async function uploadAgentFile(
102
+ client: OpenAI,
103
+ resource: Files,
104
+ environmentID: string,
105
+ params: { file: Uploadable; path: string },
106
+ options?: RequestOptions,
107
+ ): Promise<{ uploadedFile: FileObject; environmentFile: EnvironmentFile }> {
108
+ const prepared = await prepareAgentFiles(client, { [params.path]: params.file }, options);
109
+ const [reference] = prepared.files;
110
+ const [uploadedFile] = prepared.uploadedFiles;
111
+ if (!reference || !uploadedFile) {
112
+ throw new OpenAIError('Missing prepared agent file');
113
+ }
114
+ try {
115
+ return { uploadedFile, environmentFile: await resource.create(environmentID, reference, options) };
116
+ } catch (error) {
117
+ throw new AgentFileUploadError(prepared.uploadedFiles, error);
118
+ }
119
+ }
@@ -0,0 +1,32 @@
1
+ import { OpenAIError } from '../../../core/error';
2
+ import type { CursorPage } from '../../../core/pagination';
3
+ import { isObj } from '../../../internal/utils/values';
4
+
5
+ /** Retain server cursor metadata for legacy Agents items with nullable IDs.
6
+ * @internal
7
+ * @yields {T} Each item in server order, failing if pagination cannot advance.
8
+ */
9
+ export async function* agentItems<T extends { id?: string | null }>(
10
+ load: (after: string | undefined) => PromiseLike<CursorPage<T>>,
11
+ ): AsyncGenerator<T, void, undefined> {
12
+ let after: string | undefined;
13
+ while (true) {
14
+ // oxlint-disable-next-line no-await-in-loop -- Each page determines the next cursor.
15
+ const page = await load(after);
16
+ yield* page.data;
17
+ if (!page.has_more) {
18
+ return;
19
+ }
20
+ // Internal SDK read: CursorPage keeps raw metadata but does not expose last_id.
21
+ // oxlint-disable-next-line prefer-destructuring -- Bracket access intentionally reads a protected internal field.
22
+ const body = page['body'];
23
+ // oxlint-disable-next-line unicorn/prefer-at -- Keep published source compatible with ES2020 declarations.
24
+ const last = page.data[page.data.length - 1];
25
+ // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Validate only the opaque cursor from response metadata.
26
+ const cursor = isObj(body) && typeof body['last_id'] === 'string' ? body['last_id'] : last?.id;
27
+ if (!cursor || cursor === after) {
28
+ throw new OpenAIError('Agent pagination cannot advance to the next page');
29
+ }
30
+ after = cursor;
31
+ }
32
+ }
@@ -0,0 +1,76 @@
1
+ import type { WritableStream } from '../../../internal/shim-types';
2
+ import { agentItems } from './pages';
3
+ import { OpenAIError } from '../../../core/error';
4
+ import type { RequestOptions } from '../../../internal/request-options';
5
+ import type { Artifacts, SessionArtifact } from '../../../resources/beta/agents/sessions/artifacts';
6
+ import type { AgentTurnResult } from './agent-turn-result';
7
+
8
+ /** Beta: artifacts from the exact session and turn represented by a result. */
9
+ export class AgentResultArtifacts {
10
+ readonly #resource: Artifacts;
11
+ readonly #sessionID: string;
12
+ readonly #turnID: string;
13
+ constructor(resource: Artifacts, result: AgentTurnResult) {
14
+ this.#resource = resource;
15
+ this.#sessionID = result.session_id;
16
+ this.#turnID = result.turn_id;
17
+ }
18
+
19
+ /** Find one immutable artifact by its exact hosted path, across all pages. */
20
+ async retrieve(path: string, options?: RequestOptions): Promise<SessionArtifact> {
21
+ let selected: SessionArtifact | undefined;
22
+ for await (const artifact of agentItems((after) =>
23
+ this.#resource.list(
24
+ this.#sessionID,
25
+ {},
26
+ { ...options, query: { ...options?.query, after, environment_id: undefined } },
27
+ ),
28
+ )) {
29
+ if (
30
+ artifact.session_id === this.#sessionID &&
31
+ artifact.turn_id === this.#turnID &&
32
+ artifact.path === path
33
+ ) {
34
+ if (selected) {
35
+ throw new OpenAIError('Multiple artifacts match this result and path');
36
+ }
37
+ selected = artifact;
38
+ }
39
+ }
40
+ if (!selected) {
41
+ throw new OpenAIError('No artifact matches this result and path');
42
+ }
43
+ return selected;
44
+ }
45
+
46
+ /** Return the native binary response for this result's exact artifact path. */
47
+ async content(path: string, options?: RequestOptions): Promise<Response> {
48
+ const artifact = await this.retrieve(path, options);
49
+ return this.#resource.content(artifact.id, { session_id: this.#sessionID }, options);
50
+ }
51
+
52
+ /** Stream bytes to a caller-chosen destination; the hosted path never selects a local path. */
53
+ async download(
54
+ params: { path: string; to: WritableStream<Uint8Array> },
55
+ options?: RequestOptions,
56
+ ): Promise<SessionArtifact> {
57
+ const { path, to } = params;
58
+ const artifact = await this.retrieve(path, options);
59
+ const response = await this.#resource.content(artifact.id, { session_id: this.#sessionID }, options);
60
+ if (!response.body) {
61
+ throw new OpenAIError('Artifact response has no content stream');
62
+ }
63
+ try {
64
+ await response.body.pipeTo(to, options?.signal ? { signal: options.signal } : {});
65
+ } catch (error) {
66
+ // pipeTo can reject before acquiring a reader, for example when the destination is locked.
67
+ try {
68
+ await response.body.cancel();
69
+ } catch {
70
+ /* already cancelled or owned by pipeTo */
71
+ }
72
+ throw error;
73
+ }
74
+ return artifact;
75
+ }
76
+ }
@@ -366,7 +366,14 @@ export namespace UsageAudioSpeechesResponse {
366
366
  input_audio_tokens?: number;
367
367
 
368
368
  /**
369
- * The aggregated number of input tokens written to the cache.
369
+ * The aggregated number of input tokens written to the cache with a 12-hour
370
+ * retention period.
371
+ */
372
+ input_cache_write_12h_tokens?: number;
373
+
374
+ /**
375
+ * The aggregated number of input tokens written to the cache with a 30-minute
376
+ * retention period.
370
377
  */
371
378
  input_cache_write_tokens?: number;
372
379
 
@@ -923,7 +930,14 @@ export namespace UsageAudioTranscriptionsResponse {
923
930
  input_audio_tokens?: number;
924
931
 
925
932
  /**
926
- * The aggregated number of input tokens written to the cache.
933
+ * The aggregated number of input tokens written to the cache with a 12-hour
934
+ * retention period.
935
+ */
936
+ input_cache_write_12h_tokens?: number;
937
+
938
+ /**
939
+ * The aggregated number of input tokens written to the cache with a 30-minute
940
+ * retention period.
927
941
  */
928
942
  input_cache_write_tokens?: number;
929
943
 
@@ -1480,7 +1494,14 @@ export namespace UsageCodeInterpreterSessionsResponse {
1480
1494
  input_audio_tokens?: number;
1481
1495
 
1482
1496
  /**
1483
- * The aggregated number of input tokens written to the cache.
1497
+ * The aggregated number of input tokens written to the cache with a 12-hour
1498
+ * retention period.
1499
+ */
1500
+ input_cache_write_12h_tokens?: number;
1501
+
1502
+ /**
1503
+ * The aggregated number of input tokens written to the cache with a 30-minute
1504
+ * retention period.
1484
1505
  */
1485
1506
  input_cache_write_tokens?: number;
1486
1507
 
@@ -2037,7 +2058,14 @@ export namespace UsageCompletionsResponse {
2037
2058
  input_audio_tokens?: number;
2038
2059
 
2039
2060
  /**
2040
- * The aggregated number of input tokens written to the cache.
2061
+ * The aggregated number of input tokens written to the cache with a 12-hour
2062
+ * retention period.
2063
+ */
2064
+ input_cache_write_12h_tokens?: number;
2065
+
2066
+ /**
2067
+ * The aggregated number of input tokens written to the cache with a 30-minute
2068
+ * retention period.
2041
2069
  */
2042
2070
  input_cache_write_tokens?: number;
2043
2071
 
@@ -2594,7 +2622,14 @@ export namespace UsageCostsResponse {
2594
2622
  input_audio_tokens?: number;
2595
2623
 
2596
2624
  /**
2597
- * The aggregated number of input tokens written to the cache.
2625
+ * The aggregated number of input tokens written to the cache with a 12-hour
2626
+ * retention period.
2627
+ */
2628
+ input_cache_write_12h_tokens?: number;
2629
+
2630
+ /**
2631
+ * The aggregated number of input tokens written to the cache with a 30-minute
2632
+ * retention period.
2598
2633
  */
2599
2634
  input_cache_write_tokens?: number;
2600
2635
 
@@ -3151,7 +3186,14 @@ export namespace UsageEmbeddingsResponse {
3151
3186
  input_audio_tokens?: number;
3152
3187
 
3153
3188
  /**
3154
- * The aggregated number of input tokens written to the cache.
3189
+ * The aggregated number of input tokens written to the cache with a 12-hour
3190
+ * retention period.
3191
+ */
3192
+ input_cache_write_12h_tokens?: number;
3193
+
3194
+ /**
3195
+ * The aggregated number of input tokens written to the cache with a 30-minute
3196
+ * retention period.
3155
3197
  */
3156
3198
  input_cache_write_tokens?: number;
3157
3199
 
@@ -3708,7 +3750,14 @@ export namespace UsageFileSearchCallsResponse {
3708
3750
  input_audio_tokens?: number;
3709
3751
 
3710
3752
  /**
3711
- * The aggregated number of input tokens written to the cache.
3753
+ * The aggregated number of input tokens written to the cache with a 12-hour
3754
+ * retention period.
3755
+ */
3756
+ input_cache_write_12h_tokens?: number;
3757
+
3758
+ /**
3759
+ * The aggregated number of input tokens written to the cache with a 30-minute
3760
+ * retention period.
3712
3761
  */
3713
3762
  input_cache_write_tokens?: number;
3714
3763
 
@@ -4265,7 +4314,14 @@ export namespace UsageImagesResponse {
4265
4314
  input_audio_tokens?: number;
4266
4315
 
4267
4316
  /**
4268
- * The aggregated number of input tokens written to the cache.
4317
+ * The aggregated number of input tokens written to the cache with a 12-hour
4318
+ * retention period.
4319
+ */
4320
+ input_cache_write_12h_tokens?: number;
4321
+
4322
+ /**
4323
+ * The aggregated number of input tokens written to the cache with a 30-minute
4324
+ * retention period.
4269
4325
  */
4270
4326
  input_cache_write_tokens?: number;
4271
4327
 
@@ -4822,7 +4878,14 @@ export namespace UsageModerationsResponse {
4822
4878
  input_audio_tokens?: number;
4823
4879
 
4824
4880
  /**
4825
- * The aggregated number of input tokens written to the cache.
4881
+ * The aggregated number of input tokens written to the cache with a 12-hour
4882
+ * retention period.
4883
+ */
4884
+ input_cache_write_12h_tokens?: number;
4885
+
4886
+ /**
4887
+ * The aggregated number of input tokens written to the cache with a 30-minute
4888
+ * retention period.
4826
4889
  */
4827
4890
  input_cache_write_tokens?: number;
4828
4891
 
@@ -5379,7 +5442,14 @@ export namespace UsageVectorStoresResponse {
5379
5442
  input_audio_tokens?: number;
5380
5443
 
5381
5444
  /**
5382
- * The aggregated number of input tokens written to the cache.
5445
+ * The aggregated number of input tokens written to the cache with a 12-hour
5446
+ * retention period.
5447
+ */
5448
+ input_cache_write_12h_tokens?: number;
5449
+
5450
+ /**
5451
+ * The aggregated number of input tokens written to the cache with a 30-minute
5452
+ * retention period.
5383
5453
  */
5384
5454
  input_cache_write_tokens?: number;
5385
5455
 
@@ -5936,7 +6006,14 @@ export namespace UsageWebSearchCallsResponse {
5936
6006
  input_audio_tokens?: number;
5937
6007
 
5938
6008
  /**
5939
- * The aggregated number of input tokens written to the cache.
6009
+ * The aggregated number of input tokens written to the cache with a 12-hour
6010
+ * retention period.
6011
+ */
6012
+ input_cache_write_12h_tokens?: number;
6013
+
6014
+ /**
6015
+ * The aggregated number of input tokens written to the cache with a 30-minute
6016
+ * retention period.
5940
6017
  */
5941
6018
  input_cache_write_tokens?: number;
5942
6019
 
@@ -31,11 +31,14 @@ import {
31
31
  TranslationVerbose,
32
32
  Translations,
33
33
  } from './translations';
34
+ import * as VoicesAPI from './voices';
35
+ import { Voice, VoiceCreateParams, Voices } from './voices';
34
36
 
35
37
  export class Audio extends APIResource {
36
38
  transcriptions: TranscriptionsAPI.Transcriptions = new TranscriptionsAPI.Transcriptions(this._client);
37
39
  translations: TranslationsAPI.Translations = new TranslationsAPI.Translations(this._client);
38
40
  speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
41
+ voices: VoicesAPI.Voices = new VoicesAPI.Voices(this._client);
39
42
  }
40
43
 
41
44
  export type AudioModel =
@@ -58,6 +61,7 @@ export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vt
58
61
  Audio.Transcriptions = Transcriptions;
59
62
  Audio.Translations = Translations;
60
63
  Audio.Speech = Speech;
64
+ Audio.Voices = Voices;
61
65
 
62
66
  export declare namespace Audio {
63
67
  export { type AudioModel as AudioModel, type AudioResponseFormat as AudioResponseFormat };
@@ -91,4 +95,6 @@ export declare namespace Audio {
91
95
  };
92
96
 
93
97
  export { Speech as Speech, type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
98
+
99
+ export { Voices as Voices, type Voice as Voice, type VoiceCreateParams as VoiceCreateParams };
94
100
  }
@@ -28,3 +28,4 @@ export {
28
28
  type TranslationCreateResponse,
29
29
  type TranslationCreateParams,
30
30
  } from './translations';
31
+ export { Voices, type Voice, type VoiceCreateParams } from './voices';
@@ -69,6 +69,8 @@ export interface SpeechCreateParams {
69
69
  * object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the
70
70
  * voices are available in the
71
71
  * [Text to speech guide](https://developers.openai.com/api/docs/guides/text-to-speech#voice-options).
72
+ * Custom voices must be created from audio samples. Voices created from text
73
+ * prompts are supported only in Live.
72
74
  */
73
75
  voice:
74
76
  | string
@@ -0,0 +1,152 @@
1
+ // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { type Uploadable } from '../../core/uploads';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { multipartFormRequestOptions } from '../../internal/uploads';
8
+
9
+ function resolveResourceRequestOptions(
10
+ options: RequestOptions | undefined,
11
+ buildOptions: (options: RequestOptions | undefined) => RequestOptions | Promise<RequestOptions>,
12
+ ): Promise<RequestOptions> {
13
+ return Promise.resolve(options).then(buildOptions);
14
+ }
15
+
16
+ /**
17
+ * Turn audio into text or text into audio.
18
+ */
19
+ export class Voices extends APIResource {
20
+ /**
21
+ * Creates a voice from a text prompt or from a consent recording and an audio
22
+ * sample.
23
+ *
24
+ * For prompt-based creation, send `type: "prompt"` with a `name` and `prompt` as
25
+ * JSON or multipart form data. For creation from an audio sample, send
26
+ * `type: "audio_sample"` with a `name`, `audio_sample`, and `consent` recording ID
27
+ * as multipart form data. The type defaults to `audio_sample` when omitted.
28
+ *
29
+ * Returns the saved voice's metadata. Voices created from text prompts are
30
+ * supported only in Live, not in Realtime or the speech endpoint. The response
31
+ * does not include preview audio.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const voice = await client.audio.voices.create({
36
+ * audio_sample: fs.createReadStream('path/to/file'),
37
+ * consent: 'consent',
38
+ * name: 'x',
39
+ * });
40
+ * ```
41
+ */
42
+ create(body: VoiceCreateParams, options?: RequestOptions): APIPromise<Voice> {
43
+ return this._client.post(
44
+ '/audio/voices',
45
+ resolveResourceRequestOptions(options, (options) =>
46
+ multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client),
47
+ ),
48
+ );
49
+ }
50
+ }
51
+
52
+ /**
53
+ * A custom voice that can be used for audio output. Voices created from text
54
+ * prompts are supported only in Live.
55
+ */
56
+ export interface Voice {
57
+ /**
58
+ * The voice identifier, which can be referenced in API endpoints.
59
+ */
60
+ id: string;
61
+
62
+ /**
63
+ * The Unix timestamp (in seconds) for when the voice was created.
64
+ */
65
+ created_at: number;
66
+
67
+ /**
68
+ * The name of the voice.
69
+ */
70
+ name: string;
71
+
72
+ /**
73
+ * The object type, which is always `audio.voice`.
74
+ */
75
+ object: 'audio.voice';
76
+
77
+ /**
78
+ * How the voice was created. Voices created from text prompts are supported only
79
+ * in Live.
80
+ */
81
+ type: 'audio_sample' | 'prompt';
82
+ }
83
+
84
+ export type VoiceCreateParams = VoiceCreateParams.Consent | VoiceCreateParams.Prompt;
85
+
86
+ export declare namespace VoiceCreateParams {
87
+ /**
88
+ * Creates a voice from a consent recording and an audio sample. Requires
89
+ * multipart/form-data.
90
+ */
91
+ export interface Consent {
92
+ /**
93
+ * The sample audio recording file. Maximum size is 10 MiB.
94
+ *
95
+ * Supported MIME types: `audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`,
96
+ * `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.
97
+ */
98
+ audio_sample: Uploadable;
99
+
100
+ /**
101
+ * The consent recording ID (for example, `cons_1234`).
102
+ */
103
+ consent: string;
104
+
105
+ /**
106
+ * The name of the new voice.
107
+ */
108
+ name: string;
109
+
110
+ /**
111
+ * The voice creation method. Defaults to `audio_sample` when omitted.
112
+ */
113
+ type?: 'audio_sample';
114
+ }
115
+
116
+ /**
117
+ * Creates a synthetic voice from a text description. Supports application/json or
118
+ * multipart/form-data.
119
+ */
120
+ export interface Prompt {
121
+ /**
122
+ * The name of the new voice.
123
+ */
124
+ name: string;
125
+
126
+ /**
127
+ * A description of the desired voice. Must not contain only whitespace.
128
+ */
129
+ prompt: string;
130
+
131
+ /**
132
+ * Set to `prompt` to create a voice from a text description.
133
+ */
134
+ type: 'prompt';
135
+
136
+ /**
137
+ * The voice creation model to use. Defaults to `auto`.
138
+ */
139
+ model?: string | 'auto' | '2026-10-01';
140
+
141
+ /**
142
+ * Optional text for the voice to speak during creation. If omitted, a script is
143
+ * generated from the prompt. Must not be blank after trimming whitespace; scripts
144
+ * that are too short are rejected.
145
+ */
146
+ script_hint?: string;
147
+ }
148
+ }
149
+
150
+ export declare namespace Voices {
151
+ export { type Voice as Voice, type VoiceCreateParams as VoiceCreateParams };
152
+ }
@@ -5372,9 +5372,8 @@ export interface AgentCreateParams {
5372
5372
  * - `flex` - Uses the flex service tier.
5373
5373
  * - `priority` - Uses the priority service tier.
5374
5374
  * - `fast` - Uses the fast service tier.
5375
- * - `ultrafast` - Uses the ultrafast service tier.
5376
5375
  */
5377
- service_tier?: 'auto' | 'default' | 'flex' | 'priority' | 'fast' | 'ultrafast' | null;
5376
+ service_tier?: 'auto' | 'default' | 'flex' | 'priority' | 'fast' | null;
5378
5377
 
5379
5378
  /**
5380
5379
  * Configuration for generated text. Defaults to the `text` format and medium
@@ -5431,9 +5430,8 @@ export interface AgentUpdateParams {
5431
5430
  * - `flex` - Uses the flex service tier.
5432
5431
  * - `priority` - Uses the priority service tier.
5433
5432
  * - `fast` - Uses the fast service tier.
5434
- * - `ultrafast` - Uses the ultrafast service tier.
5435
5433
  */
5436
- service_tier?: 'auto' | 'default' | 'flex' | 'priority' | 'fast' | 'ultrafast' | null;
5434
+ service_tier?: 'auto' | 'default' | 'flex' | 'priority' | 'fast' | null;
5437
5435
 
5438
5436
  /**
5439
5437
  * Configuration for text generated by the agent.
@@ -1,5 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
2
 
3
+ import {
4
+ prepareAgentFiles,
5
+ uploadAgentFile,
6
+ type PreparedAgentFiles,
7
+ } from '../../../../lib/beta/agents/files';
8
+ import type { Uploadable } from '../../../../internal/uploads';
3
9
  import { APIResource } from '../../../../core/resource';
4
10
  import { APIPromise } from '../../../../core/api-promise';
5
11
  import { PagePromise, TokenPage, type TokenPageParams } from '../../../../core/pagination';
@@ -15,6 +21,16 @@ function resolveResourceRequestOptions(
15
21
  }
16
22
 
17
23
  export class Files extends APIResource {
24
+ /** Beta: prepare initial hosted file references; uploaded Files API objects remain caller-owned. */
25
+ prepare(files: Record<string, Uploadable>, options?: RequestOptions): Promise<PreparedAgentFiles> {
26
+ return prepareAgentFiles(this._client, files, options);
27
+ }
28
+
29
+ /** Beta: upload one local file and stage its reference in a live environment. */
30
+ upload(environmentID: string, params: { file: Uploadable; path: string }, options?: RequestOptions) {
31
+ return uploadAgentFile(this._client, this, environmentID, params, options);
32
+ }
33
+
18
34
  /**
19
35
  * Copies inline bytes or a Files API file into a connected execution environment.
20
36
  * See
@@ -1,5 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
2
2
 
3
+ import { AgentResultArtifacts } from '../../../../lib/beta/agents/result-artifacts';
4
+ import type { AgentTurnResult } from '../../../../lib/beta/agents/agent-turn-result';
3
5
  import { APIResource } from '../../../../core/resource';
4
6
  import { APIPromise } from '../../../../core/api-promise';
5
7
  import { CursorPage, type CursorPageParams, PagePromise } from '../../../../core/pagination';
@@ -122,6 +124,11 @@ function normalizeRequestOptionsForQuery(
122
124
  }
123
125
 
124
126
  export class Artifacts extends APIResource {
127
+ /** Beta: bind artifact lookup and downloads to a completed result's exact session and turn. */
128
+ forResult(result: AgentTurnResult): AgentResultArtifacts {
129
+ return new AgentResultArtifacts(this, result);
130
+ }
131
+
125
132
  /**
126
133
  * Retrieves immutable metadata for one durable session artifact. See
127
134
  * [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).