@ai-sdk/openai 4.0.96 → 4.0.97

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "4.0.96",
3
+ "version": "4.0.97",
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.29",
39
- "@ai-sdk/provider-utils": "5.0.62"
38
+ "@ai-sdk/provider": "4.0.30",
39
+ "@ai-sdk/provider-utils": "5.0.63"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -52,6 +52,8 @@ import { normalizeOpenAIJsonSchema } from '../normalize-openai-json-schema';
52
52
 
53
53
  type OpenAIChatConfig = {
54
54
  provider: string;
55
+ /** Model ID sent to the API. Defaults to the model's reported ID. */
56
+ requestModelId?: string;
55
57
  headers?: () => Record<string, string | undefined>;
56
58
  url: (options: { modelId: string; path: string }) => string;
57
59
  fetch?: FetchFunction;
@@ -182,7 +184,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
182
184
 
183
185
  const baseArgs = {
184
186
  // model id:
185
- model: this.modelId,
187
+ model: this.config.requestModelId ?? this.modelId,
186
188
 
187
189
  // model specific settings:
188
190
  logit_bias: openaiOptions.logitBias,
@@ -404,7 +406,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
404
406
  } = await postJsonToApi({
405
407
  url: this.config.url({
406
408
  path: '/chat/completions',
407
- modelId: this.modelId,
409
+ modelId: this.config.requestModelId ?? this.modelId,
408
410
  }),
409
411
  headers: combineHeaders(this.config.headers?.(), options.headers),
410
412
  body,
@@ -504,7 +506,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
504
506
 
505
507
  const url = this.config.url({
506
508
  path: '/chat/completions',
507
- modelId: this.modelId,
509
+ modelId: this.config.requestModelId ?? this.modelId,
508
510
  });
509
511
 
510
512
  const { responseHeaders, value: response } = await postJsonToApi({
@@ -43,6 +43,8 @@ import {
43
43
  } from './openai-completion-language-model-options';
44
44
  type OpenAICompletionConfig = {
45
45
  provider: string;
46
+ /** Model ID sent to the API. Defaults to the model's reported ID. */
47
+ requestModelId?: string;
46
48
  headers?: () => Record<string, string | undefined>;
47
49
  url: (options: { modelId: string; path: string }) => string;
48
50
  fetch?: FetchFunction;
@@ -148,7 +150,7 @@ export class OpenAICompletionLanguageModel implements LanguageModelV4 {
148
150
  return {
149
151
  args: {
150
152
  // model id:
151
- model: this.modelId,
153
+ model: this.config.requestModelId ?? this.modelId,
152
154
 
153
155
  // model specific settings:
154
156
  echo: openaiOptions.echo,
@@ -192,7 +194,7 @@ export class OpenAICompletionLanguageModel implements LanguageModelV4 {
192
194
  } = await postJsonToApi({
193
195
  url: this.config.url({
194
196
  path: '/completions',
195
- modelId: this.modelId,
197
+ modelId: this.config.requestModelId ?? this.modelId,
196
198
  }),
197
199
  headers: combineHeaders(this.config.headers?.(), options.headers),
198
200
  body: args,
@@ -246,7 +248,7 @@ export class OpenAICompletionLanguageModel implements LanguageModelV4 {
246
248
 
247
249
  const url = this.config.url({
248
250
  path: '/completions',
249
- modelId: this.modelId,
251
+ modelId: this.config.requestModelId ?? this.modelId,
250
252
  });
251
253
 
252
254
  const { responseHeaders, value: response } = await postJsonToApi({
@@ -11,6 +11,8 @@ type SerializedOpenAIConfig = Omit<Partial<OpenAIConfig>, 'headers'> & {
11
11
 
12
12
  export type OpenAIConfig = {
13
13
  provider: string;
14
+ /** Model ID sent to the API. Defaults to the model's reported ID. */
15
+ requestModelId?: string;
14
16
  baseURL?: string;
15
17
  url: (options: { modelId: string; path: string }) => string;
16
18
  headers?: () => OpenAIHeaders;
@@ -180,7 +180,10 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
180
180
  },
181
181
  ],
182
182
  questions: Object.entries(questions).map(([name, question]) => {
183
- const instructions = toText(question.instructions);
183
+ const instructions =
184
+ question.instructions == null
185
+ ? question.instructions
186
+ : toText(question.instructions);
184
187
  switch (question.type) {
185
188
  case 'boolean':
186
189
  return {
@@ -195,7 +198,7 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
195
198
  ? undefined
196
199
  : `Criteria for false:\n${toText(question.criteria.false)}`,
197
200
  ]
198
- .filter(part => part !== undefined)
201
+ .filter(part => part != null)
199
202
  .join('\n\n'),
200
203
  };
201
204
  case 'choice':
@@ -598,7 +598,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
598
598
  }
599
599
 
600
600
  const baseArgs = {
601
- model: modelId,
601
+ model: config.requestModelId ?? modelId,
602
602
  input,
603
603
  temperature,
604
604
  top_p: topP,
@@ -854,7 +854,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
854
854
  } = await this.getArgs(options);
855
855
  const url = this.config.url({
856
856
  path: '/responses',
857
- modelId: this.modelId,
857
+ modelId: this.config.requestModelId ?? this.modelId,
858
858
  });
859
859
 
860
860
  const approvalRequestIdToDummyToolCallIdFromPrompt =
@@ -1547,7 +1547,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1547
1547
 
1548
1548
  const url = this.config.url({
1549
1549
  path: '/responses',
1550
- modelId: this.modelId,
1550
+ modelId: this.config.requestModelId ?? this.modelId,
1551
1551
  });
1552
1552
 
1553
1553
  const { responseHeaders, value: response } = await postJsonToApi({