@ai-sdk/openai-compatible 1.0.0-canary.1 → 1.0.0-canary.10

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,108 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 1.0.0-canary.10
4
+
5
+ ### Patch Changes
6
+
7
+ - cf8280e: fix(providers/xai): return actual usage when streaming instead of NaN
8
+ - Updated dependencies [e86be6f]
9
+ - @ai-sdk/provider@2.0.0-canary.9
10
+ - @ai-sdk/provider-utils@3.0.0-canary.10
11
+
12
+ ## 1.0.0-canary.9
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [95857aa]
17
+ - Updated dependencies [7ea4132]
18
+ - @ai-sdk/provider@2.0.0-canary.8
19
+ - @ai-sdk/provider-utils@3.0.0-canary.9
20
+
21
+ ## 1.0.0-canary.8
22
+
23
+ ### Patch Changes
24
+
25
+ - b9a6121: fix (provider/openai-compatible): change tool_call type schema to nullish
26
+ - Updated dependencies [5d142ab]
27
+ - Updated dependencies [b6b43c7]
28
+ - Updated dependencies [8aa9e20]
29
+ - Updated dependencies [3795467]
30
+ - @ai-sdk/provider-utils@3.0.0-canary.8
31
+ - @ai-sdk/provider@2.0.0-canary.7
32
+
33
+ ## 1.0.0-canary.7
34
+
35
+ ### Patch Changes
36
+
37
+ - fa49207: feat(providers/openai-compatible): convert to providerOptions
38
+ - 26735b5: chore(embedding-model): add v2 interface
39
+ - 443d8ec: feat(embedding-model-v2): add response body field
40
+ - fd65bc6: chore(embedding-model-v2): rename rawResponse to response
41
+ - Updated dependencies [26735b5]
42
+ - Updated dependencies [443d8ec]
43
+ - Updated dependencies [14c9410]
44
+ - Updated dependencies [d9c98f4]
45
+ - Updated dependencies [c4a2fec]
46
+ - Updated dependencies [0054544]
47
+ - Updated dependencies [9e9c809]
48
+ - Updated dependencies [32831c6]
49
+ - Updated dependencies [d0f9495]
50
+ - Updated dependencies [fd65bc6]
51
+ - Updated dependencies [393138b]
52
+ - Updated dependencies [7182d14]
53
+ - @ai-sdk/provider@2.0.0-canary.6
54
+ - @ai-sdk/provider-utils@3.0.0-canary.7
55
+
56
+ ## 1.0.0-canary.6
57
+
58
+ ### Patch Changes
59
+
60
+ - 6db02c9: chore(openai-compatible): remove simulateStreaming
61
+ - Updated dependencies [411e483]
62
+ - Updated dependencies [79457bd]
63
+ - Updated dependencies [ad80501]
64
+ - Updated dependencies [1766ede]
65
+ - Updated dependencies [f10304b]
66
+ - @ai-sdk/provider@2.0.0-canary.5
67
+ - @ai-sdk/provider-utils@3.0.0-canary.6
68
+
69
+ ## 1.0.0-canary.5
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [6f6bb89]
74
+ - @ai-sdk/provider@2.0.0-canary.4
75
+ - @ai-sdk/provider-utils@3.0.0-canary.5
76
+
77
+ ## 1.0.0-canary.4
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies [d1a1aa1]
82
+ - @ai-sdk/provider@2.0.0-canary.3
83
+ - @ai-sdk/provider-utils@3.0.0-canary.4
84
+
85
+ ## 1.0.0-canary.3
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [a166433]
90
+ - Updated dependencies [abf9a79]
91
+ - Updated dependencies [9f95b35]
92
+ - Updated dependencies [0a87932]
93
+ - Updated dependencies [6dc848c]
94
+ - @ai-sdk/provider-utils@3.0.0-canary.3
95
+ - @ai-sdk/provider@2.0.0-canary.2
96
+
97
+ ## 1.0.0-canary.2
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [c57e248]
102
+ - Updated dependencies [33f4a6a]
103
+ - @ai-sdk/provider@2.0.0-canary.1
104
+ - @ai-sdk/provider-utils@3.0.0-canary.2
105
+
3
106
  ## 1.0.0-canary.1
