@llmgateway/ai-sdk-provider 2.1.0 → 2.2.0

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/dist/index.d.mts CHANGED
@@ -2736,8 +2736,7 @@ declare const models: [{
2736
2736
  readonly jsonOutput: true;
2737
2737
  }];
2738
2738
 
2739
- type ProviderModelName$1 = (typeof models)[number]['providers'][number]['modelName'];
2740
- type LLMGatewayChatModelId = (typeof models)[number]['id'] | `${Provider}/${ProviderModelName$1}` | 'test-model';
2739
+ type LLMGatewayChatModelId = (typeof models)[number]['id'] | `${Provider}/${(typeof models)[number]['id']}` | 'test-model';
2741
2740
  type LLMGatewayChatSettings = {
2742
2741
  /**
2743
2742
  Modify the likelihood of specified tokens appearing in the completion.
@@ -2833,8 +2832,6 @@ type LLMGatewayUsageAccounting = {
2833
2832
  };
2834
2833
  };
2835
2834
 
2836
- type ProviderModelName = (typeof models)[number]['providers'][number]['modelName'];
2837
- type LLMGatewayCompletionModelId = (typeof models)[number]['id'] | `${Provider}/${ProviderModelName}`;
2838
2835
  type LLMGatewayCompletionSettings = {
2839
2836
  /**
2840
2837
  Modify the likelihood of specified tokens appearing in the completion.
@@ -2935,12 +2932,12 @@ type LLMGatewayCompletionConfig = {
2935
2932
  declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
2936
2933
  readonly specificationVersion: "v2";
2937
2934
  readonly provider = "llmgateway";
2938
- readonly modelId: LLMGatewayCompletionModelId;
2935
+ readonly modelId: LLMGatewayChatModelId;
2939
2936
  readonly supportedUrls: Record<string, RegExp[]>;
2940
2937
  readonly defaultObjectGenerationMode: undefined;
2941
2938
  readonly settings: LLMGatewayCompletionSettings;
2942
2939
  private readonly config;
2943
- constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
2940
+ constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
2944
2941
  private getArgs;
2945
2942
  doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
2946
2943
  doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
@@ -2958,7 +2955,7 @@ interface LLMGatewayProvider extends LanguageModelV2 {
2958
2955
  /**
2959
2956
  Creates an LLMGateway completion model for text generation.
2960
2957
  */
2961
- completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
2958
+ completion(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
2962
2959
  }
2963
2960
  interface LLMGatewayProviderSettings {
2964
2961
  /**
@@ -3026,7 +3023,7 @@ declare class LLMGateway {
3026
3023
  constructor(options?: LLMGatewayProviderSettings);
3027
3024
  private get baseConfig();
3028
3025
  chat(modelId: LLMGatewayChatModelId, settings?: LLMGatewayChatSettings): LLMGatewayChatLanguageModel;
3029
- completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
3026
+ completion(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
3030
3027
  }
3031
3028
 
3032
3029
  export { LLMGateway, type LLMGatewayCompletionSettings, type LLMGatewayProvider, type LLMGatewayProviderOptions, type LLMGatewayProviderSettings, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting, createLLMGateway, llmgateway };
package/dist/index.d.ts CHANGED
@@ -2736,8 +2736,7 @@ declare const models: [{
2736
2736
  readonly jsonOutput: true;
2737
2737
  }];
2738
2738
 
2739
- type ProviderModelName$1 = (typeof models)[number]['providers'][number]['modelName'];
2740
- type LLMGatewayChatModelId = (typeof models)[number]['id'] | `${Provider}/${ProviderModelName$1}` | 'test-model';
2739
+ type LLMGatewayChatModelId = (typeof models)[number]['id'] | `${Provider}/${(typeof models)[number]['id']}` | 'test-model';
2741
2740
  type LLMGatewayChatSettings = {
2742
2741
  /**
2743
2742
  Modify the likelihood of specified tokens appearing in the completion.
@@ -2833,8 +2832,6 @@ type LLMGatewayUsageAccounting = {
2833
2832
  };
2834
2833
  };
2835
2834
 
2836
- type ProviderModelName = (typeof models)[number]['providers'][number]['modelName'];
2837
- type LLMGatewayCompletionModelId = (typeof models)[number]['id'] | `${Provider}/${ProviderModelName}`;
2838
2835
  type LLMGatewayCompletionSettings = {
2839
2836
  /**
2840
2837
  Modify the likelihood of specified tokens appearing in the completion.
@@ -2935,12 +2932,12 @@ type LLMGatewayCompletionConfig = {
2935
2932
  declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
2936
2933
  readonly specificationVersion: "v2";
2937
2934
  readonly provider = "llmgateway";
2938
- readonly modelId: LLMGatewayCompletionModelId;
2935
+ readonly modelId: LLMGatewayChatModelId;
2939
2936
  readonly supportedUrls: Record<string, RegExp[]>;
2940
2937
  readonly defaultObjectGenerationMode: undefined;
2941
2938
  readonly settings: LLMGatewayCompletionSettings;
2942
2939
  private readonly config;
2943
- constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
2940
+ constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
2944
2941
  private getArgs;
2945
2942
  doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
2946
2943
  doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
@@ -2958,7 +2955,7 @@ interface LLMGatewayProvider extends LanguageModelV2 {
2958
2955
  /**
2959
2956
  Creates an LLMGateway completion model for text generation.
2960
2957
  */
2961
- completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
2958
+ completion(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
2962
2959
  }
2963
2960
  interface LLMGatewayProviderSettings {
2964
2961
  /**
@@ -3026,7 +3023,7 @@ declare class LLMGateway {
3026
3023
  constructor(options?: LLMGatewayProviderSettings);
3027
3024
  private get baseConfig();
3028
3025
  chat(modelId: LLMGatewayChatModelId, settings?: LLMGatewayChatSettings): LLMGatewayChatLanguageModel;
3029
- completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
3026
+ completion(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
3030
3027
  }
3031
3028
 
3032
3029
  export { LLMGateway, type LLMGatewayCompletionSettings, type LLMGatewayProvider, type LLMGatewayProviderOptions, type LLMGatewayProviderSettings, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting, createLLMGateway, llmgateway };
package/dist/index.js CHANGED
@@ -1355,6 +1355,7 @@ var LLMGatewayChatLanguageModel = class {
1355
1355
  tools,
1356
1356
  toolChoice
1357
1357
  }) {
1358
+ var _a15;
1358
1359
  const baseArgs = __spreadValues(__spreadValues({
1359
1360
  // model id:
1360
1361
  model: this.modelId,
@@ -1383,6 +1384,19 @@ var LLMGatewayChatLanguageModel = class {
1383
1384
  usage: this.settings.usage
1384
1385
  }, this.config.extraBody), this.settings.extraBody);
1385
1386
  if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
1387
+ if ("schema" in responseFormat && responseFormat.schema) {
1388
+ return __spreadProps(__spreadValues({}, baseArgs), {
1389
+ response_format: {
1390
+ type: "json_schema",
1391
+ json_schema: {
1392
+ name: responseFormat.schema.name || "response",
1393
+ description: responseFormat.schema.description,
1394
+ schema: responseFormat.schema,
1395
+ strict: (_a15 = responseFormat.schema.strict) != null ? _a15 : true
1396
+ }
1397
+ }
1398
+ });
1399
+ }
1386
1400
  return __spreadProps(__spreadValues({}, baseArgs), {
1387
1401
  response_format: { type: "json_object" }
1388
1402
  });
@@ -1475,7 +1489,9 @@ var LLMGatewayChatLanguageModel = class {
1475
1489
  }
1476
1490
  }
1477
1491
  return null;
1478
- }).filter((p) => p !== null) : choice.message.reasoning ? [
1492
+ }).filter(
1493
+ (p) => p !== null
1494
+ ) : choice.message.reasoning ? [
1479
1495
  {
1480
1496
  type: "reasoning",
1481
1497
  text: choice.message.reasoning