@ai-sdk/openai-compatible 1.0.0-canary.10 → 1.0.0-canary.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,19 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 1.0.0-canary.11
4
+
5
+ ### Patch Changes
6
+
7
+ - db72adc: chore(providers/openai): update completion model to use providerOptions
8
+ - 42e32b0: feat(providers/xai): add reasoningEffort provider option
9
+ - 66962ed: fix(packages): export node10 compatible types
10
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
11
+ - Updated dependencies [66962ed]
12
+ - Updated dependencies [9301f86]
13
+ - Updated dependencies [a3f768e]
14
+ - @ai-sdk/provider-utils@3.0.0-canary.11
15
+ - @ai-sdk/provider@2.0.0-canary.10
16
+
3
17
  ## 1.0.0-canary.10
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
1
+ import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z, ZodSchema } from 'zod';
4
4
 
@@ -9,10 +9,16 @@ declare const openaiCompatibleProviderOptions: z.ZodObject<{
9
9
  * monitor and detect abuse.
10
10
  */
11
11
  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"]>>;
12
16
  }, "strip", z.ZodTypeAny, {
13
17
  user?: string | undefined;
18
+ reasoningEffort?: "low" | "medium" | "high" | undefined;
14
19
  }, {
15
20
  user?: string | undefined;
21
+ reasoningEffort?: "low" | "medium" | "high" | undefined;
16
22
  }>;
17
23
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
18
24
 
@@ -71,7 +77,7 @@ type MetadataExtractor = {
71
77
  */
72
78
  extractMetadata: ({ parsedBody, }: {
73
79
  parsedBody: unknown;
74
- }) => SharedV2ProviderMetadata | undefined;
80
+ }) => Promise<SharedV2ProviderMetadata | undefined>;
75
81
  /**
76
82
  * Creates an extractor for handling streaming responses. The returned object provides
77
83
  * methods to process individual chunks and build the final metadata from the accumulated
@@ -146,7 +152,7 @@ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
146
152
  * Accepts a JSON object that maps tokens (specified by their token ID in
147
153
  * the GPT tokenizer) to an associated bias value from -100 to 100.
148
154
  */
149
- logitBias: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodNumber>>;
155
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
150
156
  /**
151
157
  * The suffix that comes after a completion of inserted text.
152
158
  */
@@ -159,12 +165,12 @@ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
159
165
  }, "strip", z.ZodTypeAny, {
160
166
  user?: string | undefined;
161
167
  echo?: boolean | undefined;
162
- logitBias?: Record<number, number> | undefined;
168
+ logitBias?: Record<string, number> | undefined;
163
169
  suffix?: string | undefined;
164
170
  }, {
165
171
  user?: string | undefined;
166
172
  echo?: boolean | undefined;
167
- logitBias?: Record<number, number> | undefined;
173
+ logitBias?: Record<string, number> | undefined;
168
174
  suffix?: string | undefined;
169
175
  }>;
170
176
  type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
@@ -276,7 +282,7 @@ type OpenAICompatibleImageModelConfig = {
276
282
  currentDate?: () => Date;
277
283
  };
278
284
  };
