@ai-sdk/openai 4.0.83 → 4.0.84
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 +11 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -0
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +10 -10
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +11 -0
- package/src/openai-provider.ts +13 -7
package/docs/03-openai.mdx
CHANGED
|
@@ -3469,18 +3469,18 @@ const result = await generateSpeech({
|
|
|
3469
3469
|
| `tts-1-hd` | <Check /> |
|
|
3470
3470
|
| `gpt-4o-mini-tts` | <Check /> |
|
|
3471
3471
|
|
|
3472
|
-
##
|
|
3472
|
+
## Decision Models
|
|
3473
3473
|
|
|
3474
|
-
Create an experimental
|
|
3474
|
+
Create an experimental decision model with `openai.decisionModel(modelId)`.
|
|
3475
3475
|
It uses the Responses API with structured output to answer Choice, Score, and
|
|
3476
3476
|
Boolean questions. Choose a model that supports structured output, such as `gpt-6-luna`.
|
|
3477
3477
|
|
|
3478
3478
|
```ts
|
|
3479
3479
|
import { openai } from '@ai-sdk/openai';
|
|
3480
|
-
import {
|
|
3480
|
+
import { experimental_decide } from 'ai';
|
|
3481
3481
|
|
|
3482
|
-
const { answers } = await
|
|
3483
|
-
model: openai.
|
|
3482
|
+
const { answers } = await experimental_decide({
|
|
3483
|
+
model: openai.decisionModel('gpt-6-luna'),
|
|
3484
3484
|
state: 'I was charged twice.',
|
|
3485
3485
|
questions: {
|
|
3486
3486
|
requestsRefund: {
|
|
@@ -3506,10 +3506,10 @@ not guaranteed to be calibrated. Apply thresholds in application code, for examp
|
|
|
3506
3506
|
The factory respects `createOpenAI` settings, including custom fetch and base URL.
|
|
3507
3507
|
Pass Responses options through `providerOptions.openai`. Usage, warnings,
|
|
3508
3508
|
response information, and provider metadata are preserved. Refusals, truncated
|
|
3509
|
-
output, or invalid answers fail the entire call. See [
|
|
3509
|
+
output, or invalid answers fail the entire call. See [Decisions](/docs/ai-sdk-core/decisions).
|
|
3510
3510
|
|
|
3511
|
-
|
|
3512
|
-
`createProviderRegistry().
|
|
3511
|
+
Decision models can also be accessed through `customProvider` aliases or
|
|
3512
|
+
`createProviderRegistry().decisionModel('provider:model')`. Direct string IDs
|
|
3513
3513
|
use Gateway by default, or an explicitly configured default provider with an
|
|
3514
|
-
`
|
|
3515
|
-
[model aliases and registries](/docs/ai-sdk-core/
|
|
3514
|
+
`decisionModel` method. See
|
|
3515
|
+
[model aliases and registries](/docs/ai-sdk-core/decisions#model-aliases-and-registries).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.84",
|
|
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.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.22",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.54"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.3",
|
|
@@ -146,6 +146,17 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
|
|
|
146
146
|
warnings.push({ type: 'unsupported', feature: 'topK' });
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
// reasoningSummary is a Responses API option that the chat options schema strips,
|
|
150
|
+
// so check the raw provider options to avoid silently ignoring it:
|
|
151
|
+
if (providerOptions?.openai?.reasoningSummary != null) {
|
|
152
|
+
warnings.push({
|
|
153
|
+
type: 'unsupported',
|
|
154
|
+
feature: 'reasoningSummary',
|
|
155
|
+
details:
|
|
156
|
+
'reasoningSummary is only supported by the Responses API, not the Chat Completions API',
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
149
160
|
const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
|
|
150
161
|
{
|
|
151
162
|
prompt,
|
package/src/openai-provider.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Experimental_BatchV4 as BatchV4,
|
|
3
|
-
|
|
3
|
+
Experimental_DecisionModelV4 as DecisionModelV4,
|
|
4
4
|
EmbeddingModelV4,
|
|
5
5
|
FilesV4,
|
|
6
6
|
ImageModelV4,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
type FetchFunction,
|
|
21
21
|
type WebSocketConstructor,
|
|
22
22
|
} from '@ai-sdk/provider-utils';
|
|
23
|
-
import {
|
|
23
|
+
import { Experimental_DecisionLanguageModel as DecisionLanguageModel } from '@ai-sdk/provider-utils/experimental-decision';
|
|
24
24
|
import { OpenAIChatLanguageModel } from './chat/openai-chat-language-model';
|
|
25
25
|
import type { OpenAIChatModelId } from './chat/openai-chat-language-model-options';
|
|
26
26
|
import { OpenAICompletionLanguageModel } from './completion/openai-completion-language-model';
|
|
@@ -50,8 +50,12 @@ import { VERSION } from './version';
|
|
|
50
50
|
export interface OpenAIProvider extends ProviderV4 {
|
|
51
51
|
(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
52
52
|
|
|
53
|
-
/** Creates an experimental Choice/Score/Boolean
|
|
54
|
-
|
|
53
|
+
/** Creates an experimental Choice/Score/Boolean decision model using the Responses API. */
|
|
54
|
+
decisionModel(modelId: OpenAIResponsesModelId): DecisionModelV4;
|
|
55
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
56
|
+
evaluationModel(modelId: OpenAIResponsesModelId): DecisionModelV4 & {
|
|
57
|
+
doEvaluate: DecisionModelV4['doDecide'];
|
|
58
|
+
};
|
|
55
59
|
|
|
56
60
|
/**
|
|
57
61
|
* Creates an OpenAI model for text generation.
|
|
@@ -352,11 +356,13 @@ export function createOpenAI(
|
|
|
352
356
|
provider.chat = createChatModel;
|
|
353
357
|
provider.completion = createCompletionModel;
|
|
354
358
|
provider.responses = createResponsesModel;
|
|
355
|
-
provider.
|
|
356
|
-
new
|
|
359
|
+
provider.decisionModel = (modelId: OpenAIResponsesModelId) =>
|
|
360
|
+
new DecisionLanguageModel({
|
|
357
361
|
model: createResponsesModel(modelId),
|
|
358
|
-
provider: `${providerName}.
|
|
362
|
+
provider: `${providerName}.decision`,
|
|
359
363
|
});
|
|
364
|
+
provider.evaluationModel =
|
|
365
|
+
provider.decisionModel as OpenAIProvider['evaluationModel'];
|
|
360
366
|
provider.embedding = createEmbeddingModel;
|
|
361
367
|
provider.embeddingModel = createEmbeddingModel;
|
|
362
368
|
provider.textEmbedding = createEmbeddingModel;
|