4
107
 
5
108
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,22 +1,20 @@
1
- import { LanguageModelV2ProviderMetadata, LanguageModelV2, LanguageModelV2ObjectGenerationMode, EmbeddingModelV1, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
1
+ import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z, ZodSchema } from 'zod';
4
4
 
5
5
  type OpenAICompatibleChatModelId = string;
6
- interface OpenAICompatibleChatSettings {
6
+ declare const openaiCompatibleProviderOptions: z.ZodObject<{
7
7
  /**
8
- A unique identifier representing your end-user, which can help the provider to
9
- monitor and detect abuse.
10
- */
11
- user?: string;
12
- /**
13
- Simulates streaming by using a normal generate call and returning it as a stream.
14
- Enable this if the model that you are using does not support streaming.
15
-
16
- Defaults to `false`.
8
+ * A unique identifier representing your end-user, which can help the provider to
9
+ * monitor and detect abuse.
17
10
  */
18
- simulateStreaming?: boolean;
19
- }
11
+ user: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ user?: string | undefined;
14
+ }, {
15
+ user?: string | undefined;
16
+ }>;
17
+ type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
20
18
 
21
19
  declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
22
20
  error: z.ZodObject<{
@@ -73,7 +71,7 @@ type MetadataExtractor = {
73
71
  */
74
72
  extractMetadata: ({ parsedBody, }: {
75
73
  parsedBody: unknown;
76
- }) => LanguageModelV2ProviderMetadata | undefined;
74
+ }) => SharedV2ProviderMetadata | undefined;
77
75
  /**
78
76
  * Creates an extractor for handling streaming responses. The returned object provides
79
77
  * methods to process individual chunks and build the final metadata from the accumulated
@@ -96,7 +94,7 @@ type MetadataExtractor = {
96
94
  * @returns Provider-specific metadata or undefined if no metadata is available.
97
95
  * The metadata should be under a key indicating the provider id.
98
96
  */
99
- buildMetadata(): LanguageModelV2ProviderMetadata | undefined;
97
+ buildMetadata(): SharedV2ProviderMetadata | undefined;
100
98
  };
101
99
  };
102
100
 
@@ -108,70 +106,72 @@ type OpenAICompatibleChatConfig = {
108
106
  path: string;
109
107
  }) => string;
110
108
  fetch?: FetchFunction;
109
+ includeUsage?: boolean;
111
110
  errorStructure?: ProviderErrorStructure<any>;
112
111
  metadataExtractor?: MetadataExtractor;
113
112
  /**
114
- Default object generation mode that should be used with this model when
115
- no mode is specified. Should be the mode with the best results for this
116
- model. `undefined` can be specified if object generation is not supported.
117
- */
118
- defaultObjectGenerationMode?: LanguageModelV2ObjectGenerationMode;
119
- /**
120
113
  * Whether the model supports structured outputs.
121
114
  */
122
115
  supportsStructuredOutputs?: boolean;
116
+ /**
117
+ * The supported URLs for the model.
118
+ */
119
+ getSupportedUrls?: () => Promise<Record<string, RegExp[]>>;
123
120
  };
124
121
  declare class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
125
122
  readonly specificationVersion = "v2";
126
123
  readonly supportsStructuredOutputs: boolean;
127
124
  readonly modelId: OpenAICompatibleChatModelId;
128
- readonly settings: OpenAICompatibleChatSettings;
129
125
  private readonly config;
130
126
  private readonly failedResponseHandler;
131
127
  private readonly chunkSchema;
