@ai-sdk/openai-compatible 1.0.0-beta.1 → 1.0.0-beta.11

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,78 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 1.0.0-beta.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [dd5fd43]
8
+ - @ai-sdk/provider-utils@3.0.0-beta.8
9
+
10
+ ## 1.0.0-beta.10
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [e7fcc86]
15
+ - @ai-sdk/provider-utils@3.0.0-beta.7
16
+
17
+ ## 1.0.0-beta.9
18
+
19
+ ### Patch Changes
20
+
21
+ - 737f1e2: Add (optional) includeUsage option to createOpenAICompatible
22
+ - Updated dependencies [ac34802]
23
+ - @ai-sdk/provider-utils@3.0.0-beta.6
24
+
25
+ ## 1.0.0-beta.8
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [57edfcb]
30
+ - Updated dependencies [383cbfa]
31
+ - @ai-sdk/provider-utils@3.0.0-beta.5
32
+
33
+ ## 1.0.0-beta.7
34
+
35
+ ### Patch Changes
36
+
37
+ - 205077b: fix: improve Zod compatibility
38
+ - Updated dependencies [205077b]
39
+ - @ai-sdk/provider-utils@3.0.0-beta.4
40
+
41
+ ## 1.0.0-beta.6
42
+
43
+ ### Patch Changes
44
+
45
+ - 281bb1c: fix (provider/openai-incompatible): support empty tool calls
46
+
47
+ ## 1.0.0-beta.5
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [05d2819]
52
+ - @ai-sdk/provider-utils@3.0.0-beta.3
53
+
54
+ ## 1.0.0-beta.4
55
+
56
+ ### Patch Changes
57
+
58
+ - 1b101e1: feat (provider/openai-compatible): allow providers that do not specify function type
59
+
60
+ ## 1.0.0-beta.3
61
+
62
+ ### Patch Changes
63
+
64
+ - 7b069ed: allow any string as reasoningEffort
65
+
66
+ ## 1.0.0-beta.2
67
+
68
+ ### Patch Changes
69
+
70
+ - d1a034f: feature: using Zod 4 for internal stuff
71
+ - Updated dependencies [0571b98]
72
+ - Updated dependencies [39a4fab]
73
+ - Updated dependencies [d1a034f]
74
+ - @ai-sdk/provider-utils@3.0.0-beta.2
75
+
3
76
  ## 1.0.0-beta.1
4
77
 
5
78
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,25 +1,12 @@
1
1
  import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z, ZodSchema } from 'zod';
3
+ import { z, ZodType } from 'zod/v4';
4
4
 
5
5
  type OpenAICompatibleChatModelId = string;
6
6
  declare const openaiCompatibleProviderOptions: z.ZodObject<{
7
- /**
8
- * A unique identifier representing your end-user, which can help the provider to
9
- * monitor and detect abuse.
10
- */
11
7
  user: z.ZodOptional<z.ZodString>;
12
- /**
13
- * Reasoning effort for reasoning models. Defaults to `medium`.
14
- */
15
- reasoningEffort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
16
- }, "strip", z.ZodTypeAny, {
17
- user?: string | undefined;
18
- reasoningEffort?: "low" | "medium" | "high" | undefined;
19
- }, {
20
- user?: string | undefined;
21
- reasoningEffort?: "low" | "medium" | "high" | undefined;
22
- }>;
8
+ reasoningEffort: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>;
23
10
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
24
11
 
25
12
  declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
@@ -27,36 +14,12 @@ declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
27
14
  message: z.ZodString;
28
15
  type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
16
  param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
30
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
31
- }, "strip", z.ZodTypeAny, {
32
- message: string;
33
- type?: string | null | undefined;
34
- code?: string | number | null | undefined;
35
- param?: any;
36
- }, {
37
- message: string;
38
- type?: string | null | undefined;
39
- code?: string | number | null | undefined;
40
- param?: any;
41
- }>;
42
- }, "strip", z.ZodTypeAny, {
43
- error: {
44
- message: string;
45
- type?: string | null | undefined;
46
- code?: string | number | null | undefined;
47
- param?: any;
48
- };
49
- }, {
50
- error: {
51
- message: string;
52
- type?: string | null | undefined;
53
- code?: string | number | null | undefined;
54
- param?: any;
55
- };
56
- }>;
17
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
18
+ }, z.core.$strip>;
19
+ }, z.core.$strip>;
57
20
  type OpenAICompatibleErrorData = z.infer<typeof openaiCompatibleErrorDataSchema>;