279
- declare class OpenAICompatibleImageModel implements ImageModelV1 {
285
+ declare class OpenAICompatibleImageModel implements ImageModelV2 {
280
286
  readonly modelId: OpenAICompatibleImageModelId;
281
287
  private readonly settings;
282
288
  private readonly config;
@@ -284,7 +290,7 @@ declare class OpenAICompatibleImageModel implements ImageModelV1 {
284
290
  get maxImagesPerCall(): number;
285
291
  get provider(): string;
286
292
  constructor(modelId: OpenAICompatibleImageModelId, settings: OpenAICompatibleImageSettings, config: OpenAICompatibleImageModelConfig);
287
- doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<ImageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV1['doGenerate']>>>;
293
+ doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<ImageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV2['doGenerate']>>>;
288
294
  }
289
295
 
290
296
  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'> {
@@ -293,7 +299,7 @@ interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPL
293
299
  chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
294
300
  completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV2;
295
301
  textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV2<string>;
296
- imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV1;
302
+ imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV2;
297
303
  }
298
304
  interface OpenAICompatibleProviderSettings {
299
305
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV1, ProviderV2 } from '@ai-sdk/provider';
1
+ import { SharedV2ProviderMetadata, LanguageModelV2, EmbeddingModelV2, ImageModelV2, ProviderV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z, ZodSchema } from 'zod';
4
4
 
@@ -9,10 +9,16 @@ declare const openaiCompatibleProviderOptions: z.ZodObject<{
9
9
  * monitor and detect abuse.
10
10
  */
11
11
  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"]>>;
12
16
  }, "strip", z.ZodTypeAny, {
13
17
  user?: string | undefined;
18
+ reasoningEffort?: "low" | "medium" | "high" | undefined;
14
19
  }, {
15
20
  user?: string | undefined;
21
+ reasoningEffort?: "low" | "medium" | "high" | undefined;
16
22
  }>;
17
23
  type OpenAICompatibleProviderOptions = z.infer<typeof openaiCompatibleProviderOptions>;
18
24
 
@@ -71,7 +77,7 @@ type MetadataExtractor = {
71
77
  */
72
78
  extractMetadata: ({ parsedBody, }: {
73
79
  parsedBody: unknown;
74
- }) => SharedV2ProviderMetadata | undefined;
80
+ }) => Promise<SharedV2ProviderMetadata | undefined>;
75
81
  /**
76
82
  * Creates an extractor for handling streaming responses. The returned object provides
77
83
  * methods to process individual chunks and build the final metadata from the accumulated
@@ -146,7 +152,7 @@ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
146
152
  * Accepts a JSON object that maps tokens (specified by their token ID in
147
153
  * the GPT tokenizer) to an associated bias value from -100 to 100.
148
154
  */
149
- logitBias: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodNumber>>;
155
+ logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
150
156
  /**
151
157
  * The suffix that comes after a completion of inserted text.
152
158
  */
@@ -159,12 +165,12 @@ declare const openaiCompatibleCompletionProviderOptions: z.ZodObject<{
159
165
  }, "strip", z.ZodTypeAny, {
160
166
  user?: string | undefined;
161
167
  echo?: boolean | undefined;
162
- logitBias?: Record<number, number> | undefined;
168
+ logitBias?: Record<string, number> | undefined;
163
169
  suffix?: string | undefined;
164
170
  }, {
165
171
  user?: string | undefined;
166
172
  echo?: boolean | undefined;
167
- logitBias?: Record<number, number> | undefined;
173
+ logitBias?: Record<string, number> | undefined;
168
174
  suffix?: string | undefined;
169
175
  }>;
170
176
  type OpenAICompatibleCompletionProviderOptions = z.infer<typeof openaiCompatibleCompletionProviderOptions>;
@@ -276,7 +282,7 @@ type OpenAICompatibleImageModelConfig = {
276
282
  currentDate?: () => Date;
277
283
  };
278
284
  };
279
- declare class OpenAICompatibleImageModel implements ImageModelV1 {
285
+ declare class OpenAICompatibleImageModel implements ImageModelV2 {
280
286
  readonly modelId: OpenAICompatibleImageModelId;
281
287
  private readonly settings;
282
288
  private readonly config;
@@ -284,7 +290,7 @@ declare class OpenAICompatibleImageModel implements ImageModelV1 {
284
290
  get maxImagesPerCall(): number;
285
291
  get provider(): string;
286
292
  constructor(modelId: OpenAICompatibleImageModelId, settings: OpenAICompatibleImageSettings, config: OpenAICompatibleImageModelConfig);
287
- doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<ImageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV1['doGenerate']>>>;
293
+ doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, }: Parameters<ImageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV2['doGenerate']>>>;
288
294
  }
289
295
 
290
296
  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'> {
@@ -293,7 +299,7 @@ interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPL
293
299
  chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV2;
294
300
  completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV2;
295
301
  textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV2<string>;
296
- imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV1;
302
+ imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV2;
297
303
  }