132
- constructor(modelId: OpenAICompatibleChatModelId, settings: OpenAICompatibleChatSettings, config: OpenAICompatibleChatConfig);
133
- get defaultObjectGenerationMode(): 'json' | 'tool' | undefined;
128
+ constructor(modelId: OpenAICompatibleChatModelId, config: OpenAICompatibleChatConfig);
134
129
  get provider(): string;
135
130
  private get providerOptionsName();
131
+ getSupportedUrls(): Promise<Record<string, RegExp[]>>;
136
132
  private getArgs;
137
133
  doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
138
134
  doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
139
135
  }
140
136
 
141
137
  type OpenAICompatibleCompletionModelId = string;
142
- interface OpenAICompatibleCompletionSettings {
138
+ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
143
139
  /**
144
- Echo back the prompt in addition to the completion.
140
+ * Echo back the prompt in addition to the completion.
145
141
  */
146
- echo?: boolean;
142
+ echo: z.ZodOptional<z.ZodBoolean>;
147
143
  /**
148
- Modify the likelihood of specified tokens appearing in the completion.
149
-
150
- Accepts a JSON object that maps tokens (specified by their token ID in
151
- the GPT tokenizer) to an associated bias value from -100 to 100. You
152
- can use this tokenizer tool to convert text to token IDs. Mathematically,
153
- the bias is added to the logits generated by the model prior to sampling.
154
- The exact effect will vary per model, but values between -1 and 1 should
155
- decrease or increase likelihood of selection; values like -100 or 100
156
- should result in a ban or exclusive selection of the relevant token.
157
-
158
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
159
- token from being generated.
144
+ * Modify the likelihood of specified tokens appearing in the completion.
145
+ *
146
+ * Accepts a JSON object that maps tokens (specified by their token ID in
147
+ * the GPT tokenizer) to an associated bias value from -100 to 100.
160
148
  */
161
- logitBias?: Record<number, number>;
149
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodNumber>>;
162
150
  /**
163
- The suffix that comes after a completion of inserted text.
151
+ * The suffix that comes after a completion of inserted text.
164
152
  */
165
- suffix?: string;
153
+ suffix: z.ZodOptional<z.ZodString>;
166
154
  /**
167
- A unique identifier representing your end-user, which can help OpenAI to
168
- monitor and detect abuse. Learn more.
155
+ * A unique identifier representing your end-user, which can help providers to
156
+ * monitor and detect abuse.
169
157
  */
170
- user?: string;
171
- }
158
+ user: z.ZodOptional<z.ZodString>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ user?: string | undefined;
161
+ echo?: boolean | undefined;
162
+ logitBias?: Record<number, number> | undefined;
163
+ suffix?: string | undefined;
164
+ }, {
165
+ user?: string | undefined;
166
+ echo?: boolean | undefined;
167
+ logitBias?: Record<number, number> | undefined;
168
+ suffix?: string | undefined;
169
+ }>;
170
+ type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
172
171
 
