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

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,29 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 1.0.0-canary.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9bf7291]
8
+ - Updated dependencies [4617fab]
9
+ - Updated dependencies [e030615]
10
+ - @ai-sdk/provider@2.0.0-canary.11
11
+ - @ai-sdk/provider-utils@3.0.0-canary.12
12
+
13
+ ## 1.0.0-canary.11
14
+
15
+ ### Patch Changes
16
+
17
+ - db72adc: chore(providers/openai): update completion model to use providerOptions
18
+ - 42e32b0: feat(providers/xai): add reasoningEffort provider option
19
+ - 66962ed: fix(packages): export node10 compatible types
20
+ - 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
21
+ - Updated dependencies [66962ed]
22
+ - Updated dependencies [9301f86]
23
+ - Updated dependencies [a3f768e]
24
+ - @ai-sdk/provider-utils@3.0.0-canary.11
25
+ - @ai-sdk/provider@2.0.0-canary.10
26
+
3
27
  ## 1.0.0-canary.10
4
28
 
5
29
  ### 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
  }
@@ -746,13 +749,9 @@ var import_zod5 = require("zod");
746
749
  var import_provider4 = require("@ai-sdk/provider");
747
750
  function convertToOpenAICompatibleCompletionPrompt({
748
751
  prompt,
749
- inputFormat,
750
752
  user = "user",
751
753
  assistant = "assistant"
752
754
  }) {
753
- if (inputFormat === "prompt" && prompt.length === 1 && prompt[0].role === "user" && prompt[0].content.length === 1 && prompt[0].content[0].type === "text") {
754
- return { prompt: prompt[0].content[0].text };
755
- }
756
755
  let text = "";
757
756
  if (prompt[0].role === "system") {
758
757
  text += `${prompt[0].content}
@@ -834,7 +833,7 @@ var openaiCompatibleCompletionProviderOptions = import_zod4.z.object({
834
833
  * Accepts a JSON object that maps tokens (specified by their token ID in
835
834
  * the GPT tokenizer) to an associated bias value from -100 to 100.
836
835
  */
837
- logitBias: import_zod4.z.record(import_zod4.z.number(), import_zod4.z.number()).optional(),
836
+ logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
838
837
  /**
839
838
  * The suffix that comes after a completion of inserted text.
840
839
  */
@@ -870,8 +869,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
870
869
  var _a, _b, _c;
871
870
  return (_c = (_b = (_a = this.config).getSupportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
872
871
  }
873
- getArgs({
874
- inputFormat,
872
+ async getArgs({
875
873
  prompt,
876
874
  maxOutputTokens,
877
875
  temperature,
@@ -888,7 +886,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
888
886
  }) {
889
887
  var _a;
890
888
  const warnings = [];
891
- const completionOptions = (_a = (0, import_provider_utils2.parseProviderOptions)({
889
+ const completionOptions = (_a = await (0, import_provider_utils2.parseProviderOptions)({
892
890
  provider: this.providerOptionsName,
893
891
  providerOptions,
894
892
  schema: openaiCompatibleCompletionProviderOptions
@@ -909,7 +907,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
909
907
  details: "JSON response format is not supported."
910
908
  });
911
909
  }
912
- const { prompt: completionPrompt, stopSequences } = convertToOpenAICompatibleCompletionPrompt({ prompt, inputFormat });
910
+ const { prompt: completionPrompt, stopSequences } = convertToOpenAICompatibleCompletionPrompt({ prompt });
913
911
  const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
914
912
  return {
915
913
  args: {
@@ -938,7 +936,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
938
936
  }
939
937
  async doGenerate(options) {
940
938
  var _a, _b, _c, _d;
941
- const { args, warnings } = this.getArgs(options);
939
+ const { args, warnings } = await this.getArgs(options);
942
940
  const {
943
941
  responseHeaders,
944
942
  value: response,
@@ -979,7 +977,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
979
977
  };
980
978
  }
981
979
  async doStream(options) {
982
- const { args, warnings } = this.getArgs(options);
980
+ const { args, warnings } = await this.getArgs(options);
983
981
  const body = {
984
982
  ...args,
985
983
  stream: true,
@@ -1147,12 +1145,12 @@ var OpenAICompatibleEmbeddingModel = class {
1147
1145
  }) {
1148
1146
  var _a, _b, _c;
1149
1147
  const compatibleOptions = Object.assign(
1150
- (_a = (0, import_provider_utils3.parseProviderOptions)({
1148
+ (_a = await (0, import_provider_utils3.parseProviderOptions)({
1151
1149
  provider: "openai-compatible",
1152
1150
  providerOptions,
1153
1151
  schema: openaiCompatibleEmbeddingProviderOptions
1154
1152
  })) != null ? _a : {},
1155
- (_b = (0, import_provider_utils3.parseProviderOptions)({
1153
+ (_b = await (0, import_provider_utils3.parseProviderOptions)({
1156
1154
  provider: this.providerOptionsName,
1157
1155
  providerOptions,
1158
1156
  schema: openaiCompatibleEmbeddingProviderOptions