@ai-sdk/openai 2.0.0-canary.5 → 2.0.0-canary.7

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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.0-canary.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 26735b5: chore(embedding-model): add v2 interface
8
+ - 443d8ec: feat(embedding-model-v2): add response body field
9
+ - fd65bc6: chore(embedding-model-v2): rename rawResponse to response
10
+ - Updated dependencies [26735b5]
11
+ - Updated dependencies [443d8ec]
12
+ - Updated dependencies [14c9410]
13
+ - Updated dependencies [d9c98f4]
14
+ - Updated dependencies [c4a2fec]
15
+ - Updated dependencies [0054544]
16
+ - Updated dependencies [9e9c809]
17
+ - Updated dependencies [32831c6]
18
+ - Updated dependencies [d0f9495]
19
+ - Updated dependencies [fd65bc6]
20
+ - Updated dependencies [393138b]
21
+ - Updated dependencies [7182d14]
22
+ - @ai-sdk/provider@2.0.0-canary.6
23
+ - @ai-sdk/provider-utils@3.0.0-canary.7
24
+
25
+ ## 2.0.0-canary.6
26
+
27
+ ### Patch Changes
28
+
29
+ - 948b755: chore(providers/openai): convert to providerOptions
30
+ - 3b1ea10: adding support for gpt-4o-search-preview and handling unsupported parameters
31
+ - 442be08: fix: propagate openai transcription fixes
32
+ - 5147e6e: chore(openai): remove simulateStreaming
33
+ - c2b92cc: chore(openai): remove legacy function calling
34
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
35
+ - Updated dependencies [411e483]
36
+ - Updated dependencies [79457bd]
37
+ - Updated dependencies [ad80501]
38
+ - Updated dependencies [1766ede]
39
+ - Updated dependencies [f10304b]
40
+ - @ai-sdk/provider@2.0.0-canary.5
41
+ - @ai-sdk/provider-utils@3.0.0-canary.6
42
+
3
43
  ## 2.0.0-canary.5
4
44
 