173
172
  type OpenAICompatibleCompletionConfig = {
174
173
  provider: string;
174
+ includeUsage?: boolean;
175
175
  headers: () => Record<string, string | undefined>;
176
176
  url: (options: {
177
177
  modelId: string;
@@ -179,36 +179,46 @@ type OpenAICompatibleCompletionConfig = {
179
179
  }) => string;
180
180
  fetch?: FetchFunction;
181
181
  errorStructure?: ProviderErrorStructure<any>;
182
+ /**
183
+ * The supported URLs for the model.
184
+ */
185
+ getSupportedUrls?: () => Promise<Record<string, RegExp[]>>;
182
186
  };
183
187
  declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV2 {
184
188
  readonly specificationVersion = "v2";
185
- readonly defaultObjectGenerationMode: undefined;
186
189
  readonly modelId: OpenAICompatibleCompletionModelId;
187
- readonly settings: OpenAICompatibleCompletionSettings;
188
190
  private readonly config;
189
191
  private readonly failedResponseHandler;
190
192
  private readonly chunkSchema;
191
- constructor(modelId: OpenAICompatibleCompletionModelId, settings: OpenAICompatibleCompletionSettings, config: OpenAICompatibleCompletionConfig);
193
+ constructor(modelId: OpenAICompatibleCompletionModelId, config: OpenAICompatibleCompletionConfig);
192
194
  get provider(): string;
193
195
  private get providerOptionsName();
196
+ getSupportedUrls(): Promise<Record<string, RegExp[]>>;
194
197
  private getArgs;
195
198
  doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
196
199
  doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
197
200
  }
198
201
 
199
202
  type OpenAICompatibleEmbeddingModelId = string;
200
- interface OpenAICompatibleEmbeddingSettings {
203
+ declare const openaiCompatibleEmbeddingProviderOptions: z.ZodObject<{
201
204
  /**
202
- The number of dimensions the resulting output embeddings should have.
203
- Only supported in text-embedding-3 and later models.
205
+ * The number of dimensions the resulting output embeddings should have.
206
+ * Only supported in text-embedding-3 and later models.
204
207
  */
205
- dimensions?: number;
208
+ dimensions: z.ZodOptional<z.ZodNumber>;
206
209
  /**
207
- A unique identifier representing your end-user, which can help OpenAI to
208
- monitor and detect abuse. Learn more.
209
- */
210
- user?: string;
211
- }
210
+ * A unique identifier representing your end-user, which can help providers to
211
+ * monitor and detect abuse.
212
+ */
213
+ user: z.ZodOptional<z.ZodString>;
214
+ }, "strip", z.ZodTypeAny, {
215
+ user?: string | undefined;
216
+ dimensions?: number | undefined;
217
+ }, {
218
+ user?: string | undefined;
219
+ dimensions?: number | undefined;
220
+ }>;
221
+ type OpenAICompatibleEmbeddingProviderOptions = z.infer<typeof openaiCompatibleEmbeddingProviderOptions>;
212
222
 
213
223
  type OpenAICompatibleEmbeddingConfig = {
214
224
  /**
@@ -228,16 +238,16 @@ type OpenAICompatibleEmbeddingConfig = {
228
238
  fetch?: FetchFunction;
229
239
  errorStructure?: ProviderErrorStructure<any>;
230
240
  };
231
- declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV1<string> {
232
- readonly specificationVersion = "v1";
241
+ declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV2<string> {
242
+ readonly specificationVersion = "v2";
233
243
  readonly modelId: OpenAICompatibleEmbeddingModelId;
234
244
  private readonly config;
235
- private readonly settings;
236
245
  get provider(): string;
237
246
  get maxEmbeddingsPerCall(): number;
238
247
  get supportsParallelCalls(): boolean;
239
- constructor(modelId: OpenAICompatibleEmbeddingModelId, settings: OpenAICompatibleEmbeddingSettings, config: OpenAICompatibleEmbeddingConfig);
240
- doEmbed({ values, headers, abortSignal, }: Parameters<EmbeddingModelV1<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV1<string>['doEmbed']>>>;
248
+ constructor(modelId: OpenAICompatibleEmbeddingModelId, config: OpenAICompatibleEmbeddingConfig);
249
+ private get providerOptionsName();
250
+ doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>>;
241
251
  }
242
252
 
243
253
  type OpenAICompatibleImageModelId = string;
@@ -278,12 +288,12 @@ declare class OpenAICompatibleImageModel implements ImageModelV1 {
278
288
  }
279
289
 
280
290
  interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPLETION_MODEL_IDS extends string = string, EMBEDDING_MODEL_IDS extends string = string, IMAGE_MODEL_IDS extends string = string> extends Omit<ProviderV2, 'imageModel'> {
281
- (modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
282
- languageModel(modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
283
- chatModel(modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
284
- completionModel(modelId: COMPLETION_MODEL_IDS, settings?: OpenAICompatibleCompletionSettings): LanguageModelV2;
285
- textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS, settings?: OpenAICompatibleEmbeddingSettings): EmbeddingModelV1<string>;
286
- imageModel(modelId: IMAGE_MODEL_IDS, settings?: OpenAICompatibleImageSettings): ImageModelV1;
291
+ (modelId: CHAT_MODEL_IDS): LanguageModelV2;
292
+ languageModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
293
+ chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
294
+ completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV2;
295
+ textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV2<string>;
296
+ imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV1;
287
297
  }
288
298
  interface OpenAICompatibleProviderSettings {
289
299
  /**
@@ -320,4 +330,4 @@ Create an OpenAICompatible provider instance.
320
330
  */
321
331
  declare function createOpenAICompatible<CHAT_MODEL_IDS extends string, COMPLETION_MODEL_IDS extends string, EMBEDDING_MODEL_IDS extends string, IMAGE_MODEL_IDS extends string>(options: OpenAICompatibleProviderSettings): OpenAICompatibleProvider<CHAT_MODEL_IDS, COMPLETION_MODEL_IDS, EMBEDDING_MODEL_IDS, IMAGE_MODEL_IDS>;
322
332
 
323
- export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type OpenAICompatibleChatSettings, OpenAICompatibleCompletionLanguageModel, type OpenAICompatibleCompletionSettings, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingSettings, type OpenAICompatibleErrorData, OpenAICompatibleImageModel, type OpenAICompatibleImageSettings, type OpenAICompatibleProvider, type OpenAICompatibleProviderSettings, type ProviderErrorStructure, createOpenAICompatible };
333
+ export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type OpenAICompatibleChatModelId, OpenAICompatibleCompletionLanguageModel, type OpenAICompatibleCompletionModelId, type OpenAICompatibleCompletionProviderOptions, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingModelId, type OpenAICompatibleEmbeddingProviderOptions, type OpenAICompatibleErrorData, OpenAICompatibleImageModel, type OpenAICompatibleImageSettings, type OpenAICompatibleProvider, type OpenAICompatibleProviderOptions, type OpenAICompatibleProviderSettings, type ProviderErrorStructure, createOpenAICompatible };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,20 @@
1
- import { LanguageModelV2ProviderMetadata, LanguageModelV2, LanguageModelV2ObjectGenerationMode, EmbeddingModelV1, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
1
+ import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z, ZodSchema } from 'zod';
4
4
 
