@jerome-benoit/sap-ai-provider-v2 5.0.0 → 5.0.2

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 (40) hide show
  1. package/README.md +90 -48
  2. package/dist/chunk-77JSAAPE.js +778 -0
  3. package/dist/chunk-77JSAAPE.js.map +1 -0
  4. package/dist/{chunk-Q5JV4I6D.js → chunk-LEME2MFD.js} +59 -387
  5. package/dist/chunk-LEME2MFD.js.map +1 -0
  6. package/dist/{chunk-TXZZURBA.js → chunk-NLMWIVG7.js} +17 -7
  7. package/dist/chunk-NLMWIVG7.js.map +1 -0
  8. package/dist/chunk-QZOZ3PZT.js +634 -0
  9. package/dist/chunk-QZOZ3PZT.js.map +1 -0
  10. package/dist/{chunk-FY2HO62O.js → chunk-U6WJSLR7.js} +19 -11
  11. package/dist/chunk-U6WJSLR7.js.map +1 -0
  12. package/dist/{chunk-QDUZRLMI.js → chunk-YP3AADWD.js} +47 -40
  13. package/dist/chunk-YP3AADWD.js.map +1 -0
  14. package/dist/{foundation-models-embedding-model-strategy-JJBN3TQI.js → foundation-models-embedding-model-strategy-A3WDDAYK.js} +8 -9
  15. package/dist/foundation-models-embedding-model-strategy-A3WDDAYK.js.map +1 -0
  16. package/dist/{foundation-models-language-model-strategy-6ELKE34K.js → foundation-models-language-model-strategy-6U6KK6KH.js} +18 -21
  17. package/dist/foundation-models-language-model-strategy-6U6KK6KH.js.map +1 -0
  18. package/dist/index.cjs +1325 -31669
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +60 -55
  21. package/dist/index.d.ts +60 -55
  22. package/dist/index.js +48 -194
  23. package/dist/index.js.map +1 -1
  24. package/dist/{orchestration-embedding-model-strategy-QI72OB3E.js → orchestration-embedding-model-strategy-JO3QH5MR.js} +7 -11
  25. package/dist/orchestration-embedding-model-strategy-JO3QH5MR.js.map +1 -0
  26. package/dist/{orchestration-language-model-strategy-X4FZNLSA.js → orchestration-language-model-strategy-MBVA7BYX.js} +27 -28
  27. package/dist/orchestration-language-model-strategy-MBVA7BYX.js.map +1 -0
  28. package/package.json +15 -12
  29. package/dist/chunk-BIBSYTMU.js +0 -31085
  30. package/dist/chunk-BIBSYTMU.js.map +0 -1
  31. package/dist/chunk-FY2HO62O.js.map +0 -1
  32. package/dist/chunk-Q5JV4I6D.js.map +0 -1
  33. package/dist/chunk-QDUZRLMI.js.map +0 -1
  34. package/dist/chunk-TXZZURBA.js.map +0 -1
  35. package/dist/chunk-WNR7DC4V.js +0 -251
  36. package/dist/chunk-WNR7DC4V.js.map +0 -1
  37. package/dist/foundation-models-embedding-model-strategy-JJBN3TQI.js.map +0 -1
  38. package/dist/foundation-models-language-model-strategy-6ELKE34K.js.map +0 -1
  39. package/dist/orchestration-embedding-model-strategy-QI72OB3E.js.map +0 -1
  40. package/dist/orchestration-language-model-strategy-X4FZNLSA.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ export { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
6
6
  import { AzureOpenAiChatCompletionParameters } from '@sap-ai-sdk/foundation-models';
7
7
  import { OrchestrationConfigRefOverride, OrchestrationModuleConfig, FilteringModule, GroundingModule, MaskingModule, OrchestrationConfigRefById, OrchestrationConfigRefByName, ChatCompletionTool, TranslationModule, ChatModel } from '@sap-ai-sdk/orchestration';
8
8
  export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMessage, ChatMessageContent, ChatMessages, Citation, DeveloperChatMessage, DocumentTranslationApplyToSelector, FileContent, FilteringModule, FunctionObject, GroundingModule, ImageContentUrl, LlmModelDetails, LlmModelParams, MaskingModule, OrchestrationClient, OrchestrationConfigRef, OrchestrationConfigRefById, OrchestrationConfigRefByName, OrchestrationConfigRefOverride, 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';
9
- import { SharedV3Warning, LanguageModelV3StreamPart, LanguageModelV2 as LanguageModelV2$1, LanguageModelV2CallOptions as LanguageModelV2CallOptions$1, LanguageModelV3CallOptions } from '@ai-sdk/provider';
9
+ import { LanguageModelV2 as LanguageModelV2$1, LanguageModelV2CallOptions as LanguageModelV2CallOptions$1, LanguageModelV3CallOptions } from '@ai-sdk/provider';
10
10
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
11
11
  import { InferSchema } from '@ai-sdk/provider-utils';
12
12
 
@@ -15,7 +15,7 @@ declare const SAP_AI_PROVIDER_NAME: "sap-ai";
15
15
  /**
16
16
  * Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
17
17
  * @param providerIdentifier - The full provider identifier string.
18
- * @returns The provider name without any suffix.
18
+ * @returns The prefix before the first dot, or the unchanged identifier when no dot exists.
19
19
  */
20
20
  declare function getProviderName(providerIdentifier: string): string;
21
21
  /** @internal */
@@ -1682,8 +1682,8 @@ type AzureOpenAiChatExtensionConfiguration = NonNullable<AzureOpenAiChatCompleti
1682
1682
  /**
1683
1683
  * Common model parameters shared between both APIs.
1684
1684
  *
1685
- * These parameters control text generation behavior and are validated by Zod schemas
1686
- * when passed via `providerOptions`.
1685
+ * Known parameters are validated by Zod in constructor settings and per-call
1686
+ * `modelParams` provider options; additional model-specific keys are passed through.
1687
1687
  */
1688
1688
  interface CommonModelParams {
1689
1689
  /**
@@ -1698,7 +1698,7 @@ interface CommonModelParams {
1698
1698
  readonly maxTokens?: number;
1699
1699
  /**
1700
1700
  * Number of completions to generate.
1701
- * Not supported by Amazon/Anthropic models.
1701
+ * Availability depends on the selected SAP API and model; no model-family filtering is applied.
1702
1702
  * Range: Positive integer
1703
1703
  */
1704
1704
  readonly n?: number;
@@ -1749,7 +1749,10 @@ interface FoundationModelsModelSettings {
1749
1749
  readonly api: "foundation-models";
1750
1750
  /** Azure OpenAI "On Your Data" configuration for RAG scenarios. */
1751
1751
  readonly dataSources?: AzureOpenAiChatExtensionConfiguration[];
1752
- /** @default false */
1752
+ /**
1753
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1754
+ * @default false
1755
+ */
1753
1756
  readonly includeReasoning?: boolean;
1754
1757
  readonly modelParams?: FoundationModelsModelParams;
1755
1758
  readonly modelVersion?: string;
@@ -1769,7 +1772,7 @@ interface OrchestrationModelSettings {
1769
1772
  readonly escapeTemplatePlaceholders?: boolean;
1770
1773
  /**
1771
1774
  * Additional module configurations for prompt module fallback.
1772
- * The SDK tries the primary configuration first, then each fallback in order until one succeeds.
1775
+ * These entries follow the primary configuration in the list passed to the SAP SDK.
1773
1776
  * Each entry is a full `OrchestrationModuleConfig` with its own model, prompt, and modules.
1774
1777
  * @example
1775
1778
  * ```ts
@@ -1786,7 +1789,10 @@ interface OrchestrationModelSettings {
1786
1789
  readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
1787
1790
  readonly filtering?: FilteringModule;
1788
1791
  readonly grounding?: GroundingModule;
1789
- /** @default false */
1792
+ /**
1793
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1794
+ * @default false
1795
+ */
1790
1796
  readonly includeReasoning?: boolean;
1791
1797
  readonly masking?: MaskingModule | {
1792
1798
  providers: MaskingModule["masking_providers"];
@@ -1797,7 +1803,8 @@ interface OrchestrationModelSettings {
1797
1803
  * Reference to a complete orchestration configuration stored in SAP AI Core Prompt Registry.
1798
1804
  * When provided, local module settings (filtering, masking, grounding, translation, tools,
1799
1805
  * promptTemplateRef, responseFormat) are ignored as the full configuration is managed
1800
- * by the referenced config. Only `placeholderValues` and messages are passed through.
1806
+ * by the referenced config. The reference, including its explicit `overrideConfig`,
1807
+ * is passed to the SAP SDK; messages and `placeholderValues` remain request inputs.
1801
1808
  * @example { id: "f47ac10b-58cc-4372-a567-0e02b2c3d479" }
1802
1809
  * @example { scenario: "customer-support", name: "prod-config", version: "1.0.0" }
1803
1810
  */
@@ -1806,8 +1813,8 @@ interface OrchestrationModelSettings {
1806
1813
  readonly promptTemplateRef?: PromptTemplateRef;
1807
1814
  readonly responseFormat?: ResponseFormat;
1808
1815
  /**
1809
- * Options for streaming behavior with post-LLM modules.
1810
- * Only applies when using `streamText()` with orchestration modules.
1816
+ * Options for streaming behavior with locally configured post-LLM modules.
1817
+ * Includes direct `doStream()` calls; ignored when `orchestrationConfigRef` is used.
1811
1818
  */
1812
1819
  readonly streamOptions?: OrchestrationStreamOptions;
1813
1820
  readonly tools?: ChatCompletionTool[];
@@ -1816,6 +1823,8 @@ interface OrchestrationModelSettings {
1816
1823
  /**
1817
1824
  * Stream options for orchestration post-LLM module processing.
1818
1825
  * Controls chunking behavior for translation, filtering, and other modules during streaming.
1826
+ * Ignored with `orchestrationConfigRef`; configure streaming in the stored
1827
+ * configuration or its `overrideConfig` instead.
1819
1828
  */
1820
1829
  interface OrchestrationStreamOptions {
1821
1830
  /**
@@ -1825,7 +1834,7 @@ interface OrchestrationStreamOptions {
1825
1834
  readonly chunkSize?: number;
1826
1835
  /**
1827
1836
  * Delimiters for splitting stream into chunks (e.g., sentence boundaries).
1828
- * Required when translation module is configured.
1837
+ * Recommended for translation; the provider warns when local translation settings lack them.
1829
1838
  * @example ["\n", ".", "?", "!"]
1830
1839
  */
1831
1840
  readonly delimiters?: readonly string[];
@@ -1869,12 +1878,18 @@ interface SAPAIEmbeddingSettings {
1869
1878
  readonly masking?: MaskingModule | {
1870
1879
  providers: MaskingModule["masking_providers"];
1871
1880
  };
1872
- /** @default 2048 */
1881
+ /**
1882
+ * Maximum batch size: a positive integer, or `Infinity` for no provider-side limit.
1883
+ * @default 2048
1884
+ */
1873
1885
  readonly maxEmbeddingsPerCall?: number;
1874
1886
  readonly modelParams?: FoundationModelsEmbeddingParams | Record<string, unknown>;
1875
1887
  readonly modelVersion?: string;
1876
1888
  readonly [key: string]: unknown;
1877
- /** @default 'text' */
1889
+ /**
1890
+ * Orchestration embedding input type; ignored by Foundation Models.
1891
+ * @default 'text'
1892
+ */
1878
1893
  readonly type?: "document" | "query" | "text";
1879
1894
  }
1880
1895
  /**
@@ -1908,7 +1923,10 @@ interface SAPAISettings {
1908
1923
  readonly filtering?: FilteringModule;
1909
1924
  /** Orchestration API only. */
1910
1925
  readonly grounding?: GroundingModule;
1911
- /** @default false */
1926
+ /**
1927
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1928
+ * @default false
1929
+ */
1912
1930
  readonly includeReasoning?: boolean;
1913
1931
  /** Orchestration API only. */
1914
1932
  readonly masking?: MaskingModule | {
@@ -1923,7 +1941,7 @@ interface SAPAISettings {
1923
1941
  /** Orchestration API only. */
1924
1942
  readonly promptTemplateRef?: PromptTemplateRef;
1925
1943
  readonly responseFormat?: ResponseFormat;
1926
- /** Orchestration API only. */
1944
+ /** Orchestration API only; ignored when `orchestrationConfigRef` is used. */
1927
1945
  readonly streamOptions?: OrchestrationStreamOptions;
1928
1946
  /** Orchestration API only. */
1929
1947
  readonly tools?: ChatCompletionTool[];
@@ -2068,7 +2086,7 @@ declare class ApiSwitchError extends Error {
2068
2086
  * @example
2069
2087
  * ```typescript
2070
2088
  * throw new UnsupportedFeatureError("Content filtering", "foundation-models", "orchestration");
2071
- * // "Content filtering is only available with Orchestration API and will be ignored by Foundation Models API."
2089
+ * // Rejects the request: content filtering requires the Orchestration API.
2072
2090
  * ```
2073
2091
  * @see {@link validateSettings} - Main validation function that throws this error
2074
2092
  * @see {@link ApiSwitchError} - Related error for API switching conflicts
@@ -2080,45 +2098,25 @@ declare class UnsupportedFeatureError extends Error {
2080
2098
  /**
2081
2099
  * Creates a new UnsupportedFeatureError.
2082
2100
  * @param feature - The name of the unsupported feature (e.g., "Content filtering").
2083
- * @param api - The API being used where the feature will be ignored.
2101
+ * @param api - The API being used that does not support the feature.
2084
2102
  * @param suggestedApi - The API that supports this feature.
2085
2103
  */
2086
2104
  constructor(feature: string, api: SAPAIApiType, suggestedApi: SAPAIApiType);
2087
2105
  }
2088
2106
 
2089
- /** Adapters to convert internal (V3) formats to LanguageModelV2 formats for the V2 facade. */
2107
+ /** Adapters for the semantic differences between the V3 core and V2 facade. */
2090
2108
 
2109
+ /** Stream events supported by the V2 facade. */
2091
2110
  type ConvertedV2StreamPart = Exclude<LanguageModelV2StreamPart, {
2092
2111
  type: "stream-start";
2093
2112
  }> | {
2094
2113
  type: "stream-start";
2095
- warnings: ReturnType<typeof convertWarningsToV2>;
2114
+ warnings: ConvertedV2Warning[];
2096
2115
  };
2097
- /**
2098
- * Converts internal warnings array to V2 warnings array.
2099
- * @param internalWarnings - Internal warning objects.
2100
- * @returns V2 warning objects.
2101
- * @internal
2102
- */
2103
- declare function convertWarningsToV2(internalWarnings: SharedV3Warning[]): ReturnType<typeof convertWarningToV2>[];
2104
- /**
2105
- * Converts internal warning to V2 warning format.
2106
- *
2107
- * Maps `unsupported`/`compatibility` warnings to V2 `other` type with descriptive message.
2108
- * @param internalWarning - Internal warning object.
2109
- * @returns V2 warning object.
2110
- * @internal
2111
- */
2112
- declare function convertWarningToV2(internalWarning: SharedV3Warning): Extract<LanguageModelV2CallWarning, {
2116
+ /** V2 warning representation used when adapting V3 feature diagnostics. */
2117
+ type ConvertedV2Warning = Extract<LanguageModelV2CallWarning, {
2113
2118
  type: "other";
2114
2119
  }>;
2115
- /**
2116
- * Transforms internal stream to V2 ReadableStream.
2117
- * @param internalStream - Internal ReadableStream to transform.
2118
- * @returns V2-formatted ReadableStream.
2119
- * @internal
2120
- */
2121
- declare function createV2StreamFromInternal(internalStream: ReadableStream<LanguageModelV3StreamPart>): ReadableStream<ConvertedV2StreamPart>;
2122
2120
 
2123
2121
  /**
2124
2122
  * SAP AI Language Model V2 - Vercel AI SDK LanguageModelV2 implementation for SAP AI Core.
@@ -2202,7 +2200,7 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2$1 {
2202
2200
  headers?: SharedV2Headers;
2203
2201
  };
2204
2202
  usage: LanguageModelV2Usage;
2205
- warnings: ReturnType<typeof convertWarningsToV2>;
2203
+ warnings: ConvertedV2Warning[];
2206
2204
  }>;
2207
2205
  doStream(options: CompatibleV2CallOptions): Promise<{
2208
2206
  request?: {
@@ -2211,7 +2209,7 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2$1 {
2211
2209
  response?: {
2212
2210
  headers?: SharedV2Headers;
2213
2211
  };
2214
- stream: ReturnType<typeof createV2StreamFromInternal>;
2212
+ stream: ReadableStream<ConvertedV2StreamPart>;
2215
2213
  }>;
2216
2214
  }
2217
2215
 
@@ -2223,14 +2221,15 @@ type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
2223
2221
  */
2224
2222
  interface SAPAIProviderSettings {
2225
2223
  /**
2226
- * SAP AI Core API to use for all models created by this provider.
2227
- * Can be overridden at model creation time or per-call via providerOptions.
2224
+ * Default SAP AI Core API for models created by this provider.
2225
+ * `defaultSettings.api`, per-model `api`, and per-call `providerOptions` take precedence.
2226
+ * This option does not enable automatic failover between APIs.
2228
2227
  * - `'orchestration'` (default): SAP AI Core Orchestration API - supports filtering, grounding, masking, translation
2229
2228
  * - `'foundation-models'`: SAP AI Core Foundation Models API - supports dataSources, logprobs, seed, etc.
2230
2229
  * @default 'orchestration'
2231
2230
  */
2232
2231
  readonly api?: SAPAIApiType;
2233
- /** Default model settings applied to every model instance. Per-call settings override these. */
2232
+ /** Default model settings; settings supplied at model creation override these. */
2234
2233
  readonly defaultSettings?: SAPAISettings;
2235
2234
  /** SAP AI Core deployment ID. If not provided, the SDK resolves deployment automatically. */
2236
2235
  readonly deploymentId?: string;
@@ -2238,13 +2237,16 @@ interface SAPAIProviderSettings {
2238
2237
  readonly destination?: HttpDestinationOrFetchOptions;
2239
2238
  /**
2240
2239
  * Log level for SAP Cloud SDK loggers.
2241
- * Controls verbosity of internal SAP SDK logging (e.g., authentication, service binding).
2240
+ * Controls process-wide SAP SDK logging (e.g., authentication, service binding).
2241
+ * Creating another provider resets this level, using warn when logLevel is omitted.
2242
2242
  * Note: SAP_CLOUD_SDK_LOG_LEVEL environment variable takes precedence if set.
2243
2243
  * @default 'warn'
2244
2244
  */
2245
2245
  readonly logLevel?: "debug" | "error" | "info" | "warn";
2246
2246
  /**
2247
- * Provider name used as key for `providerOptions` and `providerMetadata`.
2247
+ * Name used in model provider identifiers. Call-level `providerOptions` and
2248
+ * `providerMetadata` keys use the prefix before the first dot; avoid dots in names.
2249
+ * Per-part prompt-cache directives always use the fixed `sap-ai` key.
2248
2250
  * @default 'sap-ai'
2249
2251
  */
2250
2252
  readonly name?: string;
@@ -2254,8 +2256,10 @@ interface SAPAIProviderSettings {
2254
2256
  *
2255
2257
  * Provider-level only (not overridable per-call via `providerOptions['sap-ai']`). The
2256
2258
  * AI SDK `abortSignal` option always wins over any `signal` on `requestConfig`; the
2257
- * latter is dropped before the request is forwarded. Node-only knobs (`httpAgent`,
2258
- * `httpsAgent`) are silently ignored on Edge / Cloudflare Workers runtimes.
2259
+ * latter is dropped before the request is forwarded. Standard AI SDK call-level
2260
+ * `headers` override matching `requestConfig.headers` case-insensitively. Other
2261
+ * options, including Node-only agents (`httpAgent`, `httpsAgent`), are forwarded
2262
+ * unchanged. The published package and SAP SDK transport require a Node-compatible runtime.
2259
2263
  *
2260
2264
  * See the "Note on `requestConfig`" section under `SAPAIProviderSettings` in
2261
2265
  * `API_REFERENCE.md` for the full SAP AI Core `AI-*` header guidance.
@@ -2271,6 +2275,7 @@ interface SAPAIProviderSettings {
2271
2275
  /** Whether to emit warnings for ambiguous configurations (e.g. both deploymentId and resourceGroup). */
2272
2276
  readonly warnOnAmbiguousConfig?: boolean;
2273
2277
  }
2278
+
2274
2279
  /** SAP AI Provider interface extending Vercel AI SDK ProviderV2. */
2275
2280
  interface SAPAIProviderV2 extends ProviderV2 {
2276
2281
  (modelId: SAPAIModelId, settings?: SAPAISettings): SAPAILanguageModelV2;
@@ -2290,12 +2295,12 @@ interface SAPAIProviderV2 extends ProviderV2 {
2290
2295
  * @param options - Provider configuration options.
2291
2296
  * @param options.api - Default API type: `'orchestration'` (default) or `'foundation-models'`.
2292
2297
  * @param options.defaultSettings - Default model settings applied to every model instance.
2293
- * @param options.deploymentId - SAP AI Core deployment ID for automatic deployment resolution.
2298
+ * @param options.deploymentId - Explicit SAP AI Core deployment ID; omit for automatic deployment resolution.
2294
2299
  * @param options.destination - Custom SAP Cloud SDK destination configuration.
2295
2300
  * @param options.logLevel - Log level for SAP Cloud SDK loggers (`'debug'`, `'info'`, `'warn'`, `'error'`).
2296
- * @param options.name - Provider name used as key in `providerOptions` (default: `'sap-ai'`).
2301
+ * @param options.name - Provider name (default: `'sap-ai'`); see {@link SAPAIProviderSettings.name} for namespace rules.
2297
2302
  * @param options.requestConfig - Provider-level custom request configuration. See {@link SAPAIProviderSettings.requestConfig} for scope, portability, and abort semantics.
2298
- * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`).
2303
+ * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`); ignored when deploymentId is set.
2299
2304
  * @param options.warnOnAmbiguousConfig - Whether to warn when both deploymentId and resourceGroup are set.
2300
2305
  * @returns A configured SAP AI provider instance that can be used as a callable or via methods.
2301
2306
  * @example
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
6
6
  import { AzureOpenAiChatCompletionParameters } from '@sap-ai-sdk/foundation-models';
7
7
  import { OrchestrationConfigRefOverride, OrchestrationModuleConfig, FilteringModule, GroundingModule, MaskingModule, OrchestrationConfigRefById, OrchestrationConfigRefByName, ChatCompletionTool, TranslationModule, ChatModel } from '@sap-ai-sdk/orchestration';
8
8
  export { AssistantChatMessage, ChatCompletionRequest, ChatCompletionTool, ChatMessage, ChatMessageContent, ChatMessages, Citation, DeveloperChatMessage, DocumentTranslationApplyToSelector, FileContent, FilteringModule, FunctionObject, GroundingModule, ImageContentUrl, LlmModelDetails, LlmModelParams, MaskingModule, OrchestrationClient, OrchestrationConfigRef, OrchestrationConfigRefById, OrchestrationConfigRefByName, OrchestrationConfigRefOverride, 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';
9
- import { SharedV3Warning, LanguageModelV3StreamPart, LanguageModelV2 as LanguageModelV2$1, LanguageModelV2CallOptions as LanguageModelV2CallOptions$1, LanguageModelV3CallOptions } from '@ai-sdk/provider';
9
+ import { LanguageModelV2 as LanguageModelV2$1, LanguageModelV2CallOptions as LanguageModelV2CallOptions$1, LanguageModelV3CallOptions } from '@ai-sdk/provider';
10
10
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
11
11
  import { InferSchema } from '@ai-sdk/provider-utils';
12
12
 
@@ -15,7 +15,7 @@ declare const SAP_AI_PROVIDER_NAME: "sap-ai";
15
15
  /**
16
16
  * Extracts the provider name from a provider identifier (e.g., "sap-ai.chat" → "sap-ai").
17
17
  * @param providerIdentifier - The full provider identifier string.
18
- * @returns The provider name without any suffix.
18
+ * @returns The prefix before the first dot, or the unchanged identifier when no dot exists.
19
19
  */
20
20
  declare function getProviderName(providerIdentifier: string): string;
21
21
  /** @internal */
@@ -1682,8 +1682,8 @@ type AzureOpenAiChatExtensionConfiguration = NonNullable<AzureOpenAiChatCompleti
1682
1682
  /**
1683
1683
  * Common model parameters shared between both APIs.
1684
1684
  *
1685
- * These parameters control text generation behavior and are validated by Zod schemas
1686
- * when passed via `providerOptions`.
1685
+ * Known parameters are validated by Zod in constructor settings and per-call
1686
+ * `modelParams` provider options; additional model-specific keys are passed through.
1687
1687
  */
1688
1688
  interface CommonModelParams {
1689
1689
  /**
@@ -1698,7 +1698,7 @@ interface CommonModelParams {
1698
1698
  readonly maxTokens?: number;
1699
1699
  /**
1700
1700
  * Number of completions to generate.
1701
- * Not supported by Amazon/Anthropic models.
1701
+ * Availability depends on the selected SAP API and model; no model-family filtering is applied.
1702
1702
  * Range: Positive integer
1703
1703
  */
1704
1704
  readonly n?: number;
@@ -1749,7 +1749,10 @@ interface FoundationModelsModelSettings {
1749
1749
  readonly api: "foundation-models";
1750
1750
  /** Azure OpenAI "On Your Data" configuration for RAG scenarios. */
1751
1751
  readonly dataSources?: AzureOpenAiChatExtensionConfiguration[];
1752
- /** @default false */
1752
+ /**
1753
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1754
+ * @default false
1755
+ */
1753
1756
  readonly includeReasoning?: boolean;
1754
1757
  readonly modelParams?: FoundationModelsModelParams;
1755
1758
  readonly modelVersion?: string;
@@ -1769,7 +1772,7 @@ interface OrchestrationModelSettings {
1769
1772
  readonly escapeTemplatePlaceholders?: boolean;
1770
1773
  /**
1771
1774
  * Additional module configurations for prompt module fallback.
1772
- * The SDK tries the primary configuration first, then each fallback in order until one succeeds.
1775
+ * These entries follow the primary configuration in the list passed to the SAP SDK.
1773
1776
  * Each entry is a full `OrchestrationModuleConfig` with its own model, prompt, and modules.
1774
1777
  * @example
1775
1778
  * ```ts
@@ -1786,7 +1789,10 @@ interface OrchestrationModelSettings {
1786
1789
  readonly fallbackModuleConfigs?: OrchestrationModuleConfig[];
1787
1790
  readonly filtering?: FilteringModule;
1788
1791
  readonly grounding?: GroundingModule;
1789
- /** @default false */
1792
+ /**
1793
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1794
+ * @default false
1795
+ */
1790
1796
  readonly includeReasoning?: boolean;
1791
1797
  readonly masking?: MaskingModule | {
1792
1798
  providers: MaskingModule["masking_providers"];
@@ -1797,7 +1803,8 @@ interface OrchestrationModelSettings {
1797
1803
  * Reference to a complete orchestration configuration stored in SAP AI Core Prompt Registry.
1798
1804
  * When provided, local module settings (filtering, masking, grounding, translation, tools,
1799
1805
  * promptTemplateRef, responseFormat) are ignored as the full configuration is managed
1800
- * by the referenced config. Only `placeholderValues` and messages are passed through.
1806
+ * by the referenced config. The reference, including its explicit `overrideConfig`,
1807
+ * is passed to the SAP SDK; messages and `placeholderValues` remain request inputs.
1801
1808
  * @example { id: "f47ac10b-58cc-4372-a567-0e02b2c3d479" }
1802
1809
  * @example { scenario: "customer-support", name: "prod-config", version: "1.0.0" }
1803
1810
  */
@@ -1806,8 +1813,8 @@ interface OrchestrationModelSettings {
1806
1813
  readonly promptTemplateRef?: PromptTemplateRef;
1807
1814
  readonly responseFormat?: ResponseFormat;
1808
1815
  /**
1809
- * Options for streaming behavior with post-LLM modules.
1810
- * Only applies when using `streamText()` with orchestration modules.
1816
+ * Options for streaming behavior with locally configured post-LLM modules.
1817
+ * Includes direct `doStream()` calls; ignored when `orchestrationConfigRef` is used.
1811
1818
  */
1812
1819
  readonly streamOptions?: OrchestrationStreamOptions;
1813
1820
  readonly tools?: ChatCompletionTool[];
@@ -1816,6 +1823,8 @@ interface OrchestrationModelSettings {
1816
1823
  /**
1817
1824
  * Stream options for orchestration post-LLM module processing.
1818
1825
  * Controls chunking behavior for translation, filtering, and other modules during streaming.
1826
+ * Ignored with `orchestrationConfigRef`; configure streaming in the stored
1827
+ * configuration or its `overrideConfig` instead.
1819
1828
  */
1820
1829
  interface OrchestrationStreamOptions {
1821
1830
  /**
@@ -1825,7 +1834,7 @@ interface OrchestrationStreamOptions {
1825
1834
  readonly chunkSize?: number;
1826
1835
  /**
1827
1836
  * Delimiters for splitting stream into chunks (e.g., sentence boundaries).
1828
- * Required when translation module is configured.
1837
+ * Recommended for translation; the provider warns when local translation settings lack them.
1829
1838
  * @example ["\n", ".", "?", "!"]
1830
1839
  */
1831
1840
  readonly delimiters?: readonly string[];
@@ -1869,12 +1878,18 @@ interface SAPAIEmbeddingSettings {
1869
1878
  readonly masking?: MaskingModule | {
1870
1879
  providers: MaskingModule["masking_providers"];
1871
1880
  };
1872
- /** @default 2048 */
1881
+ /**
1882
+ * Maximum batch size: a positive integer, or `Infinity` for no provider-side limit.
1883
+ * @default 2048
1884
+ */
1873
1885
  readonly maxEmbeddingsPerCall?: number;
1874
1886
  readonly modelParams?: FoundationModelsEmbeddingParams | Record<string, unknown>;
1875
1887
  readonly modelVersion?: string;
1876
1888
  readonly [key: string]: unknown;
1877
- /** @default 'text' */
1889
+ /**
1890
+ * Orchestration embedding input type; ignored by Foundation Models.
1891
+ * @default 'text'
1892
+ */
1878
1893
  readonly type?: "document" | "query" | "text";
1879
1894
  }
1880
1895
  /**
@@ -1908,7 +1923,10 @@ interface SAPAISettings {
1908
1923
  readonly filtering?: FilteringModule;
1909
1924
  /** Orchestration API only. */
1910
1925
  readonly grounding?: GroundingModule;
1911
- /** @default false */
1926
+ /**
1927
+ * Forward assistant reasoning from the input history as text; does not enable reasoning output.
1928
+ * @default false
1929
+ */
1912
1930
  readonly includeReasoning?: boolean;
1913
1931
  /** Orchestration API only. */
1914
1932
  readonly masking?: MaskingModule | {
@@ -1923,7 +1941,7 @@ interface SAPAISettings {
1923
1941
  /** Orchestration API only. */
1924
1942
  readonly promptTemplateRef?: PromptTemplateRef;
1925
1943
  readonly responseFormat?: ResponseFormat;
1926
- /** Orchestration API only. */
1944
+ /** Orchestration API only; ignored when `orchestrationConfigRef` is used. */
1927
1945
  readonly streamOptions?: OrchestrationStreamOptions;
1928
1946
  /** Orchestration API only. */
1929
1947
  readonly tools?: ChatCompletionTool[];
@@ -2068,7 +2086,7 @@ declare class ApiSwitchError extends Error {
2068
2086
  * @example
2069
2087
  * ```typescript
2070
2088
  * throw new UnsupportedFeatureError("Content filtering", "foundation-models", "orchestration");
2071
- * // "Content filtering is only available with Orchestration API and will be ignored by Foundation Models API."
2089
+ * // Rejects the request: content filtering requires the Orchestration API.
2072
2090
  * ```
2073
2091
  * @see {@link validateSettings} - Main validation function that throws this error
2074
2092
  * @see {@link ApiSwitchError} - Related error for API switching conflicts
@@ -2080,45 +2098,25 @@ declare class UnsupportedFeatureError extends Error {
2080
2098
  /**
2081
2099
  * Creates a new UnsupportedFeatureError.
2082
2100
  * @param feature - The name of the unsupported feature (e.g., "Content filtering").
2083
- * @param api - The API being used where the feature will be ignored.
2101
+ * @param api - The API being used that does not support the feature.
2084
2102
  * @param suggestedApi - The API that supports this feature.
2085
2103
  */
2086
2104
  constructor(feature: string, api: SAPAIApiType, suggestedApi: SAPAIApiType);
2087
2105
  }
2088
2106
 
2089
- /** Adapters to convert internal (V3) formats to LanguageModelV2 formats for the V2 facade. */
2107
+ /** Adapters for the semantic differences between the V3 core and V2 facade. */
2090
2108
 
2109
+ /** Stream events supported by the V2 facade. */
2091
2110
  type ConvertedV2StreamPart = Exclude<LanguageModelV2StreamPart, {
2092
2111
  type: "stream-start";
2093
2112
  }> | {
2094
2113
  type: "stream-start";
2095
- warnings: ReturnType<typeof convertWarningsToV2>;
2114
+ warnings: ConvertedV2Warning[];
2096
2115
  };
2097
- /**
2098
- * Converts internal warnings array to V2 warnings array.
2099
- * @param internalWarnings - Internal warning objects.
2100
- * @returns V2 warning objects.
2101
- * @internal
2102
- */
2103
- declare function convertWarningsToV2(internalWarnings: SharedV3Warning[]): ReturnType<typeof convertWarningToV2>[];
2104
- /**
2105
- * Converts internal warning to V2 warning format.
2106
- *
2107
- * Maps `unsupported`/`compatibility` warnings to V2 `other` type with descriptive message.
2108
- * @param internalWarning - Internal warning object.
2109
- * @returns V2 warning object.
2110
- * @internal
2111
- */
2112
- declare function convertWarningToV2(internalWarning: SharedV3Warning): Extract<LanguageModelV2CallWarning, {
2116
+ /** V2 warning representation used when adapting V3 feature diagnostics. */
2117
+ type ConvertedV2Warning = Extract<LanguageModelV2CallWarning, {
2113
2118
  type: "other";
2114
2119
  }>;
2115
- /**
2116
- * Transforms internal stream to V2 ReadableStream.
2117
- * @param internalStream - Internal ReadableStream to transform.
2118
- * @returns V2-formatted ReadableStream.
2119
- * @internal
2120
- */
2121
- declare function createV2StreamFromInternal(internalStream: ReadableStream<LanguageModelV3StreamPart>): ReadableStream<ConvertedV2StreamPart>;
2122
2120
 
2123
2121
  /**
2124
2122
  * SAP AI Language Model V2 - Vercel AI SDK LanguageModelV2 implementation for SAP AI Core.
@@ -2202,7 +2200,7 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2$1 {
2202
2200
  headers?: SharedV2Headers;
2203
2201
  };
2204
2202
  usage: LanguageModelV2Usage;
2205
- warnings: ReturnType<typeof convertWarningsToV2>;
2203
+ warnings: ConvertedV2Warning[];
2206
2204
  }>;
2207
2205
  doStream(options: CompatibleV2CallOptions): Promise<{
2208
2206
  request?: {
@@ -2211,7 +2209,7 @@ declare class SAPAILanguageModelV2 implements LanguageModelV2$1 {
2211
2209
  response?: {
2212
2210
  headers?: SharedV2Headers;
2213
2211
  };
2214
- stream: ReturnType<typeof createV2StreamFromInternal>;
2212
+ stream: ReadableStream<ConvertedV2StreamPart>;
2215
2213
  }>;
2216
2214
  }
2217
2215
 
@@ -2223,14 +2221,15 @@ type DeploymentConfig = DeploymentIdConfig | ResourceGroupConfig;
2223
2221
  */
2224
2222
  interface SAPAIProviderSettings {
2225
2223
  /**
2226
- * SAP AI Core API to use for all models created by this provider.
2227
- * Can be overridden at model creation time or per-call via providerOptions.
2224
+ * Default SAP AI Core API for models created by this provider.
2225
+ * `defaultSettings.api`, per-model `api`, and per-call `providerOptions` take precedence.
2226
+ * This option does not enable automatic failover between APIs.
2228
2227
  * - `'orchestration'` (default): SAP AI Core Orchestration API - supports filtering, grounding, masking, translation
2229
2228
  * - `'foundation-models'`: SAP AI Core Foundation Models API - supports dataSources, logprobs, seed, etc.
2230
2229
  * @default 'orchestration'
2231
2230
  */
2232
2231
  readonly api?: SAPAIApiType;
2233
- /** Default model settings applied to every model instance. Per-call settings override these. */
2232
+ /** Default model settings; settings supplied at model creation override these. */
2234
2233
  readonly defaultSettings?: SAPAISettings;
2235
2234
  /** SAP AI Core deployment ID. If not provided, the SDK resolves deployment automatically. */
2236
2235
  readonly deploymentId?: string;
@@ -2238,13 +2237,16 @@ interface SAPAIProviderSettings {
2238
2237
  readonly destination?: HttpDestinationOrFetchOptions;
2239
2238
  /**
2240
2239
  * Log level for SAP Cloud SDK loggers.
2241
- * Controls verbosity of internal SAP SDK logging (e.g., authentication, service binding).
2240
+ * Controls process-wide SAP SDK logging (e.g., authentication, service binding).
2241
+ * Creating another provider resets this level, using warn when logLevel is omitted.
2242
2242
  * Note: SAP_CLOUD_SDK_LOG_LEVEL environment variable takes precedence if set.
2243
2243
  * @default 'warn'
2244
2244
  */
2245
2245
  readonly logLevel?: "debug" | "error" | "info" | "warn";
2246
2246
  /**
2247
- * Provider name used as key for `providerOptions` and `providerMetadata`.
2247
+ * Name used in model provider identifiers. Call-level `providerOptions` and
2248
+ * `providerMetadata` keys use the prefix before the first dot; avoid dots in names.
2249
+ * Per-part prompt-cache directives always use the fixed `sap-ai` key.
2248
2250
  * @default 'sap-ai'
2249
2251
  */
2250
2252
  readonly name?: string;
@@ -2254,8 +2256,10 @@ interface SAPAIProviderSettings {
2254
2256
  *
2255
2257
  * Provider-level only (not overridable per-call via `providerOptions['sap-ai']`). The
2256
2258
  * AI SDK `abortSignal` option always wins over any `signal` on `requestConfig`; the
2257
- * latter is dropped before the request is forwarded. Node-only knobs (`httpAgent`,
2258
- * `httpsAgent`) are silently ignored on Edge / Cloudflare Workers runtimes.
2259
+ * latter is dropped before the request is forwarded. Standard AI SDK call-level
2260
+ * `headers` override matching `requestConfig.headers` case-insensitively. Other
2261
+ * options, including Node-only agents (`httpAgent`, `httpsAgent`), are forwarded
2262
+ * unchanged. The published package and SAP SDK transport require a Node-compatible runtime.
2259
2263
  *
2260
2264
  * See the "Note on `requestConfig`" section under `SAPAIProviderSettings` in
2261
2265
  * `API_REFERENCE.md` for the full SAP AI Core `AI-*` header guidance.
@@ -2271,6 +2275,7 @@ interface SAPAIProviderSettings {
2271
2275
  /** Whether to emit warnings for ambiguous configurations (e.g. both deploymentId and resourceGroup). */
2272
2276
  readonly warnOnAmbiguousConfig?: boolean;
2273
2277
  }
2278
+
2274
2279
  /** SAP AI Provider interface extending Vercel AI SDK ProviderV2. */
2275
2280
  interface SAPAIProviderV2 extends ProviderV2 {
2276
2281
  (modelId: SAPAIModelId, settings?: SAPAISettings): SAPAILanguageModelV2;
@@ -2290,12 +2295,12 @@ interface SAPAIProviderV2 extends ProviderV2 {
2290
2295
  * @param options - Provider configuration options.
2291
2296
  * @param options.api - Default API type: `'orchestration'` (default) or `'foundation-models'`.
2292
2297
  * @param options.defaultSettings - Default model settings applied to every model instance.
2293
- * @param options.deploymentId - SAP AI Core deployment ID for automatic deployment resolution.
2298
+ * @param options.deploymentId - Explicit SAP AI Core deployment ID; omit for automatic deployment resolution.
2294
2299
  * @param options.destination - Custom SAP Cloud SDK destination configuration.
2295
2300
  * @param options.logLevel - Log level for SAP Cloud SDK loggers (`'debug'`, `'info'`, `'warn'`, `'error'`).
2296
- * @param options.name - Provider name used as key in `providerOptions` (default: `'sap-ai'`).
2301
+ * @param options.name - Provider name (default: `'sap-ai'`); see {@link SAPAIProviderSettings.name} for namespace rules.
2297
2302
  * @param options.requestConfig - Provider-level custom request configuration. See {@link SAPAIProviderSettings.requestConfig} for scope, portability, and abort semantics.
2298
- * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`).
2303
+ * @param options.resourceGroup - SAP AI Core resource group (default: `'default'`); ignored when deploymentId is set.
2299
2304
  * @param options.warnOnAmbiguousConfig - Whether to warn when both deploymentId and resourceGroup are set.
2300
2305
  * @returns A configured SAP AI provider instance that can be used as a callable or via methods.
2301
2306
  * @example