@ai-sdk/openai 4.0.9 → 4.0.11
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.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +330 -76
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +16 -3
- package/dist/internal/index.js +329 -75
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +123 -87
- package/package.json +3 -3
- package/src/chat/convert-openai-chat-usage.ts +5 -2
- package/src/chat/convert-to-openai-chat-messages.ts +114 -7
- package/src/chat/openai-chat-api.ts +2 -0
- package/src/chat/openai-chat-language-model-options.ts +20 -2
- package/src/chat/openai-chat-language-model.ts +1 -0
- package/src/chat/openai-chat-prompt.ts +8 -4
- package/src/openai-language-model-capabilities.ts +2 -1
- package/src/responses/convert-openai-responses-usage.ts +5 -2
- package/src/responses/convert-to-openai-responses-input.ts +123 -6
- package/src/responses/openai-responses-api.ts +77 -11
- package/src/responses/openai-responses-language-model-options.ts +40 -7
- package/src/responses/openai-responses-language-model.ts +37 -1
- package/src/responses/openai-responses-provider-metadata.ts +1 -0
|
@@ -66,6 +66,10 @@ export type OpenAIChatModelId =
|
|
|
66
66
|
| 'gpt-5.4-pro-2026-03-05'
|
|
67
67
|
| 'gpt-5.5'
|
|
68
68
|
| 'gpt-5.5-2026-04-23'
|
|
69
|
+
| 'gpt-5.6'
|
|
70
|
+
| 'gpt-5.6-luna'
|
|
71
|
+
| 'gpt-5.6-sol'
|
|
72
|
+
| 'gpt-5.6-terra'
|
|
69
73
|
| (string & {});
|
|
70
74
|
|
|
71
75
|
export const openaiLanguageModelChatOptions = lazySchema(() =>
|
|
@@ -105,7 +109,7 @@ export const openaiLanguageModelChatOptions = lazySchema(() =>
|
|
|
105
109
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
106
110
|
*/
|
|
107
111
|
reasoningEffort: z
|
|
108
|
-
.enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh'])
|
|
112
|
+
.enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'])
|
|
109
113
|
.optional(),
|
|
110
114
|
|
|
111
115
|
/**
|
|
@@ -159,11 +163,25 @@ export const openaiLanguageModelChatOptions = lazySchema(() =>
|
|
|
159
163
|
*/
|
|
160
164
|
promptCacheKey: z.string().optional(),
|
|
161
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
168
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
169
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
170
|
+
*/
|
|
171
|
+
promptCacheOptions: z
|
|
172
|
+
.object({
|
|
173
|
+
mode: z.enum(['implicit', 'explicit']).optional(),
|
|
174
|
+
ttl: z.literal('30m').optional(),
|
|
175
|
+
})
|
|
176
|
+
.optional(),
|
|
177
|
+
|
|
162
178
|
/**
|
|
163
179
|
* The retention policy for the prompt cache.
|
|
164
180
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
165
181
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
166
|
-
*
|
|
182
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
183
|
+
*
|
|
184
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
167
185
|
*
|
|
168
186
|
* @default 'in_memory'
|
|
169
187
|
*/
|
|
@@ -196,6 +196,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
|
|
|
196
196
|
reasoning_effort: resolvedReasoningEffort,
|
|
197
197
|
service_tier: openaiOptions.serviceTier,
|
|
198
198
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
199
|
+
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
199
200
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
200
201
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
201
202
|
|
|
@@ -9,12 +9,12 @@ export type ChatCompletionMessage =
|
|
|
9
9
|
|
|
10
10
|
export interface ChatCompletionSystemMessage {
|
|
11
11
|
role: 'system';
|
|
12
|
-
content: string
|
|
12
|
+
content: string | Array<ChatCompletionContentPartText>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface ChatCompletionDeveloperMessage {
|
|
16
16
|
role: 'developer';
|
|
17
|
-
content: string
|
|
17
|
+
content: string | Array<ChatCompletionContentPartText>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface ChatCompletionUserMessage {
|
|
@@ -31,26 +31,30 @@ export type ChatCompletionContentPart =
|
|
|
31
31
|
export interface ChatCompletionContentPartText {
|
|
32
32
|
type: 'text';
|
|
33
33
|
text: string;
|
|
34
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export interface ChatCompletionContentPartImage {
|
|
37
38
|
type: 'image_url';
|
|
38
39
|
image_url: { url: string };
|
|
40
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export interface ChatCompletionContentPartInputAudio {
|
|
42
44
|
type: 'input_audio';
|
|
43
45
|
input_audio: { data: string; format: 'wav' | 'mp3' };
|
|
46
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export interface ChatCompletionContentPartFile {
|
|
47
50
|
type: 'file';
|
|
48
51
|
file: { filename: string; file_data: string } | { file_id: string };
|
|
52
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
export interface ChatCompletionAssistantMessage {
|
|
52
56
|
role: 'assistant';
|
|
53
|
-
content?: string | null
|
|
57
|
+
content?: string | null | Array<ChatCompletionContentPartText>;
|
|
54
58
|
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -65,6 +69,6 @@ export interface ChatCompletionMessageToolCall {
|
|
|
65
69
|
|
|
66
70
|
export interface ChatCompletionToolMessage {
|
|
67
71
|
role: 'tool';
|
|
68
|
-
content: string
|
|
72
|
+
content: string | Array<ChatCompletionContentPartText>;
|
|
69
73
|
tool_call_id: string;
|
|
70
74
|
}
|
|
@@ -42,7 +42,8 @@ export function getOpenAILanguageModelCapabilities(
|
|
|
42
42
|
modelId.startsWith('gpt-5.2') ||
|
|
43
43
|
modelId.startsWith('gpt-5.3') ||
|
|
44
44
|
modelId.startsWith('gpt-5.4') ||
|
|
45
|
-
modelId.startsWith('gpt-5.5')
|
|
45
|
+
modelId.startsWith('gpt-5.5') ||
|
|
46
|
+
modelId.startsWith('gpt-5.6');
|
|
46
47
|
|
|
47
48
|
const systemMessageMode = isReasoningModel ? 'developer' : 'system';
|
|
48
49
|
|
|
@@ -5,6 +5,7 @@ export type OpenAIResponsesUsage = {
|
|
|
5
5
|
output_tokens: number;
|
|
6
6
|
input_tokens_details?: {
|
|
7
7
|
cached_tokens?: number | null;
|
|
8
|
+
cache_write_tokens?: number | null;
|
|
8
9
|
orchestration_input_tokens?: number | null;
|
|
9
10
|
orchestration_input_cached_tokens?: number | null;
|
|
10
11
|
} | null;
|
|
@@ -37,14 +38,16 @@ export function convertOpenAIResponsesUsage(
|
|
|
37
38
|
const inputTokens = usage.input_tokens;
|
|
38
39
|
const outputTokens = usage.output_tokens;
|
|
39
40
|
const cachedTokens = usage.input_tokens_details?.cached_tokens ?? 0;
|
|
41
|
+
const cacheWriteTokens =
|
|
42
|
+
usage.input_tokens_details?.cache_write_tokens ?? undefined;
|
|
40
43
|
const reasoningTokens = usage.output_tokens_details?.reasoning_tokens ?? 0;
|
|
41
44
|
|
|
42
45
|
return {
|
|
43
46
|
inputTokens: {
|
|
44
47
|
total: inputTokens,
|
|
45
|
-
noCache: inputTokens - cachedTokens,
|
|
48
|
+
noCache: inputTokens - cachedTokens - (cacheWriteTokens ?? 0),
|
|
46
49
|
cacheRead: cachedTokens,
|
|
47
|
-
cacheWrite:
|
|
50
|
+
cacheWrite: cacheWriteTokens,
|
|
48
51
|
},
|
|
49
52
|
outputTokens: {
|
|
50
53
|
total: outputTokens,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UnsupportedFunctionalityError,
|
|
3
3
|
type LanguageModelV4Prompt,
|
|
4
|
+
type SharedV4ProviderOptions,
|
|
4
5
|
type LanguageModelV4ToolApprovalResponsePart,
|
|
5
6
|
type SharedV4Warning,
|
|
6
7
|
} from '@ai-sdk/provider';
|
|
@@ -41,6 +42,17 @@ function serializeToolCallArguments(input: unknown): string {
|
|
|
41
42
|
return JSON.stringify(input === undefined ? {} : input);
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
type OpenAIPromptCacheBreakpoint = { mode: 'explicit' };
|
|
46
|
+
|
|
47
|
+
function getPromptCacheBreakpoint(
|
|
48
|
+
providerOptions: SharedV4ProviderOptions | undefined,
|
|
49
|
+
providerOptionsName: string,
|
|
50
|
+
): OpenAIPromptCacheBreakpoint | undefined {
|
|
51
|
+
return providerOptions?.[providerOptionsName]?.promptCacheBreakpoint as
|
|
52
|
+
| OpenAIPromptCacheBreakpoint
|
|
53
|
+
| undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
/**
|
|
45
57
|
* This is soft-deprecated. Use provider references instead. Kept for backward compatibility
|
|
46
58
|
* with the `fileIdPrefixes` option.
|
|
@@ -89,16 +101,48 @@ export async function convertToOpenAIResponsesInput({
|
|
|
89
101
|
const warnings: Array<SharedV4Warning> = [];
|
|
90
102
|
const processedApprovalIds = new Set<string>();
|
|
91
103
|
|
|
92
|
-
for (const { role, content } of prompt) {
|
|
104
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
93
105
|
switch (role) {
|
|
94
106
|
case 'system': {
|
|
95
107
|
switch (systemMessageMode) {
|
|
96
108
|
case 'system': {
|
|
97
|
-
|
|
109
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
110
|
+
providerOptions,
|
|
111
|
+
providerOptionsName,
|
|
112
|
+
);
|
|
113
|
+
input.push({
|
|
114
|
+
role: 'system',
|
|
115
|
+
content:
|
|
116
|
+
promptCacheBreakpoint == null
|
|
117
|
+
? content
|
|
118
|
+
: [
|
|
119
|
+
{
|
|
120
|
+
type: 'input_text',
|
|
121
|
+
text: content,
|
|
122
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
});
|
|
98
126
|
break;
|
|
99
127
|
}
|
|
100
128
|
case 'developer': {
|
|
101
|
-
|
|
129
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
130
|
+
providerOptions,
|
|
131
|
+
providerOptionsName,
|
|
132
|
+
);
|
|
133
|
+
input.push({
|
|
134
|
+
role: 'developer',
|
|
135
|
+
content:
|
|
136
|
+
promptCacheBreakpoint == null
|
|
137
|
+
? content
|
|
138
|
+
: [
|
|
139
|
+
{
|
|
140
|
+
type: 'input_text',
|
|
141
|
+
text: content,
|
|
142
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
});
|
|
102
146
|
break;
|
|
103
147
|
}
|
|
104
148
|
case 'remove': {
|
|
@@ -124,9 +168,23 @@ export async function convertToOpenAIResponsesInput({
|
|
|
124
168
|
content: content.map((part, index) => {
|
|
125
169
|
switch (part.type) {
|
|
126
170
|
case 'text': {
|
|
127
|
-
|
|
171
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
172
|
+
part.providerOptions,
|
|
173
|
+
providerOptionsName,
|
|
174
|
+
);
|
|
175
|
+
return {
|
|
176
|
+
type: 'input_text',
|
|
177
|
+
text: part.text,
|
|
178
|
+
...(promptCacheBreakpoint != null && {
|
|
179
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
128
182
|
}
|
|
129
183
|
case 'file': {
|
|
184
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
185
|
+
part.providerOptions,
|
|
186
|
+
providerOptionsName,
|
|
187
|
+
);
|
|
130
188
|
switch (part.data.type) {
|
|
131
189
|
case 'reference': {
|
|
132
190
|
const fileId = resolveProviderReference({
|
|
@@ -141,12 +199,18 @@ export async function convertToOpenAIResponsesInput({
|
|
|
141
199
|
detail:
|
|
142
200
|
part.providerOptions?.[providerOptionsName]
|
|
143
201
|
?.imageDetail,
|
|
202
|
+
...(promptCacheBreakpoint != null && {
|
|
203
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
204
|
+
}),
|
|
144
205
|
};
|
|
145
206
|
}
|
|
146
207
|
|
|
147
208
|
return {
|
|
148
209
|
type: 'input_file',
|
|
149
210
|
file_id: fileId,
|
|
211
|
+
...(promptCacheBreakpoint != null && {
|
|
212
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
213
|
+
}),
|
|
150
214
|
};
|
|
151
215
|
}
|
|
152
216
|
case 'text': {
|
|
@@ -172,12 +236,18 @@ export async function convertToOpenAIResponsesInput({
|
|
|
172
236
|
detail:
|
|
173
237
|
part.providerOptions?.[providerOptionsName]
|
|
174
238
|
?.imageDetail,
|
|
239
|
+
...(promptCacheBreakpoint != null && {
|
|
240
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
241
|
+
}),
|
|
175
242
|
};
|
|
176
243
|
} else {
|
|
177
244
|
if (part.data.type === 'url') {
|
|
178
245
|
return {
|
|
179
246
|
type: 'input_file',
|
|
180
247
|
file_url: part.data.url.toString(),
|
|
248
|
+
...(promptCacheBreakpoint != null && {
|
|
249
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
250
|
+
}),
|
|
181
251
|
};
|
|
182
252
|
}
|
|
183
253
|
|
|
@@ -204,6 +274,9 @@ export async function convertToOpenAIResponsesInput({
|
|
|
204
274
|
: `part-${index}`),
|
|
205
275
|
file_data: `data:${fullMediaType};base64,${convertToBase64(part.data.data)}`,
|
|
206
276
|
}),
|
|
277
|
+
...(promptCacheBreakpoint != null && {
|
|
278
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
279
|
+
}),
|
|
207
280
|
};
|
|
208
281
|
}
|
|
209
282
|
}
|
|
@@ -813,9 +886,19 @@ export async function convertToOpenAIResponsesInput({
|
|
|
813
886
|
case 'content':
|
|
814
887
|
outputValue = output.value
|
|
815
888
|
.map(item => {
|
|
889
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
890
|
+
item.providerOptions,
|
|
891
|
+
providerOptionsName,
|
|
892
|
+
);
|
|
816
893
|
switch (item.type) {
|
|
817
894
|
case 'text':
|
|
818
|
-
return {
|
|
895
|
+
return {
|
|
896
|
+
type: 'input_text' as const,
|
|
897
|
+
text: item.text,
|
|
898
|
+
...(promptCacheBreakpoint != null && {
|
|
899
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
900
|
+
}),
|
|
901
|
+
};
|
|
819
902
|
case 'file': {
|
|
820
903
|
const topLevel = getTopLevelMediaType(item.mediaType);
|
|
821
904
|
const imageDetail =
|
|
@@ -831,12 +914,18 @@ export async function convertToOpenAIResponsesInput({
|
|
|
831
914
|
type: 'input_image' as const,
|
|
832
915
|
image_url: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
|
|
833
916
|
detail: imageDetail,
|
|
917
|
+
...(promptCacheBreakpoint != null && {
|
|
918
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
919
|
+
}),
|
|
834
920
|
};
|
|
835
921
|
}
|
|
836
922
|
return {
|
|
837
923
|
type: 'input_file' as const,
|
|
838
924
|
filename: item.filename ?? 'data',
|
|
839
925
|
file_data: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
|
|
926
|
+
...(promptCacheBreakpoint != null && {
|
|
927
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
928
|
+
}),
|
|
840
929
|
};
|
|
841
930
|
}
|
|
842
931
|
|
|
@@ -846,11 +935,17 @@ export async function convertToOpenAIResponsesInput({
|
|
|
846
935
|
type: 'input_image' as const,
|
|
847
936
|
image_url: item.data.url.toString(),
|
|
848
937
|
detail: imageDetail,
|
|
938
|
+
...(promptCacheBreakpoint != null && {
|
|
939
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
940
|
+
}),
|
|
849
941
|
};
|
|
850
942
|
}
|
|
851
943
|
return {
|
|
852
944
|
type: 'input_file' as const,
|
|
853
945
|
file_url: item.data.url.toString(),
|
|
946
|
+
...(promptCacheBreakpoint != null && {
|
|
947
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
948
|
+
}),
|
|
854
949
|
};
|
|
855
950
|
}
|
|
856
951
|
|
|
@@ -897,9 +992,19 @@ export async function convertToOpenAIResponsesInput({
|
|
|
897
992
|
case 'content':
|
|
898
993
|
contentValue = output.value
|
|
899
994
|
.map(item => {
|
|
995
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
996
|
+
item.providerOptions,
|
|
997
|
+
providerOptionsName,
|
|
998
|
+
);
|
|
900
999
|
switch (item.type) {
|
|
901
1000
|
case 'text': {
|
|
902
|
-
return {
|
|
1001
|
+
return {
|
|
1002
|
+
type: 'input_text' as const,
|
|
1003
|
+
text: item.text,
|
|
1004
|
+
...(promptCacheBreakpoint != null && {
|
|
1005
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
1006
|
+
}),
|
|
1007
|
+
};
|
|
903
1008
|
}
|
|
904
1009
|
|
|
905
1010
|
case 'file': {
|
|
@@ -917,12 +1022,18 @@ export async function convertToOpenAIResponsesInput({
|
|
|
917
1022
|
type: 'input_image' as const,
|
|
918
1023
|
image_url: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
|
|
919
1024
|
detail: imageDetail,
|
|
1025
|
+
...(promptCacheBreakpoint != null && {
|
|
1026
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
1027
|
+
}),
|
|
920
1028
|
};
|
|
921
1029
|
}
|
|
922
1030
|
return {
|
|
923
1031
|
type: 'input_file' as const,
|
|
924
1032
|
filename: item.filename ?? 'data',
|
|
925
1033
|
file_data: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
|
|
1034
|
+
...(promptCacheBreakpoint != null && {
|
|
1035
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
1036
|
+
}),
|
|
926
1037
|
};
|
|
927
1038
|
}
|
|
928
1039
|
|
|
@@ -932,11 +1043,17 @@ export async function convertToOpenAIResponsesInput({
|
|
|
932
1043
|
type: 'input_image' as const,
|
|
933
1044
|
image_url: item.data.url.toString(),
|
|
934
1045
|
detail: imageDetail,
|
|
1046
|
+
...(promptCacheBreakpoint != null && {
|
|
1047
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
1048
|
+
}),
|
|
935
1049
|
};
|
|
936
1050
|
}
|
|
937
1051
|
return {
|
|
938
1052
|
type: 'input_file' as const,
|
|
939
1053
|
file_url: item.data.url.toString(),
|
|
1054
|
+
...(promptCacheBreakpoint != null && {
|
|
1055
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
1056
|
+
}),
|
|
940
1057
|
};
|
|
941
1058
|
}
|
|
942
1059
|
|
|
@@ -73,18 +73,49 @@ export type OpenAIResponsesApplyPatchOperationDiffDoneChunk = {
|
|
|
73
73
|
|
|
74
74
|
export type OpenAIResponsesSystemMessage = {
|
|
75
75
|
role: 'system' | 'developer';
|
|
76
|
-
content:
|
|
76
|
+
content:
|
|
77
|
+
| string
|
|
78
|
+
| Array<{
|
|
79
|
+
type: 'input_text';
|
|
80
|
+
text: string;
|
|
81
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
82
|
+
}>;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
85
|
export type OpenAIResponsesUserMessage = {
|
|
80
86
|
role: 'user';
|
|
81
87
|
content: Array<
|
|
82
|
-
| {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| {
|
|
88
|
+
| {
|
|
89
|
+
type: 'input_text';
|
|
90
|
+
text: string;
|
|
91
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
type: 'input_image';
|
|
95
|
+
image_url: string;
|
|
96
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
97
|
+
}
|
|
98
|
+
| {
|
|
99
|
+
type: 'input_image';
|
|
100
|
+
file_id: string;
|
|
101
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
102
|
+
}
|
|
103
|
+
| {
|
|
104
|
+
type: 'input_file';
|
|
105
|
+
file_url: string;
|
|
106
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
107
|
+
}
|
|
108
|
+
| {
|
|
109
|
+
type: 'input_file';
|
|
110
|
+
filename: string;
|
|
111
|
+
file_data: string;
|
|
112
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
113
|
+
}
|
|
114
|
+
| {
|
|
115
|
+
type: 'input_file';
|
|
116
|
+
file_id: string;
|
|
117
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
118
|
+
}
|
|
88
119
|
>;
|
|
89
120
|
};
|
|
90
121
|
|
|
@@ -110,10 +141,27 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
110
141
|
output:
|
|
111
142
|
| string
|
|
112
143
|
| Array<
|
|
113
|
-
| {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
144
|
+
| {
|
|
145
|
+
type: 'input_text';
|
|
146
|
+
text: string;
|
|
147
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
148
|
+
}
|
|
149
|
+
| {
|
|
150
|
+
type: 'input_image';
|
|
151
|
+
image_url: string;
|
|
152
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
153
|
+
}
|
|
154
|
+
| {
|
|
155
|
+
type: 'input_file';
|
|
156
|
+
filename: string;
|
|
157
|
+
file_data: string;
|
|
158
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
159
|
+
}
|
|
160
|
+
| {
|
|
161
|
+
type: 'input_file';
|
|
162
|
+
file_url: string;
|
|
163
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
164
|
+
}
|
|
117
165
|
>;
|
|
118
166
|
};
|
|
119
167
|
|
|
@@ -534,6 +582,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
534
582
|
input_tokens_details: z
|
|
535
583
|
.object({
|
|
536
584
|
cached_tokens: z.number().nullish(),
|
|
585
|
+
cache_write_tokens: z.number().nullish(),
|
|
537
586
|
orchestration_input_tokens: z.number().nullish(),
|
|
538
587
|
orchestration_input_cached_tokens: z.number().nullish(),
|
|
539
588
|
})
|
|
@@ -546,6 +595,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
546
595
|
})
|
|
547
596
|
.nullish(),
|
|
548
597
|
}),
|
|
598
|
+
reasoning: z
|
|
599
|
+
.object({
|
|
600
|
+
context: z.string().nullish(),
|
|
601
|
+
})
|
|
602
|
+
.nullish(),
|
|
549
603
|
service_tier: z.string().nullish(),
|
|
550
604
|
}),
|
|
551
605
|
}),
|
|
@@ -566,6 +620,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
566
620
|
input_tokens_details: z
|
|
567
621
|
.object({
|
|
568
622
|
cached_tokens: z.number().nullish(),
|
|
623
|
+
cache_write_tokens: z.number().nullish(),
|
|
569
624
|
orchestration_input_tokens: z.number().nullish(),
|
|
570
625
|
orchestration_input_cached_tokens: z.number().nullish(),
|
|
571
626
|
})
|
|
@@ -579,6 +634,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
579
634
|
.nullish(),
|
|
580
635
|
})
|
|
581
636
|
.nullish(),
|
|
637
|
+
reasoning: z
|
|
638
|
+
.object({
|
|
639
|
+
context: z.string().nullish(),
|
|
640
|
+
})
|
|
641
|
+
.nullish(),
|
|
582
642
|
service_tier: z.string().nullish(),
|
|
583
643
|
}),
|
|
584
644
|
}),
|
|
@@ -1426,6 +1486,11 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1426
1486
|
)
|
|
1427
1487
|
.optional(),
|
|
1428
1488
|
service_tier: z.string().nullish(),
|
|
1489
|
+
reasoning: z
|
|
1490
|
+
.object({
|
|
1491
|
+
context: z.string().nullish(),
|
|
1492
|
+
})
|
|
1493
|
+
.nullish(),
|
|
1429
1494
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
1430
1495
|
usage: z
|
|
1431
1496
|
.object({
|
|
@@ -1433,6 +1498,7 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1433
1498
|
input_tokens_details: z
|
|
1434
1499
|
.object({
|
|
1435
1500
|
cached_tokens: z.number().nullish(),
|
|
1501
|
+
cache_write_tokens: z.number().nullish(),
|
|
1436
1502
|
orchestration_input_tokens: z.number().nullish(),
|
|
1437
1503
|
orchestration_input_cached_tokens: z.number().nullish(),
|
|
1438
1504
|
})
|
|
@@ -53,6 +53,10 @@ export const openaiResponsesReasoningModelIds = [
|
|
|
53
53
|
'gpt-5.4-pro-2026-03-05',
|
|
54
54
|
'gpt-5.5',
|
|
55
55
|
'gpt-5.5-2026-04-23',
|
|
56
|
+
'gpt-5.6',
|
|
57
|
+
'gpt-5.6-luna',
|
|
58
|
+
'gpt-5.6-sol',
|
|
59
|
+
'gpt-5.6-terra',
|
|
56
60
|
] as const;
|
|
57
61
|
|
|
58
62
|
export const openaiResponsesModelIds = [
|
|
@@ -121,6 +125,10 @@ export type OpenAIResponsesModelId =
|
|
|
121
125
|
| 'gpt-5.4-pro-2026-03-05'
|
|
122
126
|
| 'gpt-5.5'
|
|
123
127
|
| 'gpt-5.5-2026-04-23'
|
|
128
|
+
| 'gpt-5.6'
|
|
129
|
+
| 'gpt-5.6-luna'
|
|
130
|
+
| 'gpt-5.6-sol'
|
|
131
|
+
| 'gpt-5.6-terra'
|
|
124
132
|
| 'gpt-5-2025-08-07'
|
|
125
133
|
| 'gpt-5-chat-latest'
|
|
126
134
|
| 'gpt-5-codex'
|
|
@@ -222,11 +230,25 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
|
|
|
222
230
|
*/
|
|
223
231
|
promptCacheKey: z.string().nullish(),
|
|
224
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
235
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
236
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
237
|
+
*/
|
|
238
|
+
promptCacheOptions: z
|
|
239
|
+
.object({
|
|
240
|
+
mode: z.enum(['implicit', 'explicit']).optional(),
|
|
241
|
+
ttl: z.literal('30m').optional(),
|
|
242
|
+
})
|
|
243
|
+
.optional(),
|
|
244
|
+
|
|
225
245
|
/**
|
|
226
246
|
* The retention policy for the prompt cache.
|
|
227
247
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
228
248
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
229
|
-
*
|
|
249
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
250
|
+
*
|
|
251
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
230
252
|
*
|
|
231
253
|
* @default 'in_memory'
|
|
232
254
|
*/
|
|
@@ -235,15 +257,26 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
|
|
|
235
257
|
/**
|
|
236
258
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
237
259
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
|
|
241
|
-
* models. Also, the 'xhigh' type for `reasoningEffort` is only available for
|
|
242
|
-
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
243
|
-
* an error.
|
|
260
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
261
|
+
* Supported values vary by model.
|
|
244
262
|
*/
|
|
245
263
|
reasoningEffort: z.string().nullish(),
|
|
246
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
267
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
268
|
+
*/
|
|
269
|
+
reasoningMode: z.enum(['standard', 'pro']).optional(),
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
273
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
274
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
275
|
+
*/
|
|
276
|
+
reasoningContext: z
|
|
277
|
+
.enum(['auto', 'current_turn', 'all_turns'])
|
|
278
|
+
.optional(),
|
|
279
|
+
|
|
247
280
|
/**
|
|
248
281
|
* Controls reasoning summary output from the model.
|
|
249
282
|
* Set to "auto" to automatically receive the richest level available,
|