298
304
  interface OpenAICompatibleProviderSettings {
299
305
  /**
package/dist/index.js CHANGED
@@ -177,7 +177,11 @@ var openaiCompatibleProviderOptions = import_zod.z.object({
177
177
  * A unique identifier representing your end-user, which can help the provider to
178
178
  * monitor and detect abuse.
179
179
  */
180
- user: import_zod.z.string().optional()
180
+ user: import_zod.z.string().optional(),
181
+ /**
182
+ * Reasoning effort for reasoning models. Defaults to `medium`.
183
+ */
184
+ reasoningEffort: import_zod.z.enum(["low", "medium", "high"]).optional()
181
185
  });
182
186
 
183
187
  // src/openai-compatible-error.ts
@@ -276,7 +280,7 @@ var OpenAICompatibleChatLanguageModel = class {
276
280
  var _a, _b, _c;
277
281
  return (_c = (_b = (_a = this.config).getSupportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
278
282
  }
279
- getArgs({
283
+ async getArgs({
280
284
  prompt,
281
285
  maxOutputTokens,
282
286
  temperature,
@@ -294,12 +298,12 @@ var OpenAICompatibleChatLanguageModel = class {
294
298
  var _a, _b, _c;
295
299
  const warnings = [];
296
300
  const compatibleOptions = Object.assign(
297
- (_a = (0, import_provider_utils.parseProviderOptions)({
301
+ (_a = await (0, import_provider_utils.parseProviderOptions)({
298
302
  provider: "openai-compatible",
299
303
  providerOptions,
300
304
  schema: openaiCompatibleProviderOptions
301
305
  })) != null ? _a : {},
302
- (_b = (0, import_provider_utils.parseProviderOptions)({
306
+ (_b = await (0, import_provider_utils.parseProviderOptions)({
303
307
  provider: this.providerOptionsName,
304
308
  providerOptions,
305
309
  schema: openaiCompatibleProviderOptions
@@ -346,6 +350,7 @@ var OpenAICompatibleChatLanguageModel = class {
346
350
  stop: stopSequences,
347
351
  seed,
348
352
  ...providerOptions == null ? void 0 : providerOptions[this.providerOptionsName],
353
+ reasoning_effort: compatibleOptions.reasoningEffort,
349
354
  // messages:
350
355
  messages: convertToOpenAICompatibleChatMessages(prompt),
351
356
  // tools:
@@ -357,7 +362,7 @@ var OpenAICompatibleChatLanguageModel = class {
357
362
  }
358
363
  async doGenerate(options) {
359
364
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
360
- const { args, warnings } = this.getArgs({ ...options });
365
+ const { args, warnings } = await this.getArgs({ ...options });
361
366
  const body = JSON.stringify(args);
362
367
  const {
363
368
  responseHeaders,
@@ -387,7 +392,6 @@ var OpenAICompatibleChatLanguageModel = class {
387
392
  if (reasoning != null && reasoning.length > 0) {
388
393
  content.push({
389
394
  type: "reasoning",
390
- reasoningType: "text",
391
395
  text: reasoning
392
396
  });
393
397
  }
@@ -404,9 +408,9 @@ var OpenAICompatibleChatLanguageModel = class {
404
408
  }
405
409
  const providerMetadata = {
406
410
  [this.providerOptionsName]: {},
407
- ...(_c = (_b = this.config.metadataExtractor) == null ? void 0 : _b.extractMetadata) == null ? void 0 : _c.call(_b, {
411
+ ...await ((_c = (_b = this.config.metadataExtractor) == null ? void 0 : _b.extractMetadata) == null ? void 0 : _c.call(_b, {
408
412
  parsedBody: rawResponse
409
- })
413
+ }))
410
414
  };
411
415
  const completionTokenDetails = (_d = responseBody.usage) == null ? void 0 : _d.completion_tokens_details;
412
416
  const promptTokenDetails = (_e = responseBody.usage) == null ? void 0 : _e.prompt_tokens_details;
@@ -441,7 +445,7 @@ var OpenAICompatibleChatLanguageModel = class {
441
445
  }
442
446
  async doStream(options) {
443
447
  var _a;
444
- const { args, warnings } = this.getArgs({ ...options });
448
+ const { args, warnings } = await this.getArgs({ ...options });
445
449
  const body = {
446
450
  ...args,
447
451
  stream: true,
@@ -542,7 +546,6 @@ var OpenAICompatibleChatLanguageModel = class {
542
546
  if (delta.reasoning_content != null) {
543
547
  controller.enqueue({
544
548
  type: "reasoning",
545
- reasoningType: "text",
546
549
  text: delta.reasoning_content
547
550
  });
548
551
  }
@@ -834,7 +837,7 @@ var openaiCompatibleCompletionProviderOptions = import_zod4.z.object({
834
837
  * Accepts a JSON object that maps tokens (specified by their token ID in
835
838
  * the GPT tokenizer) to an associated bias value from -100 to 100.
836
839
  */
837
- logitBias: import_zod4.z.record(import_zod4.z.number(), import_zod4.z.number()).optional(),
840
+ logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
838
841
  /**
839
842
  * The suffix that comes after a completion of inserted text.
840
843
  */
@@ -870,7 +873,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
870
873
  var _a, _b, _c;
871
874
  return (_c = (_b = (_a = this.config).getSupportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
872
875
  }
873
- getArgs({
876
+ async getArgs({
874
877
  inputFormat,
875
878
  prompt,
876
879
  maxOutputTokens,
@@ -888,7 +891,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
888
891
  }) {
889
892
  var _a;
890
893
  const warnings = [];
891
- const completionOptions = (_a = (0, import_provider_utils2.parseProviderOptions)({
894
+ const completionOptions = (_a = await (0, import_provider_utils2.parseProviderOptions)({
892
895
  provider: this.providerOptionsName,
893
896
  providerOptions,
894
897
  schema: openaiCompatibleCompletionProviderOptions
@@ -938,7 +941,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
938
941
  }
939
942
  async doGenerate(options) {
940
943
  var _a, _b, _c, _d;
941
- const { args, warnings } = this.getArgs(options);
944
+ const { args, warnings } = await this.getArgs(options);
942
945
  const {
943
946
  responseHeaders,
944
947
  value: response,
@@ -979,7 +982,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
979
982
  };
980
983
  }
981
984
  async doStream(options) {
982
- const { args, warnings } = this.getArgs(options);
985
+ const { args, warnings } = await this.getArgs(options);
983
986
  const body = {
984
987
  ...args,
985
988
  stream: true,
@@ -1147,12 +1150,12 @@ var OpenAICompatibleEmbeddingModel = class {
1147
1150
  }) {
1148
1151
  var _a, _b, _c;
1149
1152
  const compatibleOptions = Object.assign(
1150
- (_a = (0, import_provider_utils3.parseProviderOptions)({
1153
+ (_a = await (0, import_provider_utils3.parseProviderOptions)({
1151
1154
  provider: "openai-compatible",
1152
1155
  providerOptions,
1153
1156
  schema: openaiCompatibleEmbeddingProviderOptions
1154
1157
  })) != null ? _a : {},
1155
- (_b = (0, import_provider_utils3.parseProviderOptions)({
1158
+ (_b = await (0, import_provider_utils3.parseProviderOptions)({
1156
1159
  provider: this.providerOptionsName,
1157
1160
  providerOptions,
1158
1161
  schema: openaiCompatibleEmbeddingProviderOptions