@ai-sdk/openai 2.0.38 → 2.1.0-beta.0

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/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
1
  // src/openai-provider.ts
2
2
  import {
3
3
  loadApiKey,
4
- withoutTrailingSlash,
5
- withUserAgentSuffix
4
+ withoutTrailingSlash
6
5
  } from "@ai-sdk/provider-utils";
7
6
 
8
7
  // src/chat/openai-chat-language-model.ts
@@ -251,7 +250,7 @@ function mapOpenAIFinishReason(finishReason) {
251
250
 
252
251
  // src/chat/openai-chat-options.ts
253
252
  import { z as z2 } from "zod/v4";
254
- var openaiChatLanguageModelOptions = z2.object({
253
+ var openaiProviderOptions = z2.object({
255
254
  /**
256
255
  * Modify the likelihood of specified tokens appearing in the completion.
257
256
  *
@@ -435,7 +434,7 @@ var OpenAIChatLanguageModel = class {
435
434
  const openaiOptions = (_a = await parseProviderOptions({
436
435
  provider: "openai",
437
436
  providerOptions,
438
- schema: openaiChatLanguageModelOptions
437
+ schema: openaiProviderOptions
439
438
  })) != null ? _a : {};
440
439
  const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
441
440
  if (topK != null) {
@@ -2108,40 +2107,26 @@ async function convertToOpenAIResponsesInput({
2108
2107
  });
2109
2108
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2110
2109
  if (reasoningId != null) {
2111
- const reasoningMessage = reasoningMessages[reasoningId];
2112
- if (store) {
2113
- if (reasoningMessage === void 0) {
2114
- input.push({ type: "item_reference", id: reasoningId });
2115
- reasoningMessages[reasoningId] = {
2116
- type: "reasoning",
2117
- id: reasoningId,
2118
- summary: []
2119
- };
2120
- }
2110
+ const existingReasoningMessage = reasoningMessages[reasoningId];
2111
+ const summaryParts = [];
2112
+ if (part.text.length > 0) {
2113
+ summaryParts.push({ type: "summary_text", text: part.text });
2114
+ } else if (existingReasoningMessage !== void 0) {
2115
+ warnings.push({
2116
+ type: "other",
2117
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
2118
+ });
2119
+ }
2120
+ if (existingReasoningMessage === void 0) {
2121
+ reasoningMessages[reasoningId] = {
2122
+ type: "reasoning",
2123
+ id: reasoningId,
2124
+ encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2125
+ summary: summaryParts
2126
+ };
2127
+ input.push(reasoningMessages[reasoningId]);
2121
2128
  } else {
2122
- const summaryParts = [];
2123
- if (part.text.length > 0) {
2124
- summaryParts.push({
2125
- type: "summary_text",
2126
- text: part.text
2127
- });
2128
- } else if (reasoningMessage !== void 0) {
2129
- warnings.push({
2130
- type: "other",
2131
- message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
2132
- });
2133
- }
2134
- if (reasoningMessage === void 0) {
2135
- reasoningMessages[reasoningId] = {
2136
- type: "reasoning",
2137
- id: reasoningId,
2138
- encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2139
- summary: summaryParts
2140
- };
2141
- input.push(reasoningMessages[reasoningId]);
2142
- } else {
2143
- reasoningMessage.summary.push(...summaryParts);
2144
- }
2129
+ existingReasoningMessage.summary.push(...summaryParts);
2145
2130
  }
2146
2131
  } else {
2147
2132
  warnings.push({
@@ -2695,7 +2680,7 @@ var OpenAIResponsesLanguageModel = class {
2695
2680
  ])
2696
2681
  ),
2697
2682
  service_tier: z15.string().nullish(),
2698
- incomplete_details: z15.object({ reason: z15.string() }).nullish(),
2683
+ incomplete_details: z15.object({ reason: z15.string() }).nullable(),
2699
2684
  usage: usageSchema2
2700
2685
  })
2701
2686
  ),
@@ -3917,27 +3902,21 @@ var openaiTranscriptionResponseSchema = z18.object({
3917
3902
  ).nullish()
3918
3903
  });
3919
3904
 
3920
- // src/version.ts
3921
- var VERSION = true ? "2.0.38" : "0.0.0-test";
3922
-
3923
3905
  // src/openai-provider.ts
3924
3906
  function createOpenAI(options = {}) {
3925
3907
  var _a, _b;
3926
3908
  const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3927
3909
  const providerName = (_b = options.name) != null ? _b : "openai";
3928
- const getHeaders = () => withUserAgentSuffix(
3929
- {
3930
- Authorization: `Bearer ${loadApiKey({
3931
- apiKey: options.apiKey,
3932
- environmentVariableName: "OPENAI_API_KEY",
3933
- description: "OpenAI"
3934
- })}`,
3935
- "OpenAI-Organization": options.organization,
3936
- "OpenAI-Project": options.project,
3937
- ...options.headers
3938
- },
3939
- `ai-sdk/openai/${VERSION}`
3940
- );
3910
+ const getHeaders = () => ({
3911
+ Authorization: `Bearer ${loadApiKey({
3912
+ apiKey: options.apiKey,
3913
+ environmentVariableName: "OPENAI_API_KEY",
3914
+ description: "OpenAI"
3915
+ })}`,
3916
+ "OpenAI-Organization": options.organization,
3917
+ "OpenAI-Project": options.project,
3918
+ ...options.headers
3919
+ });
3941
3920
  const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
3942
3921
  provider: `${providerName}.chat`,
3943
3922
  url: ({ path }) => `${baseURL}${path}`,
@@ -4012,7 +3991,6 @@ function createOpenAI(options = {}) {
4012
3991
  }
4013
3992
  var openai = createOpenAI();
4014
3993
  export {
4015
- VERSION,
4016
3994
  createOpenAI,
4017
3995
  openai
4018
3996
  };