@ai-sdk/openai 3.0.131 → 3.0.133

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.
@@ -206,9 +206,9 @@ The following provider options are available:
206
206
  Reasoning effort for reasoning models. Defaults to `medium`. If you use `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
207
207
 
208
208
  <Note>
209
- Supported reasoning efforts vary by model. GPT-5.6, GPT-6 Sol, and GPT-6 Luna
210
- support `'none'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`, and `'max'`. GPT-6
211
- Astra and GPT-6.1 Sol do not support `'none'`.
209
+ Supported reasoning efforts vary by model. GPT-5.6, GPT-6 Sol, GPT-6 Luna, and
210
+ GPT-6.1 Terra support `'none'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`, and
211
+ `'max'`. GPT-6 Astra and GPT-6.1 Sol do not support `'none'`.
212
212
  </Note>
213
213
 
214
214
  <Note>
@@ -2562,6 +2562,7 @@ The following optional provider options are available for OpenAI completion mode
2562
2562
  | --------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
2563
2563
  | `gpt-6-astra` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
2564
2564
  | `gpt-6.1-sol` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
2565
+ | `gpt-6.1-terra` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
2565
2566
  | `gpt-6-luna` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
2566
2567
  | `gpt-6-sol` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
2567
2568
  | `gpt-5.6` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "3.0.131",
3
+ "version": "3.0.133",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -72,6 +72,7 @@ export type OpenAIChatModelId =
72
72
  | 'gpt-5.6-terra'
73
73
  | 'gpt-6-astra'
74
74
  | 'gpt-6.1-sol'
75
+ | 'gpt-6.1-terra'
75
76
  | 'gpt-6-luna'
76
77
  | 'gpt-6-sol'
77
78
  | (string & {});
@@ -16,5 +16,6 @@ export * from '../tool/apply-patch';
16
16
  export * from '../tool/code-interpreter';
17
17
  export * from '../tool/file-search';
18
18
  export * from '../tool/image-generation';
19
+ export * from '../tool/tool-search';
19
20
  export * from '../tool/web-search';
20
21
  export * from '../tool/web-search-preview';
@@ -24,7 +24,10 @@ export function getOpenAILanguageModelCapabilities(
24
24
  const isGptNanoModel = gptVersion?.variant?.startsWith('nano') ?? false;
25
25
  const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
26
26
 
27
- const isGpt6SolOrLuna = modelId === 'gpt-6-sol' || modelId === 'gpt-6-luna';
27
+ const isGpt6OrLaterModelWithNoneEffort =
28
+ modelId === 'gpt-6-sol' ||
29
+ modelId === 'gpt-6-luna' ||
30
+ modelId === 'gpt-6.1-terra';
28
31
 
29
32
  const supportsFlexProcessing =
30
33
  (oSeriesVersion != null && oSeriesVersion >= 3) ||
@@ -59,7 +62,7 @@ export function getOpenAILanguageModelCapabilities(
59
62
  supportsPriorityProcessing,
60
63
  supportsConfigurationUpdate: isGpt6OrLaterModel,
61
64
  supportsAsyncToolCalling: isGpt6OrLaterModel,
62
- supportedReasoningEfforts: isGpt6SolOrLuna
65
+ supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort
63
66
  ? ['none', 'low', 'medium', 'high', 'xhigh', 'max']
64
67
  : isGpt6OrLaterModel
65
68
  ? ['low', 'medium', 'high', 'xhigh', 'max']
@@ -271,6 +271,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
271
271
  toolNameMapping,
272
272
  customProviderToolNames,
273
273
  supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
274
+ providerOptionsName,
274
275
  });
275
276
 
276
277
  const configurationUpdateUnsupportedReason =
@@ -59,6 +59,7 @@ export const openaiResponsesReasoningModelIds = [
59
59
  'gpt-5.6-terra',
60
60
  'gpt-6-astra',
61
61
  'gpt-6.1-sol',
62
+ 'gpt-6.1-terra',
62
63
  'gpt-6-luna',
63
64
  'gpt-6-sol',
64
65
  ] as const;
@@ -135,6 +136,7 @@ export type OpenAIResponsesModelId =
135
136
  | 'gpt-5.6-terra'
136
137
  | 'gpt-6-astra'
137
138
  | 'gpt-6.1-sol'
139
+ | 'gpt-6.1-terra'
138
140
  | 'gpt-6-luna'
139
141
  | 'gpt-6-sol'
140
142
  | 'gpt-5-2025-08-07'
@@ -44,6 +44,7 @@ export async function prepareResponsesTools({
44
44
  toolNameMapping,
45
45
  customProviderToolNames,
46
46
  supportsAsyncToolCalling = true,
47
+ providerOptionsName = 'openai',
47
48
  }: {
48
49
  tools: LanguageModelV3CallOptions['tools'];
49
50
  toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
@@ -54,6 +55,7 @@ export async function prepareResponsesTools({
54
55
  toolNameMapping?: ToolNameMapping;
55
56
  customProviderToolNames?: Set<string>;
56
57
  supportsAsyncToolCalling?: boolean;
58
+ providerOptionsName?: string;
57
59
  }): Promise<{
58
60
  tools?: Array<OpenAIResponsesTool>;
59
61
  toolChoice?:
@@ -125,9 +127,8 @@ export async function prepareResponsesTools({
125
127
  for (const tool of tools) {
126
128
  switch (tool.type) {
127
129
  case 'function': {
128
- const openaiOptions = tool.providerOptions?.openai as
129
- | OpenAIToolOptions
130
- | undefined;
130
+ const openaiOptions = (tool.providerOptions?.[providerOptionsName] ??
131
+ tool.providerOptions?.openai) as OpenAIToolOptions | undefined;
131
132
  const openaiFunctionTool = prepareFunctionTool({
132
133
  tool,
133
134
  options: openaiOptions,
@@ -32,6 +32,14 @@ export const openaiTranscriptionResponseSchema = lazySchema(() =>
32
32
  }),
33
33
  )
34
34
  .nullish(),
35
+ // Lenient: an unexpected usage shape must not fail the transcription.
36
+ usage: z
37
+ .object({
38
+ type: z.string().nullish(),
39
+ seconds: z.number().nullish(),
40
+ })
41
+ .nullish()
42
+ .catch(undefined),
35
43
  }),
36
44
  ),
37
45
  );
@@ -145,12 +145,16 @@ export class OpenAITranscriptionModel implements TranscriptionModelV3 {
145
145
  prompt: openAIOptions.prompt,
146
146
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
147
147
  // prefer verbose_json to get segments for models that support it
148
- response_format: [
149
- 'gpt-4o-transcribe',
150
- 'gpt-4o-mini-transcribe',
151
- ].includes(this.modelId)
152
- ? 'json'
153
- : 'verbose_json',
148
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
149
+ response_format:
150
+ ['gpt-4o-transcribe', 'gpt-4o-mini-transcribe'].includes(
151
+ this.modelId,
152
+ ) ||
153
+ this.modelId.startsWith('gpt-4o-mini-transcribe-') ||
154
+ this.modelId === 'gpt-transcribe' ||
155
+ this.modelId.startsWith('gpt-transcribe-')
156
+ ? 'json'
157
+ : 'verbose_json',
154
158
  temperature: openAIOptions.temperature,
155
159
  timestamp_granularities: openAIOptions.timestampGranularities,
156
160
  };
@@ -219,7 +223,12 @@ export class OpenAITranscriptionModel implements TranscriptionModelV3 {
219
223
  })) ??
220
224
  [],
221
225
  language,
222
- durationInSeconds: response.duration ?? undefined,
226
+ // Duration-billed json responses report the duration only in `usage`:
227
+ durationInSeconds:
228
+ response.duration ??
229
+ (response.usage?.type === 'duration'
230
+ ? (response.usage.seconds ?? undefined)
231
+ : undefined),
223
232
  warnings,
224
233
  response: {
225
234
  timestamp: currentDate,