@ai-sdk/openai 4.0.90 → 4.0.91

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.
@@ -3516,6 +3516,22 @@ text. Score levels receive zero-based index labels. Non-null Boolean criteria ar
3516
3516
  appended to predicate instructions under `Criteria for true:` and `Criteria for false:`.
3517
3517
  String criteria are passed through; structured criteria are serialized as JSON text.
3518
3518
 
3519
+ Image file parts in `state` are sent as inline images. Set `imageDetail` in a file
3520
+ part's `providerOptions.openai` to `'low'`, `'high'`, `'auto'`, or `'original'` to
3521
+ choose its detail level:
3522
+
3523
+ ```ts
3524
+ state: [
3525
+ { type: 'text', text: 'Inspect the product in this photo.' },
3526
+ {
3527
+ type: 'file',
3528
+ mediaType: 'image/png',
3529
+ data: productPhoto,
3530
+ providerOptions: { openai: { imageDetail: 'high' } },
3531
+ },
3532
+ ],
3533
+ ```
3534
+
3519
3535
  The factory respects `createOpenAI` settings, including custom fetch and base URL.
3520
3536
  Set `providerOptions.openai.safetyIdentifier` to an opaque end-user identifier for
3521
3537
  safety monitoring (up to 128 characters). For example:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "4.0.90",
3
+ "version": "4.0.91",
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.25",
39
- "@ai-sdk/provider-utils": "5.0.57"
38
+ "@ai-sdk/provider": "4.0.26",
39
+ "@ai-sdk/provider-utils": "5.0.58"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -54,6 +54,7 @@ export class OpenAIEmbeddingModel implements EmbeddingModelV4 {
54
54
 
55
55
  async doEmbed({
56
56
  values,
57
+ dimensions,
57
58
  headers,
58
59
  abortSignal,
59
60
  providerOptions,
@@ -91,7 +92,7 @@ export class OpenAIEmbeddingModel implements EmbeddingModelV4 {
91
92
  model: this.modelId,
92
93
  input: values,
93
94
  encoding_format: 'float',
94
- dimensions: openaiOptions.dimensions,
95
+ dimensions: openaiOptions.dimensions ?? dimensions,
95
96
  user: openaiOptions.user,
96
97
  },
97
98
  failedResponseHandler: openaiFailedResponseHandler,
@@ -812,7 +812,9 @@ async function convertOpenAIBatchResult(
812
812
  type: 'tool-result',
813
813
  toolCallId: part.id,
814
814
  toolName: 'web_search',
815
- result: mapWebSearchOutput(part.action),
815
+ ...(part.status === 'failed' || part.status === 'incomplete'
816
+ ? { isError: true, result: { status: part.status } }
817
+ : { result: mapWebSearchOutput(part.action) }),
816
818
  dynamic: true,
817
819
  });
818
820
  break;
@@ -170,9 +170,11 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
170
170
  functionality: `OpenAI decision image media type: ${part.mediaType}`,
171
171
  });
172
172
  }
173
+ const detail = part.providerOptions?.openai?.imageDetail;
173
174
  return {
174
175
  type: 'input_image',
175
176
  image_url: `data:${mediaType};base64,${typeof part.data.data === 'string' ? part.data.data : convertUint8ArrayToBase64(part.data.data)}`,
177
+ ...(detail != null && { detail }),
176
178
  };
177
179
  }),
178
180
  },
@@ -1283,7 +1283,9 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1283
1283
  toolName: toolNameMapping.toCustomToolName(
1284
1284
  webSearchToolName ?? 'web_search',
1285
1285
  ),
1286
- result: mapWebSearchOutput(part.action),
1286
+ ...(part.status === 'failed' || part.status === 'incomplete'
1287
+ ? { isError: true, result: { status: part.status } }
1288
+ : { result: mapWebSearchOutput(part.action) }),
1287
1289
  });
1288
1290
 
1289
1291
  break;
@@ -2148,7 +2150,10 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
2148
2150
  toolName: toolNameMapping.toCustomToolName(
2149
2151
  webSearchToolName ?? 'web_search',
2150
2152
  ),
2151
- result: mapWebSearchOutput(value.item.action),
2153
+ ...(value.item.status === 'failed' ||
2154
+ value.item.status === 'incomplete'
2155
+ ? { isError: true, result: { status: value.item.status } }
2156
+ : { result: mapWebSearchOutput(value.item.action) }),
2152
2157
  });
2153
2158
  } else if (value.item.type === 'computer_call') {
2154
2159
  ongoingToolCalls[value.output_index] = undefined;