5
45
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,63 +1,15 @@
1
- import { LanguageModelV2, ProviderV2, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
1
+ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
5
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
6
6
  interface OpenAIChatSettings {
7
7
  /**
8
- Modify the likelihood of specified tokens appearing in the completion.
9
-
10
- Accepts a JSON object that maps tokens (specified by their token ID in
11
- the GPT tokenizer) to an associated bias value from -100 to 100. You
12
- can use this tokenizer tool to convert text to token IDs. Mathematically,
13
- the bias is added to the logits generated by the model prior to sampling.
14
- The exact effect will vary per model, but values between -1 and 1 should
15
- decrease or increase likelihood of selection; values like -100 or 100
16
- should result in a ban or exclusive selection of the relevant token.
17
-
18
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
19
- token from being generated.
20
- */
21
- logitBias?: Record<number, number>;
22
- /**
23
- Return the log probabilities of the tokens. Including logprobs will increase
24
- the response size and can slow down response times. However, it can
25
- be useful to better understand how the model is behaving.
26
-
27
- Setting to true will return the log probabilities of the tokens that
28
- were generated.
29
-
30
- Setting to a number will return the log probabilities of the top n
31
- tokens that were generated.
32
- */
33
- logprobs?: boolean | number;
34
- /**
35
- Whether to enable parallel function calling during tool use. Default to true.
36
- */
37
- parallelToolCalls?: boolean;
38
- /**
39
8
  Whether to use structured outputs. Defaults to false.
40
9
 
41
10
  When enabled, tool calls and object generation will be strict and follow the provided schema.
42
- */
43
- structuredOutputs?: boolean;
44
- /**
45
- Whether to use legacy function calling. Defaults to false.
46
-
47
- Required by some open source inference engines which do not support the `tools` API. May also
48
- provide a workaround for `parallelToolCalls` resulting in the provider buffering tool calls,
49
- which causes `streamObject` to be non-streaming.
50
-
51
- Prefer setting `parallelToolCalls: false` over this option.
52
-
53
- @deprecated this API is supported but deprecated by OpenAI.
54
- */
55
- useLegacyFunctionCalling?: boolean;
56
- /**
57
- A unique identifier representing your end-user, which can help OpenAI to
58
- monitor and detect abuse. Learn more.
59
11
  */
60
- user?: string;
12
+ structuredOutputs?: boolean;
61
13
  /**
62
14
  Automatically download images and pass the image as data to the model.
63
15
  OpenAI supports image URLs for public models, so this is only needed for
@@ -66,19 +18,6 @@ interface OpenAIChatSettings {
66
18
  Defaults to `false`.
67
19
  */
68
20
  downloadImages?: boolean;
69
- /**
70
- Simulates streaming by using a normal generate call and returning it as a stream.
71
- Enable this if the model that you are using does not support streaming.
72
-
73
- Defaults to `false`.
74
-
75
- @deprecated Use `simulateStreamingMiddleware` instead.
76
- */
77
- simulateStreaming?: boolean;
78
- /**
79
- Reasoning effort for reasoning models. Defaults to `medium`.
80
- */
81
- reasoningEffort?: 'low' | 'medium' | 'high';
82
21
  }
83
22
 
84
23
  type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
@@ -226,17 +165,17 @@ interface OpenAIProvider extends ProviderV2 {
226
165
  /**
227
166
  Creates a model for text embeddings.
228
167
  */
229
- embedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
168
+ embedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
230
169
  /**
231
170
  Creates a model for text embeddings.
232
171
 
233
172
  @deprecated Use `textEmbeddingModel` instead.
234
173
  */
235
- textEmbedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
174
+ textEmbedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
236
175
  /**
237
176
  Creates a model for text embeddings.
238
177
  */
239
- textEmbeddingModel(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
178
+ textEmbeddingModel(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
240
179
  /**
241
180
  Creates a model for image generation.
242
181
  */
@@ -311,19 +250,19 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
311
250
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
312
251
  }, "strip", z.ZodTypeAny, {
313
252
  user?: string | null | undefined;
253
+ parallelToolCalls?: boolean | null | undefined;
254
+ reasoningEffort?: string | null | undefined;
314
255
  store?: boolean | null | undefined;
315
256
  metadata?: any;
316
- reasoningEffort?: string | null | undefined;
317
- parallelToolCalls?: boolean | null | undefined;
318
257
  previousResponseId?: string | null | undefined;
319
258
  strictSchemas?: boolean | null | undefined;
320
259
  instructions?: string | null | undefined;
321
260
  }, {
322
261
  user?: string | null | undefined;
262
+ parallelToolCalls?: boolean | null | undefined;
263
+ reasoningEffort?: string | null | undefined;
323
264
  store?: boolean | null | undefined;
324
265
  metadata?: any;
325
- reasoningEffort?: string | null | undefined;
326
- parallelToolCalls?: boolean | null | undefined;
327
266
  previousResponseId?: string | null | undefined;
328
267
  strictSchemas?: boolean | null | undefined;
329
268
  instructions?: string | null | undefined;
package/dist/index.d.ts CHANGED
@@ -1,63 +1,15 @@
1
- import { LanguageModelV2, ProviderV2, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
1
+ import { LanguageModelV2, ProviderV2, EmbeddingModelV2, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
5
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
6
6
  interface OpenAIChatSettings {
7
7
  /**
8
- Modify the likelihood of specified tokens appearing in the completion.
9
-
10
- Accepts a JSON object that maps tokens (specified by their token ID in
11
- the GPT tokenizer) to an associated bias value from -100 to 100. You
12
- can use this tokenizer tool to convert text to token IDs. Mathematically,
13
- the bias is added to the logits generated by the model prior to sampling.
14
- The exact effect will vary per model, but values between -1 and 1 should
15
- decrease or increase likelihood of selection; values like -100 or 100
16
- should result in a ban or exclusive selection of the relevant token.
17
-
18
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
19
- token from being generated.
20
- */
21
- logitBias?: Record<number, number>;
22
- /**
23
- Return the log probabilities of the tokens. Including logprobs will increase
24
- the response size and can slow down response times. However, it can
25
- be useful to better understand how the model is behaving.
26
-
27
- Setting to true will return the log probabilities of the tokens that
28
- were generated.
29
-
30
- Setting to a number will return the log probabilities of the top n
31
- tokens that were generated.
32
- */
33
- logprobs?: boolean | number;
34
- /**
35
- Whether to enable parallel function calling during tool use. Default to true.
36
- */
37
- parallelToolCalls?: boolean;
38
- /**
39
8
  Whether to use structured outputs. Defaults to false.
40
9
 
41
10
  When enabled, tool calls and object generation will be strict and follow the provided schema.
42
- */
43
- structuredOutputs?: boolean;
44
- /**
45
- Whether to use legacy function calling. Defaults to false.
46
-
47
- Required by some open source inference engines which do not support the `tools` API. May also
48
- provide a workaround for `parallelToolCalls` resulting in the provider buffering tool calls,
49
- which causes `streamObject` to be non-streaming.
50
-
51
- Prefer setting `parallelToolCalls: false` over this option.
52
-
53
- @deprecated this API is supported but deprecated by OpenAI.
54
- */
55
- useLegacyFunctionCalling?: boolean;
56
- /**
57
- A unique identifier representing your end-user, which can help OpenAI to
58
- monitor and detect abuse. Learn more.
59
11
  */
60
- user?: string;
12
+ structuredOutputs?: boolean;
61
13
  /**
62
14
  Automatically download images and pass the image as data to the model.
63
15
  OpenAI supports image URLs for public models, so this is only needed for
@@ -66,19 +18,6 @@ interface OpenAIChatSettings {
66
18
  Defaults to `false`.
67
19
  */
68
20
  downloadImages?: boolean;
69
- /**
70
- Simulates streaming by using a normal generate call and returning it as a stream.
71
- Enable this if the model that you are using does not support streaming.
72
-
73
- Defaults to `false`.
74
-
75
- @deprecated Use `simulateStreamingMiddleware` instead.
76
- */
77
- simulateStreaming?: boolean;
78
- /**
79
- Reasoning effort for reasoning models. Defaults to `medium`.
80
- */
81
- reasoningEffort?: 'low' | 'medium' | 'high';
82
21
  }
83
22
 
84
23
  type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
@@ -226,17 +165,17 @@ interface OpenAIProvider extends ProviderV2 {
226
165
  /**
227
166
  Creates a model for text embeddings.
228
167
  */
229
- embedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
168
+ embedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
230
169
  /**
231
170
  Creates a model for text embeddings.
232
171
 
233
172
  @deprecated Use `textEmbeddingModel` instead.
234
173
  */
235
- textEmbedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
174
+ textEmbedding(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
236
175
  /**
237
176
  Creates a model for text embeddings.
238
177
  */
239
- textEmbeddingModel(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
178
+ textEmbeddingModel(modelId: OpenAIEmbeddingModelId, settings?: OpenAIEmbeddingSettings): EmbeddingModelV2<string>;
240
179
  /**
241
180
  Creates a model for image generation.
242
181
  */
@@ -311,19 +250,19 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
311
250
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
312
251
  }, "strip", z.ZodTypeAny, {
313
252
  user?: string | null | undefined;
253
+ parallelToolCalls?: boolean | null | undefined;
254
+ reasoningEffort?: string | null | undefined;
314
255
  store?: boolean | null | undefined;
315
256
  metadata?: any;
316
- reasoningEffort?: string | null | undefined;
317
- parallelToolCalls?: boolean | null | undefined;
318
257
  previousResponseId?: string | null | undefined;
319
258
  strictSchemas?: boolean | null | undefined;
320
259
  instructions?: string | null | undefined;
321
260
  }, {
322
261
  user?: string | null | undefined;
262
+ parallelToolCalls?: boolean | null | undefined;
263
+ reasoningEffort?: string | null | undefined;
323
264
  store?: boolean | null | undefined;
324
265
  metadata?: any;
325
- reasoningEffort?: string | null | undefined;
326
- parallelToolCalls?: boolean | null | undefined;
327
266
  previousResponseId?: string | null | undefined;
328
267
  strictSchemas?: boolean | null | undefined;
329
268
  instructions?: string | null | undefined;