@ai-sdk/openai 2.0.33 → 2.0.35

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,32 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.35
4
+
5
+ ### Patch Changes
6
+
7
+ - 1cfc209: feat(provider/openai): `OpenAIChatLanguageModelOptions` type
8
+
9
+ ```ts
10
+ import { openai, type OpenAIChatLanguageModelOptions } from '@ai-sdk/openai';
11
+ import { generateText } from 'ai';
12
+
13
+ await generateText({
14
+ model: openai.chat('gpt-4o'),
15
+ prompt: 'Invent a new holiday and describe its traditions.',
16
+ providerOptions: {
17
+ openai: {
18
+ user: 'user-123',
19
+ } satisfies OpenAIChatLanguageModelOptions,
20
+ },
21
+ });
22
+ ```
23
+
24
+ ## 2.0.34
25
+
26
+ ### Patch Changes
27
+
28
+ - 322901b: feat: add provider version to user-agent header
29
+
3
30
  ## 2.0.33
4
31
 
5
32
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,6 +4,37 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import { z } from 'zod/v4';
5
5
 
6
6
  type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | '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' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | (string & {});
7
+ declare const openaiChatLanguageModelOptions: z.ZodObject<{
8
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodCoercedNumber<string>, z.ZodNumber>>;
9
+ logprobs: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber]>>;
10
+ parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
11
+ user: z.ZodOptional<z.ZodString>;
12
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
13
+ minimal: "minimal";
14
+ low: "low";
15
+ medium: "medium";
16
+ high: "high";
17
+ }>>;
18
+ maxCompletionTokens: z.ZodOptional<z.ZodNumber>;
19
+ store: z.ZodOptional<z.ZodBoolean>;
20
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
+ prediction: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
22
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
23
+ serviceTier: z.ZodOptional<z.ZodEnum<{
24
+ auto: "auto";
25
+ flex: "flex";
26
+ priority: "priority";
27
+ }>>;
28
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
29
+ textVerbosity: z.ZodOptional<z.ZodEnum<{
30
+ low: "low";
31
+ medium: "medium";
32
+ high: "high";
33
+ }>>;
34
+ promptCacheKey: z.ZodOptional<z.ZodString>;
35
+ safetyIdentifier: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ type OpenAIChatLanguageModelOptions = z.infer<typeof openaiChatLanguageModelOptions>;
7
38
 
8
39
  type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
9
40
 
@@ -336,4 +367,6 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
336
367
  }, z.core.$strip>;
337
368
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
338
369
 
339
- export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, createOpenAI, openai };
370
+ declare const VERSION: string;
371
+
372
+ export { type OpenAIChatLanguageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,37 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import { z } from 'zod/v4';
5
5
 
6
6
  type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | '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' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | (string & {});
7
+ declare const openaiChatLanguageModelOptions: z.ZodObject<{
8
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodCoercedNumber<string>, z.ZodNumber>>;
9
+ logprobs: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber]>>;
10
+ parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
11
+ user: z.ZodOptional<z.ZodString>;
12
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
13
+ minimal: "minimal";
14
+ low: "low";
15
+ medium: "medium";
16
+ high: "high";
17
+ }>>;
18
+ maxCompletionTokens: z.ZodOptional<z.ZodNumber>;
19
+ store: z.ZodOptional<z.ZodBoolean>;
20
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
+ prediction: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
22
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
23
+ serviceTier: z.ZodOptional<z.ZodEnum<{
24
+ auto: "auto";
25
+ flex: "flex";
26
+ priority: "priority";
27
+ }>>;
28
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
29
+ textVerbosity: z.ZodOptional<z.ZodEnum<{
30
+ low: "low";
31
+ medium: "medium";
32
+ high: "high";
33
+ }>>;
34
+ promptCacheKey: z.ZodOptional<z.ZodString>;
35
+ safetyIdentifier: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ type OpenAIChatLanguageModelOptions = z.infer<typeof openaiChatLanguageModelOptions>;
7
38
 
8
39
  type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
9
40
 
@@ -336,4 +367,6 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
336
367
  }, z.core.$strip>;
337
368
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
338
369
 
339
- export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, createOpenAI, openai };
370
+ declare const VERSION: string;
371
+
372
+ export { type OpenAIChatLanguageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ VERSION: () => VERSION,
23
24
  createOpenAI: () => createOpenAI,
24
25
  openai: () => openai
25
26
  });
@@ -262,7 +263,7 @@ function mapOpenAIFinishReason(finishReason) {
262
263
 
263
264
  // src/chat/openai-chat-options.ts
264
265
  var import_v42 = require("zod/v4");
265
- var openaiProviderOptions = import_v42.z.object({
266
+ var openaiChatLanguageModelOptions = import_v42.z.object({
266
267
  /**
267
268
  * Modify the likelihood of specified tokens appearing in the completion.
268
269
  *
@@ -444,7 +445,7 @@ var OpenAIChatLanguageModel = class {
444
445
  const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
445
446
  provider: "openai",
446
447
  providerOptions,
447
- schema: openaiProviderOptions
448
+ schema: openaiChatLanguageModelOptions
448
449
  })) != null ? _a : {};
449
450
  const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
450
451
  if (topK != null) {
@@ -3867,21 +3868,27 @@ var openaiTranscriptionResponseSchema = import_v418.z.object({
3867
3868
  ).nullish()
3868
3869
  });
3869
3870
 
3871
+ // src/version.ts
3872
+ var VERSION = true ? "2.0.35" : "0.0.0-test";
3873
+
3870
3874
  // src/openai-provider.ts
3871
3875
  function createOpenAI(options = {}) {
3872
3876
  var _a, _b;
3873
3877
  const baseURL = (_a = (0, import_provider_utils16.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3874
3878
  const providerName = (_b = options.name) != null ? _b : "openai";
3875
- const getHeaders = () => ({
3876
- Authorization: `Bearer ${(0, import_provider_utils16.loadApiKey)({
3877
- apiKey: options.apiKey,
3878
- environmentVariableName: "OPENAI_API_KEY",
3879
- description: "OpenAI"
3880
- })}`,
3881
- "OpenAI-Organization": options.organization,
3882
- "OpenAI-Project": options.project,
3883
- ...options.headers
3884
- });
3879
+ const getHeaders = () => (0, import_provider_utils16.withUserAgentSuffix)(
3880
+ {
3881
+ Authorization: `Bearer ${(0, import_provider_utils16.loadApiKey)({
3882
+ apiKey: options.apiKey,
3883
+ environmentVariableName: "OPENAI_API_KEY",
3884
+ description: "OpenAI"
3885
+ })}`,
3886
+ "OpenAI-Organization": options.organization,
3887
+ "OpenAI-Project": options.project,
3888
+ ...options.headers
3889
+ },
3890
+ `ai-sdk/openai/${VERSION}`
3891
+ );
3885
3892
  const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
3886
3893
  provider: `${providerName}.chat`,
3887
3894
  url: ({ path }) => `${baseURL}${path}`,
@@ -3957,6 +3964,7 @@ function createOpenAI(options = {}) {
3957
3964
  var openai = createOpenAI();
3958
3965
  // Annotate the CommonJS export names for ESM import in node:
3959
3966
  0 && (module.exports = {
3967
+ VERSION,
3960
3968
  createOpenAI,
3961
3969
  openai
3962
3970
  });