@jerome-benoit/sap-ai-provider-v2 4.7.0 → 4.8.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.
Files changed (35) hide show
  1. package/README.md +26 -31
  2. package/dist/{chunk-TVXWNZQT.js → chunk-3ZSXTKOK.js} +607 -210
  3. package/dist/chunk-3ZSXTKOK.js.map +1 -0
  4. package/dist/{chunk-GMMX46AH.js → chunk-BVDSJ4IZ.js} +10 -4
  5. package/dist/chunk-BVDSJ4IZ.js.map +1 -0
  6. package/dist/{chunk-36DFHUVQ.js → chunk-H5KD4EPO.js} +8 -2
  7. package/dist/chunk-H5KD4EPO.js.map +1 -0
  8. package/dist/{chunk-WDUOKIKD.js → chunk-KVOLFUQJ.js} +4 -2
  9. package/dist/chunk-KVOLFUQJ.js.map +1 -0
  10. package/dist/{chunk-BZZJKLDG.js → chunk-TQXCNZBC.js} +11 -5
  11. package/dist/chunk-TQXCNZBC.js.map +1 -0
  12. package/dist/{foundation-models-embedding-model-strategy-YWPDIJEN.js → foundation-models-embedding-model-strategy-SWRJNFD4.js} +7 -6
  13. package/dist/foundation-models-embedding-model-strategy-SWRJNFD4.js.map +1 -0
  14. package/dist/{foundation-models-language-model-strategy-WDSQWU64.js → foundation-models-language-model-strategy-LRAC25ZY.js} +14 -9
  15. package/dist/foundation-models-language-model-strategy-LRAC25ZY.js.map +1 -0
  16. package/dist/index.cjs +658 -228
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +24 -1
  19. package/dist/index.d.ts +24 -1
  20. package/dist/index.js +14 -10
  21. package/dist/index.js.map +1 -1
  22. package/dist/{orchestration-embedding-model-strategy-66QYAO64.js → orchestration-embedding-model-strategy-C5G735Q2.js} +8 -7
  23. package/dist/orchestration-embedding-model-strategy-C5G735Q2.js.map +1 -0
  24. package/dist/{orchestration-language-model-strategy-4TKRZK7U.js → orchestration-language-model-strategy-NUHYRIXH.js} +17 -10
  25. package/dist/orchestration-language-model-strategy-NUHYRIXH.js.map +1 -0
  26. package/package.json +19 -21
  27. package/dist/chunk-36DFHUVQ.js.map +0 -1
  28. package/dist/chunk-BZZJKLDG.js.map +0 -1
  29. package/dist/chunk-GMMX46AH.js.map +0 -1
  30. package/dist/chunk-TVXWNZQT.js.map +0 -1
  31. package/dist/chunk-WDUOKIKD.js.map +0 -1
  32. package/dist/foundation-models-embedding-model-strategy-YWPDIJEN.js.map +0 -1
  33. package/dist/foundation-models-language-model-strategy-WDSQWU64.js.map +0 -1
  34. package/dist/orchestration-embedding-model-strategy-66QYAO64.js.map +0 -1
  35. package/dist/orchestration-language-model-strategy-4TKRZK7U.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { EmbeddingModelV2, SharedV2ProviderOptions, SharedV2ProviderMetadata, SharedV2Headers, LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2ResponseMetadata, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2StreamPart, ProviderV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { DeploymentIdConfig, ResourceGroupConfig } from '@sap-ai-sdk/ai-api/internal.js';
3
+ import { CustomRequestConfig } from '@sap-ai-sdk/core';
4
+ export { CustomRequestConfig } from '@sap-ai-sdk/core';
3
5
  import { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
6
+ export { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
4
7
  import { AzureOpenAiChatCompletionParameters } from '@sap-ai-sdk/foundation-models';
5
8
  import { OrchestrationModuleConfig, FilteringModule, GroundingModule, MaskingModule, OrchestrationConfigRef, ChatCompletionTool, TranslationModule, ChatModel } from '@sap-ai-sdk/orchestration';
6
9
  export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMessage, ChatMessageContent, ChatMessages, Citation, DeveloperChatMessage, DocumentTranslationApplyToSelector, FileContent, FilteringModule, FunctionObject, GroundingModule, ImageContentUrl, LlmModelDetails, LlmModelParams, MaskingModule, OrchestrationClient, OrchestrationConfigRef, OrchestrationEmbeddingClient, OrchestrationEmbeddingResponse, OrchestrationError, OrchestrationErrorResponse, OrchestrationModuleConfig, OrchestrationModuleConfigList, OrchestrationResponse, OrchestrationStream, OrchestrationStreamChunkResponse, OrchestrationStreamResponse, PromptTemplatingModule, SystemChatMessage, ToolChatMessage, TranslationApplyToCategory, TranslationInputParameters, TranslationModule, TranslationOutputParameters, TranslationTargetLanguage, UserChatMessage, UserChatMessageContent, UserChatMessageContentItem, buildAzureContentSafetyFilter, buildDocumentGroundingConfig, buildDpiMaskingProvider, buildLlamaGuard38BFilter, buildTranslationConfig } from '@sap-ai-sdk/orchestration';
@@ -289,7 +292,7 @@ interface SAPAIEmbeddingSettings {
289
292
  *
290
293
  * Model availability depends on tenant configuration and region.
291
294
  * Common values include: `'gpt-4.1'`, `'gpt-4.1-mini'`, `'anthropic--claude-4.5-sonnet'`, `'gemini-2.5-pro'`.
292
- * @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub|SAP AI Core Models}
295
+ * @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub | SAP AI Core Models}
293
296
  */
294
297
  type SAPAIModelId = ChatModel;
295
298
  /**
@@ -310,6 +313,8 @@ interface SAPAISettings {
310
313
  /** @default true */
311
314
  readonly escapeTemplatePlaceholders?: boolean;
312
315
  /** Orchestration API only. */
316
+ readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
317
+ /** Orchestration API only. */
313
318
  readonly filtering?: FilteringModule;
314
319
  /** Orchestration API only. */
315
320
  readonly grounding?: GroundingModule;
@@ -351,6 +356,7 @@ interface SAPAIEmbeddingModelV2Config {
351
356
  readonly destination?: HttpDestinationOrFetchOptions;
352
357
  readonly provider: string;
353
358
  readonly providerApi?: SAPAIApiType;
359
+ readonly requestConfig?: CustomRequestConfig;
354
360
  }
355
361
  /**
356
362
  * SAP AI Core Embedding Model implementing Vercel AI SDK EmbeddingModelV2.
@@ -505,6 +511,7 @@ interface SAPAILanguageModelV2Config {
505
511
  readonly destination?: HttpDestinationOrFetchOptions;
506
512
  readonly provider: string;
507
513
  readonly providerApi?: SAPAIApiType;
514
+ readonly requestConfig?: CustomRequestConfig;
508
515
  }
509
516
  /**
510
517
  * SAP AI Language Model implementing Vercel AI SDK LanguageModelV2.
@@ -614,6 +621,21 @@ interface SAPAIProviderSettings {
614
621
  * @default 'sap-ai'
615
622
  */
616
623
  readonly name?: string;
624
+ /**
625
+ * Custom request configuration forwarded to the underlying SAP AI SDK client on every
626
+ * call created from this provider.
627
+ *
628
+ * Provider-level only (not overridable per-call via `providerOptions['sap-ai']`). The
629
+ * AI SDK `abortSignal` option always wins over any `signal` on `requestConfig`; the
630
+ * latter is dropped before the request is forwarded. Node-only knobs (`httpAgent`,
631
+ * `httpsAgent`) are silently ignored on Edge / Cloudflare Workers runtimes.
632
+ *
633
+ * See the "Note on `requestConfig`" section under `SAPAIProviderSettings` in
634
+ * `API_REFERENCE.md` for the full SAP AI Core `AI-*` header guidance.
635
+ * @see {@link https://sap.github.io/ai-sdk/docs/js/getting-started | SAP Cloud SDK for AI (JS)}
636
+ * @see {@link https://github.com/jerome-benoit/sap-ai-provider/blob/main/API_REFERENCE.md#requestconfig-note | Note on `requestConfig` (API_REFERENCE.md)}
637
+ */
638
+ readonly requestConfig?: CustomRequestConfig;
617
639
  /**
618
640
  * SAP AI Core resource group for resource isolation and access control.
619
641
  * @default 'default'
@@ -644,6 +666,7 @@ interface SAPAIProviderV2 extends ProviderV2 {
644
666
  * @param options.destination - Custom SAP Cloud SDK destination configuration.
645
667
  * @param options.logLevel - Log level for SAP Cloud SDK loggers (`'debug'`, `'info'`, `'warn'`, `'error'`).
646
668
  * @param options.name - Provider name used as key in `providerOptions` (default: `'sap-ai'`).
669
+ * @param options.requestConfig - Provider-level custom request configuration. See {@link SAPAIProviderSettings.requestConfig} for scope, portability, and abort semantics.
647
670
  * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`).
648
671
  * @param options.warnOnAmbiguousConfig - Whether to warn when both deploymentId and resourceGroup are set.
649
672
  * @returns A configured SAP AI provider instance that can be used as a callable or via methods.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { EmbeddingModelV2, SharedV2ProviderOptions, SharedV2ProviderMetadata, SharedV2Headers, LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2ResponseMetadata, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2StreamPart, ProviderV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { DeploymentIdConfig, ResourceGroupConfig } from '@sap-ai-sdk/ai-api/internal.js';
3
+ import { CustomRequestConfig } from '@sap-ai-sdk/core';
4
+ export { CustomRequestConfig } from '@sap-ai-sdk/core';
3
5
  import { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
6
+ export { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
4
7
  import { AzureOpenAiChatCompletionParameters } from '@sap-ai-sdk/foundation-models';
5
8
  import { OrchestrationModuleConfig, FilteringModule, GroundingModule, MaskingModule, OrchestrationConfigRef, ChatCompletionTool, TranslationModule, ChatModel } from '@sap-ai-sdk/orchestration';
6
9
  export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMessage, ChatMessageContent, ChatMessages, Citation, DeveloperChatMessage, DocumentTranslationApplyToSelector, FileContent, FilteringModule, FunctionObject, GroundingModule, ImageContentUrl, LlmModelDetails, LlmModelParams, MaskingModule, OrchestrationClient, OrchestrationConfigRef, OrchestrationEmbeddingClient, OrchestrationEmbeddingResponse, OrchestrationError, OrchestrationErrorResponse, OrchestrationModuleConfig, OrchestrationModuleConfigList, OrchestrationResponse, OrchestrationStream, OrchestrationStreamChunkResponse, OrchestrationStreamResponse, PromptTemplatingModule, SystemChatMessage, ToolChatMessage, TranslationApplyToCategory, TranslationInputParameters, TranslationModule, TranslationOutputParameters, TranslationTargetLanguage, UserChatMessage, UserChatMessageContent, UserChatMessageContentItem, buildAzureContentSafetyFilter, buildDocumentGroundingConfig, buildDpiMaskingProvider, buildLlamaGuard38BFilter, buildTranslationConfig } from '@sap-ai-sdk/orchestration';
@@ -289,7 +292,7 @@ interface SAPAIEmbeddingSettings {
289
292
  *
290
293
  * Model availability depends on tenant configuration and region.
291
294
  * Common values include: `'gpt-4.1'`, `'gpt-4.1-mini'`, `'anthropic--claude-4.5-sonnet'`, `'gemini-2.5-pro'`.
292
- * @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub|SAP AI Core Models}
295
+ * @see {@link https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/models-and-scenarios-in-generative-ai-hub | SAP AI Core Models}
293
296
  */
294
297
  type SAPAIModelId = ChatModel;
295
298
  /**
@@ -310,6 +313,8 @@ interface SAPAISettings {
310
313
  /** @default true */
311
314
  readonly escapeTemplatePlaceholders?: boolean;
312
315
  /** Orchestration API only. */
316
+ readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
317
+ /** Orchestration API only. */
313
318
  readonly filtering?: FilteringModule;
314
319
  /** Orchestration API only. */
315
320
  readonly grounding?: GroundingModule;
@@ -351,6 +356,7 @@ interface SAPAIEmbeddingModelV2Config {
351
356
  readonly destination?: HttpDestinationOrFetchOptions;
352
357
  readonly provider: string;
353
358
  readonly providerApi?: SAPAIApiType;
359
+ readonly requestConfig?: CustomRequestConfig;
354
360
  }
355
361
  /**
356
362
  * SAP AI Core Embedding Model implementing Vercel AI SDK EmbeddingModelV2.
@@ -505,6 +511,7 @@ interface SAPAILanguageModelV2Config {
505
511
  readonly destination?: HttpDestinationOrFetchOptions;
506
512
  readonly provider: string;
507
513
  readonly providerApi?: SAPAIApiType;
514
+ readonly requestConfig?: CustomRequestConfig;
508
515
  }
509
516
  /**
510
517
  * SAP AI Language Model implementing Vercel AI SDK LanguageModelV2.
@@ -614,6 +621,21 @@ interface SAPAIProviderSettings {
614
621
  * @default 'sap-ai'
615
622
  */
616
623
  readonly name?: string;
624
+ /**
625
+ * Custom request configuration forwarded to the underlying SAP AI SDK client on every
626
+ * call created from this provider.
627
+ *
628
+ * Provider-level only (not overridable per-call via `providerOptions['sap-ai']`). The
629
+ * AI SDK `abortSignal` option always wins over any `signal` on `requestConfig`; the
630
+ * latter is dropped before the request is forwarded. Node-only knobs (`httpAgent`,
631
+ * `httpsAgent`) are silently ignored on Edge / Cloudflare Workers runtimes.
632
+ *
633
+ * See the "Note on `requestConfig`" section under `SAPAIProviderSettings` in
634
+ * `API_REFERENCE.md` for the full SAP AI Core `AI-*` header guidance.
635
+ * @see {@link https://sap.github.io/ai-sdk/docs/js/getting-started | SAP Cloud SDK for AI (JS)}
636
+ * @see {@link https://github.com/jerome-benoit/sap-ai-provider/blob/main/API_REFERENCE.md#requestconfig-note | Note on `requestConfig` (API_REFERENCE.md)}
637
+ */
638
+ readonly requestConfig?: CustomRequestConfig;
617
639
  /**
618
640
  * SAP AI Core resource group for resource isolation and access control.
619
641
  * @default 'default'
@@ -644,6 +666,7 @@ interface SAPAIProviderV2 extends ProviderV2 {
644
666
  * @param options.destination - Custom SAP Cloud SDK destination configuration.
645
667
  * @param options.logLevel - Log level for SAP Cloud SDK loggers (`'debug'`, `'info'`, `'warn'`, `'error'`).
646
668
  * @param options.name - Provider name used as key in `providerOptions` (default: `'sap-ai'`).
669
+ * @param options.requestConfig - Provider-level custom request configuration. See {@link SAPAIProviderSettings.requestConfig} for scope, portability, and abort semantics.
647
670
  * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`).
648
671
  * @param options.warnOnAmbiguousConfig - Whether to warn when both deploymentId and resourceGroup are set.
649
672
  * @returns A configured SAP AI provider instance that can be used as a callable or via methods.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  mergeSettingsWithApi,
4
4
  resolveApi,
5
5
  validateSettings
6
- } from "./chunk-WDUOKIKD.js";
6
+ } from "./chunk-KVOLFUQJ.js";
7
7
  import {
8
8
  escapeOrchestrationPlaceholders,
9
9
  unescapeOrchestrationPlaceholders
@@ -20,7 +20,7 @@ import {
20
20
  sapAILanguageModelProviderOptions,
21
21
  validateEmbeddingModelParamsSettings,
22
22
  validateModelParamsSettings
23
- } from "./chunk-TVXWNZQT.js";
23
+ } from "./chunk-3ZSXTKOK.js";
24
24
 
25
25
  // src/sap-ai-adapters-v3-to-v2.ts
26
26
  function convertFinishReasonToV2(internalFinishReason) {
@@ -253,21 +253,21 @@ function getOrCreateLanguageModelStrategy(api) {
253
253
  async function createEmbeddingModelStrategy(api) {
254
254
  if (api === "foundation-models") {
255
255
  const { AzureOpenAiEmbeddingClient } = await import("@sap-ai-sdk/foundation-models");
256
- const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-YWPDIJEN.js");
256
+ const { FoundationModelsEmbeddingModelStrategy } = await import("./foundation-models-embedding-model-strategy-SWRJNFD4.js");
257
257
  return new FoundationModelsEmbeddingModelStrategy(AzureOpenAiEmbeddingClient);
258
258
  }
259
259
  const { OrchestrationEmbeddingClient: OrchestrationEmbeddingClient2 } = await import("@sap-ai-sdk/orchestration");
260
- const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-66QYAO64.js");
260
+ const { OrchestrationEmbeddingModelStrategy } = await import("./orchestration-embedding-model-strategy-C5G735Q2.js");
261
261
  return new OrchestrationEmbeddingModelStrategy(OrchestrationEmbeddingClient2);
262
262
  }
263
263
  async function createLanguageModelStrategy(api) {
264
264
  if (api === "foundation-models") {
265
265
  const { AzureOpenAiChatClient } = await import("@sap-ai-sdk/foundation-models");
266
- const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-WDSQWU64.js");
266
+ const { FoundationModelsLanguageModelStrategy } = await import("./foundation-models-language-model-strategy-LRAC25ZY.js");
267
267
  return new FoundationModelsLanguageModelStrategy(AzureOpenAiChatClient);
268
268
  }
269
269
  const { OrchestrationClient: OrchestrationClient2 } = await import("@sap-ai-sdk/orchestration");
270
- const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-4TKRZK7U.js");
270
+ const { OrchestrationLanguageModelStrategy } = await import("./orchestration-language-model-strategy-NUHYRIXH.js");
271
271
  return new OrchestrationLanguageModelStrategy(OrchestrationClient2);
272
272
  }
273
273
 
@@ -316,7 +316,8 @@ var SAPAIEmbeddingModel = class {
316
316
  deploymentConfig: this.config.deploymentConfig,
317
317
  destination: this.config.destination,
318
318
  modelId: this.modelId,
319
- provider: this.config.provider
319
+ provider: this.config.provider,
320
+ requestConfig: this.config.requestConfig
320
321
  };
321
322
  return strategy.doEmbed(strategyConfig, this.settings, options, this.maxEmbeddingsPerCall);
322
323
  }
@@ -452,7 +453,8 @@ var SAPAILanguageModel = class {
452
453
  deploymentConfig: this.config.deploymentConfig,
453
454
  destination: this.config.destination,
454
455
  modelId: this.modelId,
455
- provider: this.config.provider
456
+ provider: this.config.provider,
457
+ requestConfig: this.config.requestConfig
456
458
  };
457
459
  return { strategy, strategyConfig };
458
460
  }
@@ -545,7 +547,8 @@ function createSAPAIProvider(options = {}) {
545
547
  deploymentConfig,
546
548
  destination: options.destination,
547
549
  provider: `${providerName}.chat`,
548
- providerApi
550
+ providerApi,
551
+ requestConfig: options.requestConfig
549
552
  });
550
553
  };
551
554
  const createEmbeddingModel = (modelId, settings = {}) => {
@@ -561,7 +564,8 @@ function createSAPAIProvider(options = {}) {
561
564
  deploymentConfig,
562
565
  destination: options.destination,
563
566
  provider: `${providerName}.embedding`,
564
- providerApi
567
+ providerApi,
568
+ requestConfig: options.requestConfig
565
569
  });
566
570
  };
567
571
  const provider = function(modelId, settings) {