@ai-sdk/openai 4.0.100 → 4.0.102

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,25 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.102
4
+
5
+ ### Patch Changes
6
+
7
+ - 5475347: Fix non-streaming Responses API structured output failing when multiple assistant messages contain JSON. Providers can supply separate structured-output text for parsing, allowing OpenAI and Azure Responses models to select the last `final_answer` while preserving all generated content, annotations, conversation history, and token usage.
8
+ - e729d58: chore(docs): update `README.md` for consistent format and to avoid duplication
9
+ - Updated dependencies [5475347]
10
+ - Updated dependencies [e729d58]
11
+ - @ai-sdk/provider@4.0.34
12
+ - @ai-sdk/provider-utils@5.0.68
13
+
14
+ ## 4.0.101
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [8202f5b]
19
+ - Updated dependencies [85d84a1]
20
+ - @ai-sdk/provider-utils@5.0.67
21
+ - @ai-sdk/provider@4.0.33
22
+
3
23
  ## 4.0.100
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -7,10 +7,8 @@ contains language model support for the OpenAI chat and completion APIs and embe
7
7
 
8
8
  ## Setup
9
9
 
10
- The OpenAI provider is available in the `@ai-sdk/openai` module. You can install it with
11
-
12
10
  ```bash
13
- npm i @ai-sdk/openai
11
+ npm i ai @ai-sdk/openai
14
12
  ```
15
13
 
16
14
  ## Skill for Coding Agents
@@ -21,15 +19,7 @@ If you use coding agents such as Claude Code or Cursor, we highly recommend addi
21
19
  npx skills add vercel/ai
22
20
  ```
23
21
 
24
- ## Provider Instance
25
-
26
- You can import the default provider instance `openai` from `@ai-sdk/openai`:
27
-
28
- ```ts
29
- import { openai } from '@ai-sdk/openai';
30
- ```
31
-
32
- ## Example
22
+ ## Usage
33
23
 
34
24
  ```ts
35
25
  import { openai } from '@ai-sdk/openai';
@@ -41,31 +31,4 @@ const { text } = await generateText({
41
31
  });
42
32
  ```
43
33
 
44
- ## Documentation
45
-
46
- ### Experimental realtime models
47
-
48
- Use the same factory for OpenAI Realtime and Live models:
49
-
50
- ```ts
51
- openai.experimental_realtime('gpt-realtime');
52
- openai.experimental_realtime('gpt-live-1');
53
- openai.experimental_realtime('not-yet-released', { api: 'live' });
54
- ```
55
-
56
- Live supports browser WSS sessions through an application-owned relay and
57
- `experimental_useRealtime`, with client delegation: your application owns the
58
- agent and tools. Optional browser-direct WebRTC is also available. Start with the
59
- [OpenAI provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/openai#realtime-models)
60
- for connection settings, startup options, and event mapping.
61
-
62
- The [`experimental_useRealtime` reference](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-realtime#continuous-conversations)
63
- covers the JSON/PCM16 relay runtime, capture/playback controls, and application-handled
64
- client delegation, plus `api.session` WebRTC setup and server-owned data-channel
65
- permissions. Microphone capture requires browser permission; the application handles
66
- client delegation and submits context on either transport. The
67
- [Realtime guide](https://ai-sdk.dev/docs/ai-sdk-core/realtime) covers legacy token-based,
68
- turn-based sessions.
69
-
70
- Runtime and provider authors can consult the repository's
71
- [realtime integration notes](../../architecture/realtime-provider-integration.md).
34
+ See the [OpenAI Provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/openai) for more information.
package/dist/index.js CHANGED
@@ -6584,6 +6584,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6584
6584
  const retrievedFileIds = /* @__PURE__ */ new Set();
6585
6585
  let hasFunctionCall = false;
6586
6586
  const hostedToolSearchCallIds = [];
6587
+ let structuredOutputText;
6587
6588
  for (const part of response.output) switch (part.type) {
6588
6589
  case "reasoning":
6589
6590
  if (part.summary.length === 0) part.summary.push({
@@ -6684,6 +6685,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6684
6685
  });
6685
6686
  break;
6686
6687
  case "message":
6688
+ if (options.responseFormat?.type === "json" && part.phase === "final_answer") structuredOutputText = part.content.map((contentPart) => contentPart.text).join("");
6687
6689
  for (const contentPart of part.content) {
6688
6690
  if (options.providerOptions?.[providerOptionsName]?.logprobs && contentPart.logprobs) logprobs.push(contentPart.logprobs);
6689
6691
  const providerMetadata = {
@@ -6970,6 +6972,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6970
6972
  const usage = response.usage;
6971
6973
  return {
6972
6974
  content,
6975
+ ...structuredOutputText !== void 0 && { structuredOutputText },
6973
6976
  finishReason: {
6974
6977
  unified: mapOpenAIResponseFinishReason({
6975
6978
  finishReason: response.incomplete_details?.reason,
@@ -10248,7 +10251,7 @@ var OpenAISkills = class {
10248
10251
  };
10249
10252
  //#endregion
10250
10253
  //#region src/version.ts
10251
- const VERSION = "4.0.100";
10254
+ const VERSION = "4.0.102";
10252
10255
  //#endregion
10253
10256
  //#region src/openai-provider.ts
10254
10257
  /**