@ai-sdk/openai-compatible 3.0.0-beta.4 → 3.0.0-beta.57
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 +440 -8
- package/README.md +2 -0
- package/dist/index.d.ts +69 -8
- package/dist/index.js +548 -428
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +20 -2
- package/dist/internal/index.js +91 -91
- package/dist/internal/index.js.map +1 -1
- package/docs/index.mdx +1 -0
- package/package.json +16 -17
- package/src/chat/convert-openai-compatible-chat-usage.ts +1 -1
- package/src/chat/convert-to-openai-compatible-chat-messages.ts +94 -73
- package/src/chat/map-openai-compatible-finish-reason.ts +1 -1
- package/src/chat/openai-compatible-api-types.ts +3 -5
- package/src/chat/openai-compatible-chat-language-model.ts +205 -191
- package/src/chat/openai-compatible-metadata-extractor.ts +1 -1
- package/src/chat/openai-compatible-prepare-tools.ts +2 -3
- package/src/completion/convert-openai-compatible-completion-usage.ts +1 -1
- package/src/completion/convert-to-openai-compatible-completion-prompt.ts +1 -2
- package/src/completion/map-openai-compatible-finish-reason.ts +1 -1
- package/src/completion/openai-compatible-completion-language-model.ts +52 -17
- package/src/embedding/openai-compatible-embedding-model.ts +36 -10
- package/src/image/openai-compatible-image-model.ts +35 -13
- package/src/index.ts +3 -3
- package/src/openai-compatible-error.ts +1 -2
- package/src/openai-compatible-provider.ts +18 -5
- package/src/utils/to-camel-case.ts +43 -0
- package/dist/index.d.mts +0 -290
- package/dist/index.mjs +0 -1742
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -193
- package/dist/internal/index.mjs +0 -340
- package/dist/internal/index.mjs.map +0 -1
- /package/src/chat/{openai-compatible-chat-options.ts → openai-compatible-chat-language-model-options.ts} +0 -0
- /package/src/completion/{openai-compatible-completion-options.ts → openai-compatible-completion-language-model-options.ts} +0 -0
- /package/src/embedding/{openai-compatible-embedding-options.ts → openai-compatible-embedding-model-options.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,437 @@
|
|
|
1
1
|
# @ai-sdk/openai-compatible
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.57
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b8396f0: trigger initial beta release
|
|
8
|
+
- Updated dependencies [b8396f0]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-beta.49
|
|
10
|
+
- @ai-sdk/provider@4.0.0-beta.19
|
|
11
|
+
|
|
12
|
+
## 3.0.0-canary.56
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [aeda373]
|
|
17
|
+
- Updated dependencies [375fdd7]
|
|
18
|
+
- Updated dependencies [b4507d5]
|
|
19
|
+
- @ai-sdk/provider-utils@5.0.0-canary.48
|
|
20
|
+
|
|
21
|
+
## 3.0.0-canary.55
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [bae5e2b]
|
|
26
|
+
- @ai-sdk/provider-utils@5.0.0-canary.47
|
|
27
|
+
|
|
28
|
+
## 3.0.0-canary.54
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [ce769dd]
|
|
33
|
+
- @ai-sdk/provider@4.0.0-canary.18
|
|
34
|
+
- @ai-sdk/provider-utils@5.0.0-canary.46
|
|
35
|
+
|
|
36
|
+
## 3.0.0-canary.53
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [ee798eb]
|
|
41
|
+
- Updated dependencies [daf6637]
|
|
42
|
+
- @ai-sdk/provider-utils@5.0.0-canary.45
|
|
43
|
+
|
|
44
|
+
## 3.0.0-canary.52
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [6c93e36]
|
|
49
|
+
- Updated dependencies [f617ac2]
|
|
50
|
+
- @ai-sdk/provider-utils@5.0.0-canary.44
|
|
51
|
+
|
|
52
|
+
## 3.0.0-canary.51
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- 9f1e1ba: fix: accept empty string `role` in streaming delta chunks from OpenAI-compatible providers
|
|
57
|
+
|
|
58
|
+
## 3.0.0-canary.50
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
|
|
63
|
+
- Updated dependencies [7fc6bd6]
|
|
64
|
+
- @ai-sdk/provider-utils@5.0.0-canary.43
|
|
65
|
+
- @ai-sdk/provider@4.0.0-canary.17
|
|
66
|
+
|
|
67
|
+
## 3.0.0-canary.49
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [a6617c5]
|
|
72
|
+
- @ai-sdk/provider-utils@5.0.0-canary.42
|
|
73
|
+
|
|
74
|
+
## 3.0.0-canary.48
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [28dfa06]
|
|
79
|
+
- Updated dependencies [e93fa91]
|
|
80
|
+
- @ai-sdk/provider-utils@5.0.0-canary.41
|
|
81
|
+
|
|
82
|
+
## 3.0.0-canary.47
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies [a7de9c9]
|
|
87
|
+
- @ai-sdk/provider-utils@5.0.0-canary.40
|
|
88
|
+
|
|
89
|
+
## 3.0.0-canary.46
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [105f95b]
|
|
94
|
+
- @ai-sdk/provider-utils@5.0.0-canary.39
|
|
95
|
+
|
|
96
|
+
## 3.0.0-canary.45
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Updated dependencies [ca446f8]
|
|
101
|
+
- @ai-sdk/provider-utils@5.0.0-canary.38
|
|
102
|
+
|
|
103
|
+
## 3.0.0-canary.44
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Updated dependencies [d848405]
|
|
108
|
+
- @ai-sdk/provider-utils@5.0.0-canary.37
|
|
109
|
+
|
|
110
|
+
## 3.0.0-canary.43
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [ca39020]
|
|
115
|
+
- @ai-sdk/provider-utils@5.0.0-canary.36
|
|
116
|
+
|
|
117
|
+
## 3.0.0-canary.42
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Updated dependencies [f634bac]
|
|
122
|
+
- @ai-sdk/provider-utils@5.0.0-canary.35
|
|
123
|
+
|
|
124
|
+
## 3.0.0-canary.41
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- Updated dependencies [69254e0]
|
|
129
|
+
- Updated dependencies [3015fc3]
|
|
130
|
+
- @ai-sdk/provider-utils@5.0.0-canary.34
|
|
131
|
+
|
|
132
|
+
## 3.0.0-canary.40
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- Updated dependencies [2427d88]
|
|
137
|
+
- @ai-sdk/provider-utils@5.0.0-canary.33
|
|
138
|
+
|
|
139
|
+
## 3.0.0-canary.39
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- Updated dependencies [5463d0d]
|
|
144
|
+
- @ai-sdk/provider-utils@5.0.0-canary.32
|
|
145
|
+
- @ai-sdk/provider@4.0.0-canary.16
|
|
146
|
+
|
|
147
|
+
## 3.0.0-canary.38
|
|
148
|
+
|
|
149
|
+
### Patch Changes
|
|
150
|
+
|
|
151
|
+
- cd9c311: fix(openai, openai-compatible): only send null content for assistant messages with tool calls
|
|
152
|
+
|
|
153
|
+
## 3.0.0-canary.37
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- 0c4c275: trigger initial canary release
|
|
158
|
+
- Updated dependencies [0c4c275]
|
|
159
|
+
- @ai-sdk/provider-utils@5.0.0-canary.31
|
|
160
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
161
|
+
|
|
162
|
+
## 3.0.0-beta.36
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- e59c955: feat(vertex): add grok models to vertex provider
|
|
167
|
+
|
|
168
|
+
## 3.0.0-beta.35
|
|
169
|
+
|
|
170
|
+
### Major Changes
|
|
171
|
+
|
|
172
|
+
- 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
|
|
173
|
+
|
|
174
|
+
For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [08d2129]
|
|
179
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
180
|
+
|
|
181
|
+
## 3.0.0-beta.34
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
|
|
186
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
187
|
+
- Updated dependencies [9bd6512]
|
|
188
|
+
- Updated dependencies [258c093]
|
|
189
|
+
- Updated dependencies [b6783da]
|
|
190
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
191
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
192
|
+
|
|
193
|
+
## 3.0.0-beta.33
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
198
|
+
- Updated dependencies [9f0e36c]
|
|
199
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
201
|
+
|
|
202
|
+
## 3.0.0-beta.32
|
|
203
|
+
|
|
204
|
+
### Patch Changes
|
|
205
|
+
|
|
206
|
+
- ab81968: fix(openai-compatible): buffer tool call deltas until function.name arrives
|
|
207
|
+
- 58a2ad7: fix: more precise default message for tool execution denial
|
|
208
|
+
- Updated dependencies [785fe16]
|
|
209
|
+
- Updated dependencies [67df0a0]
|
|
210
|
+
- Updated dependencies [befb78c]
|
|
211
|
+
- Updated dependencies [0458559]
|
|
212
|
+
- Updated dependencies [5852c0a]
|
|
213
|
+
- Updated dependencies [fc92055]
|
|
214
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
215
|
+
|
|
216
|
+
## 3.0.0-beta.31
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- bfb756d: patch - send content: null instead of empty string for tool-only assistant messages
|
|
221
|
+
- Updated dependencies [2e98477]
|
|
222
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
223
|
+
|
|
224
|
+
## 3.0.0-beta.30
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- Updated dependencies [eea8d98]
|
|
229
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
230
|
+
|
|
231
|
+
## 3.0.0-beta.29
|
|
232
|
+
|
|
233
|
+
### Patch Changes
|
|
234
|
+
|
|
235
|
+
- f807e45: Extract shared `StreamingToolCallTracker` class into `@ai-sdk/provider-utils` to deduplicate streaming tool call handling across OpenAI-compatible providers. Also adds missing `generateId()` fallback for `toolCallId` in Alibaba's `doGenerate` path and ensures all providers finalize unfinished tool calls during stream flush.
|
|
236
|
+
- Updated dependencies [f807e45]
|
|
237
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
238
|
+
|
|
239
|
+
## 3.0.0-beta.28
|
|
240
|
+
|
|
241
|
+
### Patch Changes
|
|
242
|
+
|
|
243
|
+
- Updated dependencies [350ea38]
|
|
244
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
245
|
+
|
|
246
|
+
## 3.0.0-beta.27
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- Updated dependencies [083947b]
|
|
251
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
252
|
+
|
|
253
|
+
## 3.0.0-beta.26
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- Updated dependencies [add1126]
|
|
258
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
259
|
+
|
|
260
|
+
## 3.0.0-beta.25
|
|
261
|
+
|
|
262
|
+
### Patch Changes
|
|
263
|
+
|
|
264
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
265
|
+
|
|
266
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
267
|
+
|
|
268
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
269
|
+
|
|
270
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
271
|
+
|
|
272
|
+
- Updated dependencies [b3976a2]
|
|
273
|
+
- Updated dependencies [ff5eba1]
|
|
274
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
275
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
276
|
+
|
|
277
|
+
## 3.0.0-beta.24
|
|
278
|
+
|
|
279
|
+
### Major Changes
|
|
280
|
+
|
|
281
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
282
|
+
|
|
283
|
+
### Patch Changes
|
|
284
|
+
|
|
285
|
+
- Updated dependencies [ef992f8]
|
|
286
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
287
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
288
|
+
|
|
289
|
+
## 3.0.0-beta.23
|
|
290
|
+
|
|
291
|
+
### Patch Changes
|
|
292
|
+
|
|
293
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
294
|
+
- Updated dependencies [90e2d8a]
|
|
295
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
296
|
+
|
|
297
|
+
## 3.0.0-beta.22
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- Updated dependencies [3ae1786]
|
|
302
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
303
|
+
|
|
304
|
+
## 3.0.0-beta.21
|
|
305
|
+
|
|
306
|
+
### Patch Changes
|
|
307
|
+
|
|
308
|
+
- Updated dependencies [176466a]
|
|
309
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
310
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
311
|
+
|
|
312
|
+
## 3.0.0-beta.20
|
|
313
|
+
|
|
314
|
+
### Patch Changes
|
|
315
|
+
|
|
316
|
+
- Updated dependencies [e311194]
|
|
317
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
318
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
319
|
+
|
|
320
|
+
## 3.0.0-beta.19
|
|
321
|
+
|
|
322
|
+
### Patch Changes
|
|
323
|
+
|
|
324
|
+
- 008271d: feat(openai-compatible): emit warning when using kebab-case instead of camelCase
|
|
325
|
+
- Updated dependencies [34bd95d]
|
|
326
|
+
- Updated dependencies [008271d]
|
|
327
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
328
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
329
|
+
|
|
330
|
+
## 3.0.0-beta.18
|
|
331
|
+
|
|
332
|
+
### Patch Changes
|
|
333
|
+
|
|
334
|
+
- Updated dependencies [b0c2869]
|
|
335
|
+
- Updated dependencies [7e26e81]
|
|
336
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
337
|
+
|
|
338
|
+
## 3.0.0-beta.17
|
|
339
|
+
|
|
340
|
+
### Patch Changes
|
|
341
|
+
|
|
342
|
+
- 816ff67: fix(openai-compatible): honor camelCase providerOptions key in chat and completion models
|
|
343
|
+
|
|
344
|
+
## 3.0.0-beta.16
|
|
345
|
+
|
|
346
|
+
### Patch Changes
|
|
347
|
+
|
|
348
|
+
- Updated dependencies [46d1149]
|
|
349
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
350
|
+
|
|
351
|
+
## 3.0.0-beta.15
|
|
352
|
+
|
|
353
|
+
### Patch Changes
|
|
354
|
+
|
|
355
|
+
- 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
|
|
356
|
+
- Updated dependencies [6fd51c0]
|
|
357
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
358
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
359
|
+
|
|
360
|
+
## 3.0.0-beta.14
|
|
361
|
+
|
|
362
|
+
### Patch Changes
|
|
363
|
+
|
|
364
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
365
|
+
- Updated dependencies [c29a26f]
|
|
366
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
367
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
368
|
+
|
|
369
|
+
## 3.0.0-beta.13
|
|
370
|
+
|
|
371
|
+
### Patch Changes
|
|
372
|
+
|
|
373
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
374
|
+
|
|
375
|
+
## 3.0.0-beta.12
|
|
376
|
+
|
|
377
|
+
### Patch Changes
|
|
378
|
+
|
|
379
|
+
- Updated dependencies [2e17091]
|
|
380
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
381
|
+
|
|
382
|
+
## 3.0.0-beta.11
|
|
383
|
+
|
|
384
|
+
### Patch Changes
|
|
385
|
+
|
|
386
|
+
- Updated dependencies [986c6fd]
|
|
387
|
+
- Updated dependencies [493295c]
|
|
388
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
389
|
+
|
|
390
|
+
## 3.0.0-beta.10
|
|
391
|
+
|
|
392
|
+
### Patch Changes
|
|
393
|
+
|
|
394
|
+
- Updated dependencies [1f509d4]
|
|
395
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
396
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
397
|
+
|
|
398
|
+
## 3.0.0-beta.9
|
|
399
|
+
|
|
400
|
+
### Patch Changes
|
|
401
|
+
|
|
402
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
403
|
+
|
|
404
|
+
## 3.0.0-beta.8
|
|
405
|
+
|
|
406
|
+
### Patch Changes
|
|
407
|
+
|
|
408
|
+
- Updated dependencies [3887c70]
|
|
409
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
410
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
411
|
+
|
|
412
|
+
## 3.0.0-beta.7
|
|
413
|
+
|
|
414
|
+
### Patch Changes
|
|
415
|
+
|
|
416
|
+
- Updated dependencies [776b617]
|
|
417
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
418
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
419
|
+
|
|
420
|
+
## 3.0.0-beta.6
|
|
421
|
+
|
|
422
|
+
### Patch Changes
|
|
423
|
+
|
|
424
|
+
- Updated dependencies [61753c3]
|
|
425
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
426
|
+
|
|
427
|
+
## 3.0.0-beta.5
|
|
428
|
+
|
|
429
|
+
### Patch Changes
|
|
430
|
+
|
|
431
|
+
- Updated dependencies [f7d4f01]
|
|
432
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
433
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
434
|
+
|
|
3
435
|
## 3.0.0-beta.4
|
|
4
436
|
|
|
5
437
|
### Patch Changes
|
|
@@ -301,13 +733,13 @@
|
|
|
301
733
|
Before
|
|
302
734
|
|
|
303
735
|
```ts
|
|
304
|
-
model.textEmbeddingModel(
|
|
736
|
+
model.textEmbeddingModel("my-model-id");
|
|
305
737
|
```
|
|
306
738
|
|
|
307
739
|
After
|
|
308
740
|
|
|
309
741
|
```ts
|
|
310
|
-
model.embeddingModel(
|
|
742
|
+
model.embeddingModel("my-model-id");
|
|
311
743
|
```
|
|
312
744
|
|
|
313
745
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -522,13 +954,13 @@
|
|
|
522
954
|
Before
|
|
523
955
|
|
|
524
956
|
```ts
|
|
525
|
-
model.textEmbeddingModel(
|
|
957
|
+
model.textEmbeddingModel("my-model-id");
|
|
526
958
|
```
|
|
527
959
|
|
|
528
960
|
After
|
|
529
961
|
|
|
530
962
|
```ts
|
|
531
|
-
model.embeddingModel(
|
|
963
|
+
model.embeddingModel("my-model-id");
|
|
532
964
|
```
|
|
533
965
|
|
|
534
966
|
- Updated dependencies [8d9e8ad]
|
|
@@ -964,7 +1396,7 @@
|
|
|
964
1396
|
|
|
965
1397
|
```js
|
|
966
1398
|
await generateImage({
|
|
967
|
-
model: luma.image(
|
|
1399
|
+
model: luma.image("photon-flash-1", {
|
|
968
1400
|
maxImagesPerCall: 5,
|
|
969
1401
|
pollIntervalMillis: 500,
|
|
970
1402
|
}),
|
|
@@ -977,7 +1409,7 @@
|
|
|
977
1409
|
|
|
978
1410
|
```js
|
|
979
1411
|
await generateImage({
|
|
980
|
-
model: luma.image(
|
|
1412
|
+
model: luma.image("photon-flash-1"),
|
|
981
1413
|
prompt,
|
|
982
1414
|
n: 10,
|
|
983
1415
|
maxImagesPerCall: 5,
|
|
@@ -1246,7 +1678,7 @@
|
|
|
1246
1678
|
|
|
1247
1679
|
```js
|
|
1248
1680
|
await generateImage({
|
|
1249
|
-
model: luma.image(
|
|
1681
|
+
model: luma.image("photon-flash-1", {
|
|
1250
1682
|
maxImagesPerCall: 5,
|
|
1251
1683
|
pollIntervalMillis: 500,
|
|
1252
1684
|
}),
|
|
@@ -1259,7 +1691,7 @@
|
|
|
1259
1691
|
|
|
1260
1692
|
```js
|
|
1261
1693
|
await generateImage({
|
|
1262
|
-
model: luma.image(
|
|
1694
|
+
model: luma.image("photon-flash-1"),
|
|
1263
1695
|
prompt,
|
|
1264
1696
|
n: 10,
|
|
1265
1697
|
maxImagesPerCall: 5,
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ This package provides a foundation for implementing providers that expose an Ope
|
|
|
4
4
|
|
|
5
5
|
The primary [OpenAI provider](../openai/README.md) is more feature-rich, including OpenAI-specific experimental and legacy features. This package offers a lighter-weight alternative focused on core OpenAI-compatible functionality.
|
|
6
6
|
|
|
7
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access hundreds of models from any provider — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
8
|
+
|
|
7
9
|
## Setup
|
|
8
10
|
|
|
9
11
|
The provider is available in the `@ai-sdk/openai-compatible` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
+
import { SharedV4ProviderMetadata, LanguageModelV4, LanguageModelV4Usage, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, EmbeddingModelV4, ImageModelV4, ProviderV4 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
3
4
|
import { ZodType, z } from 'zod/v4';
|
|
4
5
|
|
|
5
6
|
declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
|
|
@@ -71,7 +72,7 @@ type MetadataExtractor = {
|
|
|
71
72
|
|
|
72
73
|
type OpenAICompatibleChatConfig = {
|
|
73
74
|
provider: string;
|
|
74
|
-
headers
|
|
75
|
+
headers?: () => Record<string, string | undefined>;
|
|
75
76
|
url: (options: {
|
|
76
77
|
modelId: string;
|
|
77
78
|
path: string;
|
|
@@ -94,23 +95,50 @@ type OpenAICompatibleChatConfig = {
|
|
|
94
95
|
* than the official OpenAI API.
|
|
95
96
|
*/
|
|
96
97
|
transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
|
|
98
|
+
/**
|
|
99
|
+
* Optional usage converter for OpenAI-compatible providers with different
|
|
100
|
+
* token accounting semantics.
|
|
101
|
+
*/
|
|
102
|
+
convertUsage?: (usage: z.infer<typeof openaiCompatibleTokenUsageSchema>) => LanguageModelV4Usage;
|
|
97
103
|
};
|
|
98
104
|
declare class OpenAICompatibleChatLanguageModel implements LanguageModelV4 {
|
|
99
105
|
readonly specificationVersion = "v4";
|
|
100
106
|
readonly supportsStructuredOutputs: boolean;
|
|
101
107
|
readonly modelId: OpenAICompatibleChatModelId;
|
|
102
|
-
|
|
108
|
+
protected readonly config: OpenAICompatibleChatConfig;
|
|
103
109
|
private readonly failedResponseHandler;
|
|
104
110
|
private readonly chunkSchema;
|
|
111
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleChatLanguageModel): {
|
|
112
|
+
modelId: string;
|
|
113
|
+
config: _ai_sdk_provider.JSONObject;
|
|
114
|
+
};
|
|
115
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
116
|
+
modelId: string;
|
|
117
|
+
config: OpenAICompatibleChatConfig;
|
|
118
|
+
}): OpenAICompatibleChatLanguageModel;
|
|
105
119
|
constructor(modelId: OpenAICompatibleChatModelId, config: OpenAICompatibleChatConfig);
|
|
106
120
|
get provider(): string;
|
|
107
121
|
private get providerOptionsName();
|
|
108
122
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
109
123
|
private transformRequestBody;
|
|
124
|
+
private convertUsage;
|
|
110
125
|
private getArgs;
|
|
111
126
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
112
127
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
113
128
|
}
|
|
129
|
+
declare const openaiCompatibleTokenUsageSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
130
|
+
prompt_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
131
|
+
completion_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
132
|
+
total_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
133
|
+
prompt_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
134
|
+
cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
135
|
+
}, z.core.$strip>>>;
|
|
136
|
+
completion_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
137
|
+
reasoning_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
138
|
+
accepted_prediction_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
139
|
+
rejected_prediction_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
140
|
+
}, z.core.$strip>>>;
|
|
141
|
+
}, z.core.$loose>>>;
|
|
114
142
|
|
|
115
143
|
type OpenAICompatibleCompletionModelId = string;
|
|
116
144
|
declare const openaiCompatibleLanguageModelCompletionOptions: z.ZodObject<{
|
|
@@ -124,7 +152,7 @@ type OpenAICompatibleLanguageModelCompletionOptions = z.infer<typeof openaiCompa
|
|
|
124
152
|
type OpenAICompatibleCompletionConfig = {
|
|
125
153
|
provider: string;
|
|
126
154
|
includeUsage?: boolean;
|
|
127
|
-
headers
|
|
155
|
+
headers?: () => Record<string, string | undefined>;
|
|
128
156
|
url: (options: {
|
|
129
157
|
modelId: string;
|
|
130
158
|
path: string;
|
|
@@ -142,6 +170,14 @@ declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV4
|
|
|
142
170
|
private readonly config;
|
|
143
171
|
private readonly failedResponseHandler;
|
|
144
172
|
private readonly chunkSchema;
|
|
173
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleCompletionLanguageModel): {
|
|
174
|
+
modelId: string;
|
|
175
|
+
config: _ai_sdk_provider.JSONObject;
|
|
176
|
+
};
|
|
177
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
178
|
+
modelId: string;
|
|
179
|
+
config: OpenAICompatibleCompletionConfig;
|
|
180
|
+
}): OpenAICompatibleCompletionLanguageModel;
|
|
145
181
|
constructor(modelId: OpenAICompatibleCompletionModelId, config: OpenAICompatibleCompletionConfig);
|
|
146
182
|
get provider(): string;
|
|
147
183
|
private get providerOptionsName();
|
|
@@ -172,7 +208,7 @@ type OpenAICompatibleEmbeddingConfig = {
|
|
|
172
208
|
modelId: string;
|
|
173
209
|
path: string;
|
|
174
210
|
}) => string;
|
|
175
|
-
headers
|
|
211
|
+
headers?: () => Record<string, string | undefined>;
|
|
176
212
|
fetch?: FetchFunction;
|
|
177
213
|
errorStructure?: ProviderErrorStructure<any>;
|
|
178
214
|
};
|
|
@@ -183,6 +219,14 @@ declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV4 {
|
|
|
183
219
|
get provider(): string;
|
|
184
220
|
get maxEmbeddingsPerCall(): number;
|
|
185
221
|
get supportsParallelCalls(): boolean;
|
|
222
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleEmbeddingModel): {
|
|
223
|
+
modelId: string;
|
|
224
|
+
config: _ai_sdk_provider.JSONObject;
|
|
225
|
+
};
|
|
226
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
227
|
+
modelId: string;
|
|
228
|
+
config: OpenAICompatibleEmbeddingConfig;
|
|
229
|
+
}): OpenAICompatibleEmbeddingModel;
|
|
186
230
|
constructor(modelId: OpenAICompatibleEmbeddingModelId, config: OpenAICompatibleEmbeddingConfig);
|
|
187
231
|
private get providerOptionsName();
|
|
188
232
|
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
@@ -192,7 +236,7 @@ type OpenAICompatibleImageModelId = string;
|
|
|
192
236
|
|
|
193
237
|
type OpenAICompatibleImageModelConfig = {
|
|
194
238
|
provider: string;
|
|
195
|
-
headers
|
|
239
|
+
headers?: () => Record<string, string | undefined>;
|
|
196
240
|
url: (options: {
|
|
197
241
|
modelId: string;
|
|
198
242
|
path: string;
|
|
@@ -213,12 +257,20 @@ declare class OpenAICompatibleImageModel implements ImageModelV4 {
|
|
|
213
257
|
* The provider options key used to extract provider-specific options.
|
|
214
258
|
*/
|
|
215
259
|
private get providerOptionsKey();
|
|
260
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleImageModel): {
|
|
261
|
+
modelId: string;
|
|
262
|
+
config: _ai_sdk_provider.JSONObject;
|
|
263
|
+
};
|
|
264
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
265
|
+
modelId: string;
|
|
266
|
+
config: OpenAICompatibleImageModelConfig;
|
|
267
|
+
}): OpenAICompatibleImageModel;
|
|
216
268
|
constructor(modelId: OpenAICompatibleImageModelId, config: OpenAICompatibleImageModelConfig);
|
|
217
269
|
private getArgs;
|
|
218
270
|
doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, files, mask, }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
219
271
|
}
|
|
220
272
|
|
|
221
|
-
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
|
|
273
|
+
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 ProviderV4 {
|
|
222
274
|
(modelId: CHAT_MODEL_IDS): LanguageModelV4;
|
|
223
275
|
languageModel(modelId: CHAT_MODEL_IDS, config?: Partial<OpenAICompatibleChatConfig>): LanguageModelV4;
|
|
224
276
|
chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV4;
|
|
@@ -279,6 +331,15 @@ interface OpenAICompatibleProviderSettings {
|
|
|
279
331
|
* or provider-specific metrics from both streaming and non-streaming responses.
|
|
280
332
|
*/
|
|
281
333
|
metadataExtractor?: MetadataExtractor;
|
|
334
|
+
/**
|
|
335
|
+
* The supported URLs for chat models.
|
|
336
|
+
*/
|
|
337
|
+
supportedUrls?: OpenAICompatibleChatConfig['supportedUrls'];
|
|
338
|
+
/**
|
|
339
|
+
* Optional usage converter for providers with token accounting semantics that
|
|
340
|
+
* differ from the default OpenAI-compatible shape.
|
|
341
|
+
*/
|
|
342
|
+
convertUsage?: OpenAICompatibleChatConfig['convertUsage'];
|
|
282
343
|
}
|
|
283
344
|
/**
|
|
284
345
|
* Create an OpenAICompatible provider instance.
|