@ai-sdk/openai-compatible 3.0.0-beta.17 → 3.0.0-beta.19

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.
@@ -26,7 +26,11 @@ import {
26
26
  ResponseHandler,
27
27
  } from '@ai-sdk/provider-utils';
28
28
  import { z } from 'zod/v4';
29
- import { resolveProviderOptionsKey, toCamelCase } from '../utils/to-camel-case';
29
+ import {
30
+ resolveProviderOptionsKey,
31
+ toCamelCase,
32
+ warnIfDeprecatedProviderOptionsKey,
33
+ } from '../utils/to-camel-case';
30
34
  import {
31
35
  defaultOpenAICompatibleErrorStructure,
32
36
  ProviderErrorStructure,
@@ -140,11 +144,19 @@ export class OpenAICompatibleChatLanguageModel implements LanguageModelV4 {
140
144
 
141
145
  if (deprecatedOptions != null) {
142
146
  warnings.push({
143
- type: 'other',
144
- message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`,
147
+ type: 'deprecated',
148
+ setting: "providerOptions key 'openai-compatible'",
149
+ message: "Use 'openaiCompatible' instead.",
145
150
  });
146
151
  }
147
152
 
153
+ // Warn when the raw (non-camelCase) provider name is used
154
+ warnIfDeprecatedProviderOptionsKey({
155
+ rawName: this.providerOptionsName,
156
+ providerOptions,
157
+ warnings,
158
+ });
159
+
148
160
  const compatibleOptions = Object.assign(
149
161
  deprecatedOptions ?? {},
150
162
  (await parseProviderOptions({
@@ -21,7 +21,10 @@ import {
21
21
  ResponseHandler,
22
22
  } from '@ai-sdk/provider-utils';
23
23
  import { z } from 'zod/v4';
24
- import { toCamelCase } from '../utils/to-camel-case';
24
+ import {
25
+ toCamelCase,
26
+ warnIfDeprecatedProviderOptionsKey,
27
+ } from '../utils/to-camel-case';
25
28
  import {
26
29
  defaultOpenAICompatibleErrorStructure,
27
30
  ProviderErrorStructure,
@@ -102,6 +105,13 @@ export class OpenAICompatibleCompletionLanguageModel implements LanguageModelV4
102
105
  }: LanguageModelV4CallOptions) {
103
106
  const warnings: SharedV4Warning[] = [];
104
107
 
108
+ // Warn when the raw (non-camelCase) provider name is used
109
+ warnIfDeprecatedProviderOptionsKey({
110
+ rawName: this.providerOptionsName,
111
+ providerOptions,
112
+ warnings,
113
+ });
114
+
105
115
  // Parse provider options (support both raw and camelCase keys)
106
116
  const completionOptions = Object.assign(
107
117
  (await parseProviderOptions({
@@ -20,6 +20,7 @@ import {
20
20
  defaultOpenAICompatibleErrorStructure,
21
21
  ProviderErrorStructure,
22
22
  } from '../openai-compatible-error';
23
+ import { warnIfDeprecatedProviderOptionsKey } from '../utils/to-camel-case';
23
24
 
24
25
  type OpenAICompatibleEmbeddingConfig = {
25
26
  /**
@@ -88,11 +89,19 @@ export class OpenAICompatibleEmbeddingModel implements EmbeddingModelV4 {
88
89
 
89
90
  if (deprecatedOptions != null) {
90
91
  warnings.push({
91
- type: 'other',
92
- message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`,
92
+ type: 'deprecated',
93
+ setting: "providerOptions key 'openai-compatible'",
94
+ message: "Use 'openaiCompatible' instead.",
93
95
  });
94
96
  }
95
97
 
98
+ // Warn when the raw (non-camelCase) provider name is used
99
+ warnIfDeprecatedProviderOptionsKey({
100
+ rawName: this.providerOptionsName,
101
+ providerOptions,
102
+ warnings,
103
+ });
104
+
96
105
  const compatibleOptions = Object.assign(
97
106
  deprecatedOptions ?? {},
98
107
  (await parseProviderOptions({
@@ -4,7 +4,10 @@ import {
4
4
  SharedV4ProviderOptions,
5
5
  SharedV4Warning,
6
6
  } from '@ai-sdk/provider';
7
- import { toCamelCase } from '../utils/to-camel-case';
7
+ import {
8
+ toCamelCase,
9
+ warnIfDeprecatedProviderOptionsKey,
10
+ } from '../utils/to-camel-case';
8
11
  import {
9
12
  combineHeaders,
10
13
  convertBase64ToUint8Array,
@@ -54,10 +57,15 @@ export class OpenAICompatibleImageModel implements ImageModelV4 {
54
57
  private readonly config: OpenAICompatibleImageModelConfig,
55
58
  ) {}
56
59
 
57
- // TODO: deprecate non-camelCase keys and remove in future major version
58
60
  private getArgs(
59
61
  providerOptions: SharedV4ProviderOptions,
62
+ warnings: SharedV4Warning[],
60
63
  ): Record<string, unknown> {
64
+ warnIfDeprecatedProviderOptionsKey({
65
+ rawName: this.providerOptionsKey,
66
+ providerOptions,
67
+ warnings,
68
+ });
61
69
  return {
62
70
  ...providerOptions[this.providerOptionsKey],
63
71
  ...providerOptions[toCamelCase(this.providerOptionsKey)],
@@ -95,7 +103,7 @@ export class OpenAICompatibleImageModel implements ImageModelV4 {
95
103
 
96
104
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
97
105
 
98
- const args = this.getArgs(providerOptions);
106
+ const args = this.getArgs(providerOptions, warnings);
99
107
 
100
108
  // Image editing mode - use form data and /images/edits endpoint
101
109
  if (files != null && files.length > 0) {
@@ -1,3 +1,5 @@
1
+ import { SharedV4Warning } from '@ai-sdk/provider';
2
+
1
3
  export function toCamelCase(str: string): string {
2
4
  return str.replace(/[_-]([a-z])/g, g => g[1].toUpperCase());
3
5
  }
@@ -17,3 +19,25 @@ export function resolveProviderOptionsKey(
17
19
  }
18
20
  return rawName;
19
21
  }
22
+
23
+ /**
24
+ Pushes a deprecation warning when the user supplies providerOptions under a non-camelCase key
25
+ */
26
+ export function warnIfDeprecatedProviderOptionsKey({
27
+ rawName,
28
+ providerOptions,
29
+ warnings,
30
+ }: {
31
+ rawName: string;
32
+ providerOptions: Record<string, unknown> | undefined;
33
+ warnings: SharedV4Warning[];
34
+ }): void {
35
+ const camelName = toCamelCase(rawName);
36
+ if (camelName !== rawName && providerOptions?.[rawName] != null) {
37
+ warnings.push({
38
+ type: 'deprecated',
39
+ setting: `providerOptions key '${rawName}'`,
40
+ message: `Use '${camelName}' instead.`,
41
+ });
42
+ }
43
+ }