@ai-sdk/openai 4.0.88 → 4.0.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "4.0.88",
3
+ "version": "4.0.90",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.24",
39
- "@ai-sdk/provider-utils": "5.0.56"
38
+ "@ai-sdk/provider": "4.0.25",
39
+ "@ai-sdk/provider-utils": "5.0.57"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -259,7 +259,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
259
259
  // remove unsupported settings for reasoning models
260
260
  // see https://platform.openai.com/docs/guides/reasoning#limitations
261
261
  if (isReasoningModel) {
262
- // when reasoning effort is none, gpt-5.1 models allow temperature, topP, logprobs
262
+ // supported models allow temperature, topP, and logprobs when reasoning effort is none
263
263
  // https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
264
264
  if (
265
265
  resolvedReasoningEffort !== 'none' ||
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  InvalidResponseDataError,
3
+ UnsupportedFunctionalityError,
3
4
  type Experimental_DecisionModelV4 as DecisionModelV4,
4
5
  type Experimental_DecisionModelV4Answer as DecisionModelV4Answer,
5
6
  type Experimental_DecisionModelV4Input as DecisionModelV4Input,
6
7
  } from '@ai-sdk/provider';
7
8
  import {
8
9
  combineHeaders,
10
+ convertUint8ArrayToBase64,
11
+ detectMediaType,
12
+ isFullMediaType,
9
13
  createJsonResponseHandler,
10
14
  postJsonToApi,
11
15
  parseProviderOptions,
@@ -72,10 +76,6 @@ const responseSchema = z.object({
72
76
  ),
73
77
  });
74
78
 
75
- function toText(input: DecisionModelV4Input): string {
76
- return typeof input === 'string' ? input : JSON.stringify(input);
77
- }
78
-
79
79
  export class DecisionOpenAIModel implements DecisionModelV4 {
80
80
  readonly specificationVersion = 'v4';
81
81
  readonly supportedQuestionTypes = ['choice', 'score', 'boolean'] as const;
@@ -135,7 +135,48 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
135
135
  body: {
136
136
  model: this.modelId,
137
137
  safety_identifier: openaiOptions?.safetyIdentifier,
138
- input: toText(state),
138
+ input: [
139
+ {
140
+ role: 'user',
141
+ content: state.map(part => {
142
+ if (part.type === 'text')
143
+ return { type: 'input_text', text: part.text };
144
+ if (part.type === 'json')
145
+ return {
146
+ type: 'input_text',
147
+ text: JSON.stringify(part.value),
148
+ };
149
+ if (part.data.type !== 'data') {
150
+ throw new UnsupportedFunctionalityError({
151
+ functionality: `OpenAI decision file input: ${part.mediaType} (${part.data.type})`,
152
+ });
153
+ }
154
+ // Direct doDecide calls can bypass Core's media type detection.
155
+ const mediaType = isFullMediaType(part.mediaType)
156
+ ? part.mediaType
157
+ : detectMediaType({
158
+ data: part.data.data,
159
+ topLevelType: 'image',
160
+ });
161
+ if (
162
+ ![
163
+ 'image/png',
164
+ 'image/jpeg',
165
+ 'image/webp',
166
+ 'image/gif',
167
+ ].includes(mediaType ?? '')
168
+ ) {
169
+ throw new UnsupportedFunctionalityError({
170
+ functionality: `OpenAI decision image media type: ${part.mediaType}`,
171
+ });
172
+ }
173
+ return {
174
+ type: 'input_image',
175
+ image_url: `data:${mediaType};base64,${typeof part.data.data === 'string' ? part.data.data : convertUint8ArrayToBase64(part.data.data)}`,
176
+ };
177
+ }),
178
+ },
179
+ ],
139
180
  questions: Object.entries(questions).map(([name, question]) => {
140
181
  const instructions = toText(question.instructions);
141
182
  switch (question.type) {
@@ -283,3 +324,7 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
283
324
  };
284
325
  }
285
326
  }
327
+
328
+ function toText(input: DecisionModelV4Input): string {
329
+ return typeof input === 'string' ? input : JSON.stringify(input);
330
+ }
@@ -45,12 +45,14 @@ export function getOpenAILanguageModelCapabilities(
45
45
  (gptVersion != null && gptVersion.major >= 5 && !isGptChatModel);
46
46
 
47
47
  // https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
48
- // GPT-5.1 and later model families support temperature, topP, logProbs when reasoningEffort is none.
48
+ // GPT-5.1 through GPT-5.x and GPT-6 Sol/Luna support temperature,
49
+ // topP, and logProbs when reasoningEffort is none.
49
50
  const supportsNonReasoningParameters =
50
- !isGpt6OrLaterModel &&
51
- gptVersion != null &&
52
- (gptVersion.major > 5 ||
53
- (gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1));
51
+ isGpt6SolOrLuna ||
52
+ (!isGpt6OrLaterModel &&
53
+ gptVersion != null &&
54
+ (gptVersion.major > 5 ||
55
+ (gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1)));
54
56
 
55
57
  const systemMessageMode = isReasoningModel ? 'developer' : 'system';
56
58
 
@@ -685,11 +685,19 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
685
685
  // remove unsupported settings for reasoning models
686
686
  // see https://platform.openai.com/docs/guides/reasoning#limitations
687
687
  if (isReasoningModel) {
688
- // when reasoning effort is none, gpt-5.1 models allow temperature, topP, logprobs
688
+ // Input updates change the effort used to validate sampling parameters.
689
+ let effectiveReasoningEffort = resolvedReasoningEffort;
690
+ for (const item of input) {
691
+ if (item.type === 'configuration_update') {
692
+ effectiveReasoningEffort = item.reasoning.effort;
693
+ }
694
+ }
695
+
696
+ // supported models allow temperature, topP, and logprobs when reasoning effort is none
689
697
  // https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
690
698
  if (
691
699
  !(
692
- resolvedReasoningEffort === 'none' &&
700
+ effectiveReasoningEffort === 'none' &&
693
701
  modelCapabilities.supportsNonReasoningParameters
694
702
  )
695
703
  ) {