58
21
  type ProviderErrorStructure<T> = {
59
- errorSchema: ZodSchema<T>;
22
+ errorSchema: ZodType<T>;
60
23
  errorToMessage: (error: T) => string;
61
24
  isRetryable?: (response: Response, error?: T) => boolean;
62
25
  };
@@ -142,37 +105,11 @@ declare class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
142
105
 
143
106
  type OpenAICompatibleCompletionModelId = string;
144
107
  declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
145
- /**
146
- * Echo back the prompt in addition to the completion.
147
- */
148
108
  echo: z.ZodOptional<z.ZodBoolean>;
149
- /**
150
- * Modify the likelihood of specified tokens appearing in the completion.
151
- *
152
- * Accepts a JSON object that maps tokens (specified by their token ID in
153
- * the GPT tokenizer) to an associated bias value from -100 to 100.
154
- */
155
109
  logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
156
- /**
157
- * The suffix that comes after a completion of inserted text.
158
- */
159
110
  suffix: z.ZodOptional<z.ZodString>;
160
- /**
161
- * A unique identifier representing your end-user, which can help providers to
162
- * monitor and detect abuse.
163
- */
164
111
  user: z.ZodOptional<z.ZodString>;
165
- }, "strip", z.ZodTypeAny, {
166
- user?: string | undefined;
167
- echo?: boolean | undefined;
168
- logitBias?: Record<string, number> | undefined;
169
- suffix?: string | undefined;
170
- }, {
171
- user?: string | undefined;
172
- echo?: boolean | undefined;
173
- logitBias?: Record<string, number> | undefined;
174
- suffix?: string | undefined;
175
- }>;
112
+ }, z.core.$strip>;
176
113
  type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
177
114
 
178
115
  type OpenAICompatibleCompletionConfig = {
@@ -207,23 +144,9 @@ declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV2
207
144
 
208
145
  type OpenAICompatibleEmbeddingModelId = string;
209
146
  declare const openaiCompatibleEmbeddingProviderOptions: z.ZodObject<{
210
- /**
211
- * The number of dimensions the resulting output embeddings should have.
212
- * Only supported in text-embedding-3 and later models.
213
- */
214
147
  dimensions: z.ZodOptional<z.ZodNumber>;
215
- /**
216
- * A unique identifier representing your end-user, which can help providers to
217
- * monitor and detect abuse.
218
- */
219
148
  user: z.ZodOptional<z.ZodString>;
220
- }, "strip", z.ZodTypeAny, {
221
- user?: string | undefined;
222
- dimensions?: number | undefined;
223
- }, {
224
- user?: string | undefined;
225
- dimensions?: number | undefined;
226
- }>;
149
+ }, z.core.$strip>;
227
150
  type OpenAICompatibleEmbeddingProviderOptions = z.infer<typeof openaiCompatibleEmbeddingProviderOptions>;
228
151
 
229
152
  type OpenAICompatibleEmbeddingConfig = {
@@ -318,6 +241,10 @@ interface OpenAICompatibleProviderSettings {
318
241
  or to provide a custom fetch implementation for e.g. testing.
319
242
  */
320
243
  fetch?: FetchFunction;
244
+ /**
245
+ Include usage information in streaming responses.
246
+ */
247
+ includeUsage?: boolean;
321
248
  }
322
249
  /**
323
250
  Create an OpenAICompatible provider instance.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,12 @@
1
1
  import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z, ZodSchema } from 'zod';
3
+ import { z, ZodType } from 'zod/v4';
4
4
 
5
5
  type OpenAICompatibleChatModelId = string;
6
6
  declare const openaiCompatibleProviderOptions: z.ZodObject<{
7
- /**
8
- * A unique identifier representing your end-user, which can help the provider to
9
- * monitor and detect abuse.
10
- */
11
7
  user: z.ZodOptional<z.ZodString>;
12
- /**
13
- * Reasoning effort for reasoning models. Defaults to `medium`.
14
- */
15
- reasoningEffort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
16
- }, "strip", z.ZodTypeAny, {
17
- user?: string | undefined;
18
- reasoningEffort?: "low" | "medium" | "high" | undefined;
19
- }, {
20
- user?: string | undefined;
21
- reasoningEffort?: "low" | "medium" | "high" | undefined;
22
- }>;
8
+ reasoningEffort: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>;
23
10
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
24
11
 
25
12
  declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