5
5
  type OpenAICompatibleChatModelId = string;
6
- interface OpenAICompatibleChatSettings {
6
+ declare const openaiCompatibleProviderOptions: z.ZodObject<{
7
7
  /**
8
- A unique identifier representing your end-user, which can help the provider to
9
- monitor and detect abuse.
10
- */
11
- user?: string;
12
- /**
13
- Simulates streaming by using a normal generate call and returning it as a stream.
14
- Enable this if the model that you are using does not support streaming.
15
-
16
- Defaults to `false`.
8
+ * A unique identifier representing your end-user, which can help the provider to
9
+ * monitor and detect abuse.
17
10
  */
18
- simulateStreaming?: boolean;
19
- }
11
+ user: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ user?: string | undefined;
14
+ }, {
15
+ user?: string | undefined;
16
+ }>;
17
+ type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
20
18
 
21
19
  declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
22
20
  error: z.ZodObject<{
@@ -73,7 +71,7 @@ type MetadataExtractor = {
73
71
  */
74
72
  extractMetadata: ({ parsedBody, }: {
75
73
  parsedBody: unknown;
76
- }) => LanguageModelV2ProviderMetadata | undefined;
74
+ }) => SharedV2ProviderMetadata | undefined;
77
75
  /**
78
76
  * Creates an extractor for handling streaming responses. The returned object provides
79
77
  * methods to process individual chunks and build the final metadata from the accumulated
@@ -96,7 +94,7 @@ type MetadataExtractor = {
96
94
  * @returns Provider-specific metadata or undefined if no metadata is available.
97
95
  * The metadata should be under a key indicating the provider id.
98
96
  */
