@jerome-benoit/sap-ai-provider-v2 5.0.0 → 5.0.1
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/README.md +51 -16
- package/dist/{chunk-BIBSYTMU.js → chunk-2KOXKYVT.js} +5 -7
- package/dist/{chunk-BIBSYTMU.js.map → chunk-2KOXKYVT.js.map} +1 -1
- package/dist/{chunk-WNR7DC4V.js → chunk-643USI3B.js} +7 -7
- package/dist/{chunk-WNR7DC4V.js.map → chunk-643USI3B.js.map} +1 -1
- package/dist/{chunk-Q5JV4I6D.js → chunk-AFZC2DH2.js} +2 -2
- package/dist/chunk-AFZC2DH2.js.map +1 -0
- package/dist/{chunk-FY2HO62O.js → chunk-JRUSQTKB.js} +3 -3
- package/dist/{chunk-QDUZRLMI.js → chunk-MF3VO3ER.js} +1 -1
- package/dist/chunk-MF3VO3ER.js.map +1 -0
- package/dist/{chunk-TXZZURBA.js → chunk-U23M3VYO.js} +2 -2
- package/dist/{foundation-models-embedding-model-strategy-JJBN3TQI.js → foundation-models-embedding-model-strategy-2GUADNXT.js} +4 -4
- package/dist/{foundation-models-language-model-strategy-6ELKE34K.js → foundation-models-language-model-strategy-5AYZ5KHA.js} +5 -5
- package/dist/index.cjs +11 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -26
- package/dist/index.d.ts +46 -26
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/{orchestration-embedding-model-strategy-QI72OB3E.js → orchestration-embedding-model-strategy-F7WHDLX7.js} +5 -5
- package/dist/{orchestration-language-model-strategy-X4FZNLSA.js → orchestration-language-model-strategy-Z72AFW62.js} +10 -9
- package/dist/orchestration-language-model-strategy-Z72AFW62.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-Q5JV4I6D.js.map +0 -1
- package/dist/chunk-QDUZRLMI.js.map +0 -1
- package/dist/orchestration-language-model-strategy-X4FZNLSA.js.map +0 -1
- /package/dist/{chunk-FY2HO62O.js.map → chunk-JRUSQTKB.js.map} +0 -0
- /package/dist/{chunk-TXZZURBA.js.map → chunk-U23M3VYO.js.map} +0 -0
- /package/dist/{foundation-models-embedding-model-strategy-JJBN3TQI.js.map → foundation-models-embedding-model-strategy-2GUADNXT.js.map} +0 -0
- /package/dist/{foundation-models-language-model-strategy-6ELKE34K.js.map → foundation-models-language-model-strategy-5AYZ5KHA.js.map} +0 -0
- /package/dist/{orchestration-embedding-model-strategy-QI72OB3E.js.map → orchestration-embedding-model-strategy-F7WHDLX7.js.map} +0 -0
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ SAP's enterprise-grade AI models through the familiar Vercel AI SDK interface.
|
|
|
46
46
|
- [Debug Mode](#debug-mode)
|
|
47
47
|
- [Examples](#examples)
|
|
48
48
|
- [Migration Guides](#migration-guides)
|
|
49
|
+
- [Upgrading from v4.x to v5.x](#upgrading-from-v4x-to-v5x)
|
|
49
50
|
- [Upgrading from v3.x to v4.x](#upgrading-from-v3x-to-v4x)
|
|
50
51
|
- [Upgrading from v2.x to v3.x](#upgrading-from-v2x-to-v3x)
|
|
51
52
|
- [Upgrading from v1.x to v2.x](#upgrading-from-v1x-to-v2x)
|
|
@@ -82,7 +83,7 @@ SAP's enterprise-grade AI models through the familiar Vercel AI SDK interface.
|
|
|
82
83
|
## Quick Start
|
|
83
84
|
|
|
84
85
|
```bash
|
|
85
|
-
npm install @jerome-benoit/sap-ai-provider ai@^6
|
|
86
|
+
npm install @jerome-benoit/sap-ai-provider ai@^6 dotenv
|
|
86
87
|
```
|
|
87
88
|
|
|
88
89
|
```typescript
|
|
@@ -125,7 +126,7 @@ try {
|
|
|
125
126
|
| **Text Generation** | `generateText({ model: provider("gpt-4.1"), prompt })` | [Basic Usage](#text-generation) |
|
|
126
127
|
| **Streaming** | `streamText({ model: provider("gpt-4.1"), prompt })` | [Streaming](#streaming-responses) |
|
|
127
128
|
| **Tool Calling** | `generateText({ tools: { myTool: tool({...}) } })` | [Tool Calling](#tool-calling) |
|
|
128
|
-
| **Error Handling** | `
|
|
129
|
+
| **Error Handling** | `if (APICallError.isInstance(error)) { /* handle error */ }` | [API Reference](./API_REFERENCE.md#error-handling--reference) |
|
|
129
130
|
| **Choose Model** | See 80+ models (GPT, Claude, Gemini, Llama) | [Models](./API_REFERENCE.md#models) |
|
|
130
131
|
| **Embeddings** | `embed({ model: provider.embedding("text-embedding-3-small") })` | [Embeddings](#embeddings) |
|
|
131
132
|
|
|
@@ -134,6 +135,11 @@ try {
|
|
|
134
135
|
**Requirements:** Node.js 22.12+. The provider entrypoint must match the installed
|
|
135
136
|
AI SDK major.
|
|
136
137
|
|
|
138
|
+
The published package targets Node.js. Its ESM output uses Node
|
|
139
|
+
`module.createRequire`, and the SAP SDK dependency chain relies on Node APIs.
|
|
140
|
+
The source-level Edge test suite does not establish deployability to pure Edge
|
|
141
|
+
runtimes such as Cloudflare Workers; use a Node.js server runtime for deployment.
|
|
142
|
+
|
|
137
143
|
| AI SDK | Install | Provider import |
|
|
138
144
|
| ------ | -------------------------------------------------- | ----------------------------------- |
|
|
139
145
|
| 7 | `npm install @jerome-benoit/sap-ai-provider ai@^7` | `@jerome-benoit/sap-ai-provider/v4` |
|
|
@@ -269,7 +275,7 @@ The provider is callable and also exposes explicit methods:
|
|
|
269
275
|
const chatModel = provider("gpt-4.1");
|
|
270
276
|
|
|
271
277
|
// Explicit method syntax
|
|
272
|
-
const
|
|
278
|
+
const explicitChatModel = provider.chat("gpt-4.1");
|
|
273
279
|
const embeddingModel = provider.embedding("text-embedding-3-small");
|
|
274
280
|
```
|
|
275
281
|
|
|
@@ -350,20 +356,26 @@ import { streamText } from "ai";
|
|
|
350
356
|
import { APICallError } from "@ai-sdk/provider";
|
|
351
357
|
|
|
352
358
|
try {
|
|
359
|
+
let streamError: unknown;
|
|
353
360
|
const result = streamText({
|
|
354
361
|
model: provider("gpt-4.1"),
|
|
355
362
|
prompt: "Explain machine learning concepts.",
|
|
363
|
+
onError({ error }) {
|
|
364
|
+
streamError = error;
|
|
365
|
+
},
|
|
356
366
|
});
|
|
357
367
|
|
|
358
368
|
for await (const delta of result.textStream) {
|
|
359
369
|
process.stdout.write(delta);
|
|
360
370
|
}
|
|
361
371
|
|
|
362
|
-
//
|
|
363
|
-
|
|
364
|
-
|
|
372
|
+
// textStream does not throw stream errors; preserve the original API error.
|
|
373
|
+
if (streamError !== undefined) throw streamError;
|
|
374
|
+
|
|
375
|
+
// streamText returns a result object; its usage property is a promise.
|
|
376
|
+
console.log("\n\nUsage:", await result.usage);
|
|
365
377
|
} catch (error) {
|
|
366
|
-
if (error
|
|
378
|
+
if (APICallError.isInstance(error)) {
|
|
367
379
|
console.error("API Error:", error.message);
|
|
368
380
|
// See Error Handling section for complete error type reference
|
|
369
381
|
}
|
|
@@ -621,7 +633,10 @@ const model = provider("gpt-4.1");
|
|
|
621
633
|
### Provider Options (Per-Call Overrides)
|
|
622
634
|
|
|
623
635
|
Override constructor settings on a per-call basis using `providerOptions`.
|
|
624
|
-
|
|
636
|
+
Only the documented per-call fields are supported: unknown top-level fields
|
|
637
|
+
are stripped by the Zod schemas, while additional `modelParams` keys pass
|
|
638
|
+
through. Standard AI SDK generation options (for example, `temperature`) take
|
|
639
|
+
precedence over the corresponding `providerOptions` model parameters.
|
|
625
640
|
|
|
626
641
|
```typescript
|
|
627
642
|
import { generateText } from "ai";
|
|
@@ -654,8 +669,8 @@ authentication, model parameters, data masking, content filtering, and more.
|
|
|
654
669
|
|
|
655
670
|
**Common Configuration:**
|
|
656
671
|
|
|
657
|
-
- `name`: Provider
|
|
658
|
-
`providerOptions`/`providerMetadata`.
|
|
672
|
+
- `name`: Provider identifier prefix (default: `'sap-ai'`). The segment before
|
|
673
|
+
the first dot is used as the key in `providerOptions`/`providerMetadata`.
|
|
659
674
|
- `resourceGroup`: SAP AI Core resource group (default: 'default')
|
|
660
675
|
- `deploymentId`: Specific deployment ID (auto-resolved if not set)
|
|
661
676
|
- `requestConfig`: Custom HTTP request configuration (headers, params, timeout, etc.)
|
|
@@ -690,7 +705,9 @@ error handling across providers.
|
|
|
690
705
|
|
|
691
706
|
- **Authentication (401)**: Check `AICORE_SERVICE_KEY` or `VCAP_SERVICES`
|
|
692
707
|
- **Model not found (404)**: Confirm tenant/region supports the model ID
|
|
693
|
-
- **Rate limit (429)**:
|
|
708
|
+
- **Rate limit (429)**: High-level AI SDK calls retry eligible errors with
|
|
709
|
+
exponential backoff, bounded by `maxRetries`; direct provider calls do not
|
|
710
|
+
implement retries
|
|
694
711
|
- **Streaming**: Iterate `textStream` correctly; don't mix `generateText` and
|
|
695
712
|
`streamText`
|
|
696
713
|
|
|
@@ -704,10 +721,10 @@ streaming, and tool calling.
|
|
|
704
721
|
## Performance
|
|
705
722
|
|
|
706
723
|
- Prefer streaming (`streamText`) for long outputs to reduce latency and memory.
|
|
707
|
-
- Tune `modelParams` carefully: lower `temperature` for
|
|
724
|
+
- Tune `modelParams` carefully: lower `temperature` for less variable results;
|
|
708
725
|
set `maxTokens` to expected response size.
|
|
709
|
-
- Use `defaultSettings` at provider creation
|
|
710
|
-
|
|
726
|
+
- Use `defaultSettings` at provider creation to share configuration across models;
|
|
727
|
+
settings are still merged and validated when models and calls are prepared.
|
|
711
728
|
- Avoid unnecessary history: keep `messages` concise to reduce prompt size and
|
|
712
729
|
cost.
|
|
713
730
|
|
|
@@ -759,6 +776,24 @@ npx tsx examples/example-generate-text.ts
|
|
|
759
776
|
|
|
760
777
|
## Migration Guides
|
|
761
778
|
|
|
779
|
+
### Upgrading from v4.x to v5.x
|
|
780
|
+
|
|
781
|
+
Version 5.0 adds **AI SDK 7** support through the **V4** facade and requires
|
|
782
|
+
**Node.js 22.12 or newer** for both packages. The root entrypoint remains
|
|
783
|
+
**V3 for AI SDK 6**; upgrading the provider does not require switching SDKs.
|
|
784
|
+
|
|
785
|
+
**Key changes:**
|
|
786
|
+
|
|
787
|
+
- **Runtime**: Upgrade local, CI and deployment environments from Node.js 20
|
|
788
|
+
to Node.js 22.12 or newer.
|
|
789
|
+
- **Entrypoints**: Use `/v4` with SDK 7, the root with SDK 6, or `/v2` with
|
|
790
|
+
SDK 5. The standalone V2 package remains available for SDK 5/6.
|
|
791
|
+
- **Multimodal inputs**: V4 tagged JPEG/PDF inputs are normalized correctly;
|
|
792
|
+
unsupported binary objects are rejected instead of silently stringified.
|
|
793
|
+
|
|
794
|
+
See the [4.x to 5.x migration guide](./MIGRATION_GUIDE.md#version-4x-to-5x-breaking-changes)
|
|
795
|
+
for installation commands, compatibility details and the migration checklist.
|
|
796
|
+
|
|
762
797
|
### Upgrading from v3.x to v4.x
|
|
763
798
|
|
|
764
799
|
Version 4.0 migrates from **LanguageModelV2** to **LanguageModelV3**
|
|
@@ -796,7 +831,7 @@ complete upgrade instructions.**
|
|
|
796
831
|
|
|
797
832
|
- `SAPAIError` removed → Use `APICallError` from `@ai-sdk/provider`
|
|
798
833
|
- Error properties: `error.code` → `error.statusCode`
|
|
799
|
-
-
|
|
834
|
+
- Retryable error classification for the AI SDK's rate-limit/server-error retries
|
|
800
835
|
|
|
801
836
|
### Upgrading from v1.x to v2.x
|
|
802
837
|
|
|
@@ -830,7 +865,7 @@ for details.
|
|
|
830
865
|
### Documentation
|
|
831
866
|
|
|
832
867
|
- [Migration Guide](./MIGRATION_GUIDE.md) - Version upgrade instructions (v1.x →
|
|
833
|
-
v2.x → v3.x → v4.x)
|
|
868
|
+
v2.x → v3.x → v4.x → v5.x)
|
|
834
869
|
- [API Reference](./API_REFERENCE.md) - Complete API documentation with all
|
|
835
870
|
types and functions
|
|
836
871
|
- [Environment Setup](./ENVIRONMENT_SETUP.md) - Authentication and configuration
|
|
@@ -30642,15 +30642,13 @@ var UnsupportedFeatureError = class extends Error {
|
|
|
30642
30642
|
/**
|
|
30643
30643
|
* Creates a new UnsupportedFeatureError.
|
|
30644
30644
|
* @param feature - The name of the unsupported feature (e.g., "Content filtering").
|
|
30645
|
-
* @param api - The API being used
|
|
30645
|
+
* @param api - The API being used that does not support the feature.
|
|
30646
30646
|
* @param suggestedApi - The API that supports this feature.
|
|
30647
30647
|
*/
|
|
30648
30648
|
constructor(feature, api, suggestedApi) {
|
|
30649
30649
|
const apiName = api === "foundation-models" ? "Foundation Models" : "Orchestration";
|
|
30650
30650
|
const suggestedApiName = suggestedApi === "foundation-models" ? "Foundation Models" : "Orchestration";
|
|
30651
|
-
super(
|
|
30652
|
-
`${feature} is only available with ${suggestedApiName} API and will be ignored by ${apiName} API.`
|
|
30653
|
-
);
|
|
30651
|
+
super(`${feature} is not supported by ${apiName} API. Use ${suggestedApiName} API instead.`);
|
|
30654
30652
|
this.feature = feature;
|
|
30655
30653
|
this.api = api;
|
|
30656
30654
|
this.suggestedApi = suggestedApi;
|
|
@@ -30698,7 +30696,7 @@ Request ID: ${requestId}`;
|
|
|
30698
30696
|
if (statusCode === HTTP_STATUS.RATE_LIMIT) {
|
|
30699
30697
|
enhancedMessage += "\n\nRate limit exceeded. Please try again later or contact your SAP administrator.\nSee: https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/rate-limits";
|
|
30700
30698
|
} else if (statusCode >= HTTP_STATUS.INTERNAL_ERROR) {
|
|
30701
|
-
enhancedMessage += "\n\nSAP AI Core service error. This is typically a temporary issue.
|
|
30699
|
+
enhancedMessage += "\n\nSAP AI Core service error. This is typically a temporary issue. Retries depend on the caller's retry configuration.\nSee: https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/troubleshooting";
|
|
30702
30700
|
} else if (location) {
|
|
30703
30701
|
enhancedMessage += `
|
|
30704
30702
|
|
|
@@ -31028,7 +31026,7 @@ function tryExtractSAPErrorFromMessage(message) {
|
|
|
31028
31026
|
}
|
|
31029
31027
|
|
|
31030
31028
|
// src/version.ts
|
|
31031
|
-
var VERSION = true ? "5.0.
|
|
31029
|
+
var VERSION = true ? "5.0.1" : "0.0.0-test";
|
|
31032
31030
|
|
|
31033
31031
|
export {
|
|
31034
31032
|
__toESM,
|
|
@@ -31082,4 +31080,4 @@ mime-types/index.js:
|
|
|
31082
31080
|
axios/dist/node/axios.cjs:
|
|
31083
31081
|
(*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
|
|
31084
31082
|
*/
|
|
31085
|
-
//# sourceMappingURL=chunk-
|
|
31083
|
+
//# sourceMappingURL=chunk-2KOXKYVT.js.map
|