@@ -27,36 +14,12 @@ declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
27
14
  message: z.ZodString;
28
15
  type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
16
  param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
30
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
31
- }, "strip", z.ZodTypeAny, {
32
- message: string;
33
- type?: string | null | undefined;
34
- code?: string | number | null | undefined;
35
- param?: any;
36
- }, {
37
- message: string;
38
- type?: string | null | undefined;
39
- code?: string | number | null | undefined;
40
- param?: any;
41
- }>;
42
- }, "strip", z.ZodTypeAny, {
43
- error: {
44
- message: string;
45
- type?: string | null | undefined;
46
- code?: string | number | null | undefined;
47
- param?: any;
48
- };
49
- }, {
50
- error: {
51
- message: string;
52
- type?: string | null | undefined;
53
- code?: string | number | null | undefined;
54
- param?: any;
55
- };
56
- }>;
17
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
18
+ }, z.core.$strip>;
19
+ }, z.core.$strip>;
57
20
  type OpenAICompatibleErrorData = z.infer<typeof openaiCompatibleErrorDataSchema>;
58
21
  type ProviderErrorStructure<T> = {
59
- errorSchema: ZodSchema<T>;
22
+ errorSchema: ZodType<T>;
60
23
  errorToMessage: (error: T) => string;
61
24
  isRetryable?: (response: Response, error?: T) => boolean;
62
25
  };
@@ -142,37 +105,11 @@ declare class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
142
105
 
143
106
  type OpenAICompatibleCompletionModelId = string;
144
107
  declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
145
- /**
146
- * Echo back the prompt in addition to the completion.
147
- */
148
108
  echo: z.ZodOptional<z.ZodBoolean>;
149
- /**
150
- * Modify the likelihood of specified tokens appearing in the completion.
151
- *
152
- * Accepts a JSON object that maps tokens (specified by their token ID in
153
- * the GPT tokenizer) to an associated bias value from -100 to 100.
154
- */
155
109
  logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
156
- /**
157
- * The suffix that comes after a completion of inserted text.
158
- */
159
110
  suffix: z.ZodOptional<z.ZodString>;
160
- /**
161
- * A unique identifier representing your end-user, which can help providers to
162
- * monitor and detect abuse.
163
- */
164
111
  user: z.ZodOptional<z.ZodString>;
165
- }, "strip", z.ZodTypeAny, {
166
- user?: string | undefined;
167
- echo?: boolean | undefined;
168
- logitBias?: Record<string, number> | undefined;
169
- suffix?: string | undefined;
170
- }, {
171
- user?: string | undefined;
172
- echo?: boolean | undefined;
173
- logitBias?: Record<string, number> | undefined;
174
- suffix?: string | undefined;
175
- }>;
112
+ }, z.core.$strip>;
176
113
  type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
177
114
 
178
115
  type OpenAICompatibleCompletionConfig = {
@@ -207,23 +144,9 @@ declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV2
207
144
 
208
145
  type OpenAICompatibleEmbeddingModelId = string;
209
146
  declare const openaiCompatibleEmbeddingProviderOptions: z.ZodObject<{
210
- /**
211
- * The number of dimensions the resulting output embeddings should have.
212
- * Only supported in text-embedding-3 and later models.
213
- */
214
147
  dimensions: z.ZodOptional<z.ZodNumber>;
215
- /**
216
- * A unique identifier representing your end-user, which can help providers to
217
- * monitor and detect abuse.
218
- */
219
148
  user: z.ZodOptional<z.ZodString>;
220
- }, "strip", z.ZodTypeAny, {
221
- user?: string | undefined;
222
- dimensions?: number | undefined;
223
- }, {
224
- user?: string | undefined;
225
- dimensions?: number | undefined;
226
- }>;
149
+ }, z.core.$strip>;
227
150
  type OpenAICompatibleEmbeddingProviderOptions = z.infer<typeof openaiCompatibleEmbeddingProviderOptions>;
228
151
 
229
152
  type OpenAICompatibleEmbeddingConfig = {
@@ -318,6 +241,10 @@ interface OpenAICompatibleProviderSettings {
318
241
  or to provide a custom fetch implementation for e.g. testing.
319
242
  */
320
243
  fetch?: FetchFunction;
244
+ /**
245
+ Include usage information in streaming responses.
246
+ */
247
+ includeUsage?: boolean;
321
248
  }
322
249
  /**
323
250
  Create an OpenAICompatible provider instance.