99
- buildMetadata(): LanguageModelV2ProviderMetadata | undefined;
97
+ buildMetadata(): SharedV2ProviderMetadata | undefined;
100
98
  };
101
99
  };
102
100
 
@@ -108,70 +106,72 @@ type OpenAICompatibleChatConfig = {
108
106
  path: string;
109
107
  }) => string;
110
108
  fetch?: FetchFunction;
109
+ includeUsage?: boolean;
111
110
  errorStructure?: ProviderErrorStructure<any>;
112
111
  metadataExtractor?: MetadataExtractor;
113
112
  /**
114
- Default object generation mode that should be used with this model when
115
- no mode is specified. Should be the mode with the best results for this
116
- model. `undefined` can be specified if object generation is not supported.
117
- */
118
- defaultObjectGenerationMode?: LanguageModelV2ObjectGenerationMode;
119
- /**
120
113
  * Whether the model supports structured outputs.
121
114
  */
122
115
  supportsStructuredOutputs?: boolean;
116
+ /**
117
+ * The supported URLs for the model.
118
+ */
119
+ getSupportedUrls?: () => Promise<Record<string, RegExp[]>>;
123
120
  };
124
121
  declare class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
125
122
  readonly specificationVersion = "v2";
126
123
  readonly supportsStructuredOutputs: boolean;
127
124
  readonly modelId: OpenAICompatibleChatModelId;
128
- readonly settings: OpenAICompatibleChatSettings;
129
125
  private readonly config;
130
126
  private readonly failedResponseHandler;
131
127
  private readonly chunkSchema;
132
- constructor(modelId: OpenAICompatibleChatModelId, settings: OpenAICompatibleChatSettings, config: OpenAICompatibleChatConfig);
133
- get defaultObjectGenerationMode(): 'json' | 'tool' | undefined;
128
+ constructor(modelId: OpenAICompatibleChatModelId, config: OpenAICompatibleChatConfig);
134
129
  get provider(): string;
135
130
  private get providerOptionsName();
131
+ getSupportedUrls(): Promise<Record<string, RegExp[]>>;
136
132
  private getArgs;
137
133
  doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
138
134
  doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
139
135
  }
140
136
 
141
137
  type OpenAICompatibleCompletionModelId = string;
142
- interface OpenAICompatibleCompletionSettings {
138
+ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
143
139
  /**
144
- Echo back the prompt in addition to the completion.
140
+ * Echo back the prompt in addition to the completion.
145
141
  */
146
- echo?: boolean;
142
+ echo: z.ZodOptional<z.ZodBoolean>;
147
143
  /**
148
- Modify the likelihood of specified tokens appearing in the completion.
149
-
150
- Accepts a JSON object that maps tokens (specified by their token ID in
151
- the GPT tokenizer) to an associated bias value from -100 to 100. You
152
- can use this tokenizer tool to convert text to token IDs. Mathematically,
153
- the bias is added to the logits generated by the model prior to sampling.
154
- The exact effect will vary per model, but values between -1 and 1 should
155
- decrease or increase likelihood of selection; values like -100 or 100
156
- should result in a ban or exclusive selection of the relevant token.
157
-
158
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
159
- token from being generated.
144
+ * Modify the likelihood of specified tokens appearing in the completion.
145
+ *
146
+ * Accepts a JSON object that maps tokens (specified by their token ID in
147
+ * the GPT tokenizer) to an associated bias value from -100 to 100.
160
148
  */
161
- logitBias?: Record<number, number>;
149
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodNumber>>;
162
150
  /**
163
- The suffix that comes after a completion of inserted text.
151
+ * The suffix that comes after a completion of inserted text.
164
152
  */
165
- suffix?: string;
153
+ suffix: z.ZodOptional<z.ZodString>;
166
154
  /**
167
- A unique identifier representing your end-user, which can help OpenAI to
168
- monitor and detect abuse. Learn more.
155
+ * A unique identifier representing your end-user, which can help providers to
156
+ * monitor and detect abuse.
169
157
  */
170
- user?: string;
171
- }
158
+ user: z.ZodOptional<z.ZodString>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ user?: string | undefined;
161
+ echo?: boolean | undefined;
162
+ logitBias?: Record<number, number> | undefined;
163
+ suffix?: string | undefined;
164
+ }, {
165
+ user?: string | undefined;
166
+ echo?: boolean | undefined;
167
+ logitBias?: Record<number, number> | undefined;
168
+ suffix?: string | undefined;
169
+ }>;
170
+ type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
172
171
 
173
172
  type OpenAICompatibleCompletionConfig = {
174
173
  provider: string;
174
+ includeUsage?: boolean;
175
175
  headers: () => Record<string, string | undefined>;
176
176
  url: (options: {
177
177
  modelId: string;
@@ -179,36 +179,46 @@ type OpenAICompatibleCompletionConfig = {
179
179
  }) => string;
180
180
  fetch?: FetchFunction;
181
181
  errorStructure?: ProviderErrorStructure<any>;
182
+ /**
183
+ * The supported URLs for the model.
184
+ */
185
+ getSupportedUrls?: () => Promise<Record<string, RegExp[]>>;
182
186
  };
183
187
  declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV2 {
184
188
  readonly specificationVersion = "v2";
185
- readonly defaultObjectGenerationMode: undefined;
186
189
  readonly modelId: OpenAICompatibleCompletionModelId;
187
- readonly settings: OpenAICompatibleCompletionSettings;
188
190
  private readonly config;
189
191
  private readonly failedResponseHandler;
190
192
  private readonly chunkSchema;
191
- constructor(modelId: OpenAICompatibleCompletionModelId, settings: OpenAICompatibleCompletionSettings, config: OpenAICompatibleCompletionConfig);
193
+ constructor(modelId: OpenAICompatibleCompletionModelId, config: OpenAICompatibleCompletionConfig);
192
194
  get provider(): string;
193
195
  private get providerOptionsName();
196
+ getSupportedUrls(): Promise<Record<string, RegExp[]>>;
194
197
  private getArgs;
195
198
  doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
196
199
  doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
197
200
  }
198
201
 
199
202
  type OpenAICompatibleEmbeddingModelId = string;
200
- interface OpenAICompatibleEmbeddingSettings {
203
+ declare const openaiCompatibleEmbeddingProviderOptions: z.ZodObject<{
201
204
  /**
202
- The number of dimensions the resulting output embeddings should have.
203
- Only supported in text-embedding-3 and later models.
205
+ * The number of dimensions the resulting output embeddings should have.
206
+ * Only supported in text-embedding-3 and later models.
204
207
  */
205
- dimensions?: number;
208
+ dimensions: z.ZodOptional<z.ZodNumber>;
206
209
  /**
207
- A unique identifier representing your end-user, which can help OpenAI to
208
- monitor and detect abuse. Learn more.
209
- */
210
- user?: string;
211
- }
210
+ * A unique identifier representing your end-user, which can help providers to
211
+ * monitor and detect abuse.
212
+ */
213
+ user: z.ZodOptional<z.ZodString>;
214
+ }, "strip", z.ZodTypeAny, {
215
+ user?: string | undefined;
216
+ dimensions?: number | undefined;
217
+ }, {
218
+ user?: string | undefined;
219
+ dimensions?: number | undefined;
220
+ }>;
221
+ type OpenAICompatibleEmbeddingProviderOptions = z.infer<typeof openaiCompatibleEmbeddingProviderOptions>;
212
222
 
213
223
  type OpenAICompatibleEmbeddingConfig = {
214
224
  /**
@@ -228,16 +238,16 @@ type OpenAICompatibleEmbeddingConfig = {
228
238
  fetch?: FetchFunction;
229
239
  errorStructure?: ProviderErrorStructure<any>;
230
240
  };
231
- declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV1<string> {
232
- readonly specificationVersion = "v1";
241
+ declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV2<string> {
242
+ readonly specificationVersion = "v2";
233
243
  readonly modelId: OpenAICompatibleEmbeddingModelId;
234
244
  private readonly config;
235
- private readonly settings;
236
245
  get provider(): string;
237
246
  get maxEmbeddingsPerCall(): number;
238
247
  get supportsParallelCalls(): boolean;
239
- constructor(modelId: OpenAICompatibleEmbeddingModelId, settings: OpenAICompatibleEmbeddingSettings, config: OpenAICompatibleEmbeddingConfig);
240
- doEmbed({ values, headers, abortSignal, }: Parameters<EmbeddingModelV1<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV1<string>['doEmbed']>>>;
248
+ constructor(modelId: OpenAICompatibleEmbeddingModelId, config: OpenAICompatibleEmbeddingConfig);
249
+ private get providerOptionsName();
250
+ doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV2<string>['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV2<string>['doEmbed']>>>;
241
251
  }
242
252
 
243
253
  type OpenAICompatibleImageModelId = string;
@@ -278,12 +288,12 @@ declare class OpenAICompatibleImageModel implements ImageModelV1 {
278
288
  }
279
289
 
280
290
  interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPLETION_MODEL_IDS extends string = string, EMBEDDING_MODEL_IDS extends string = string, IMAGE_MODEL_IDS extends string = string> extends Omit<ProviderV2, 'imageModel'> {
281
- (modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
282
- languageModel(modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
283
- chatModel(modelId: CHAT_MODEL_IDS, settings?: OpenAICompatibleChatSettings): LanguageModelV2;
284
- completionModel(modelId: COMPLETION_MODEL_IDS, settings?: OpenAICompatibleCompletionSettings): LanguageModelV2;
285
- textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS, settings?: OpenAICompatibleEmbeddingSettings): EmbeddingModelV1<string>;
286
- imageModel(modelId: IMAGE_MODEL_IDS, settings?: OpenAICompatibleImageSettings): ImageModelV1;
291
+ (modelId: CHAT_MODEL_IDS): LanguageModelV2;
292
+ languageModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
293
+ chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
294
+ completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV2;
295
+ textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV2<string>;
296
+ imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV1;
287
297
  }
288
298
  interface OpenAICompatibleProviderSettings {
289
299
  /**
@@ -320,4 +330,4 @@ Create an OpenAICompatible provider instance.
320
330
  */
321
331
  declare function createOpenAICompatible<CHAT_MODEL_IDS extends string, COMPLETION_MODEL_IDS extends string, EMBEDDING_MODEL_IDS extends string, IMAGE_MODEL_IDS extends string>(options: OpenAICompatibleProviderSettings): OpenAICompatibleProvider<CHAT_MODEL_IDS, COMPLETION_MODEL_IDS, EMBEDDING_MODEL_IDS, IMAGE_MODEL_IDS>;
322
332
 
323
- export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type OpenAICompatibleChatSettings, OpenAICompatibleCompletionLanguageModel, type OpenAICompatibleCompletionSettings, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingSettings, type OpenAICompatibleErrorData, OpenAICompatibleImageModel, type OpenAICompatibleImageSettings, type OpenAICompatibleProvider, type OpenAICompatibleProviderSettings, type ProviderErrorStructure, createOpenAICompatible };
333
+ export { type MetadataExtractor, OpenAICompatibleChatLanguageModel, type OpenAICompatibleChatModelId, OpenAICompatibleCompletionLanguageModel, type OpenAICompatibleCompletionModelId, type OpenAICompatibleCompletionProviderOptions, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingModelId, type OpenAICompatibleEmbeddingProviderOptions, type OpenAICompatibleErrorData, OpenAICompatibleImageModel, type OpenAICompatibleImageSettings, type OpenAICompatibleProvider, type OpenAICompatibleProviderOptions, type OpenAICompatibleProviderSettings, type ProviderErrorStructure, createOpenAICompatible };