@jerome-benoit/sap-ai-provider-v2 4.9.0 → 5.0.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 (32) hide show
  1. package/README.md +64 -51
  2. package/dist/{chunk-4PLJVJX4.js → chunk-BIBSYTMU.js} +517 -216
  3. package/dist/chunk-BIBSYTMU.js.map +1 -0
  4. package/dist/{chunk-RW6WSPU2.js → chunk-FY2HO62O.js} +3 -3
  5. package/dist/{chunk-33WLQYKB.js → chunk-Q5JV4I6D.js} +2 -2
  6. package/dist/{chunk-4JIMBRMV.js → chunk-QDUZRLMI.js} +154 -20
  7. package/dist/chunk-QDUZRLMI.js.map +1 -0
  8. package/dist/{chunk-4SQ5HC6Y.js → chunk-TXZZURBA.js} +2 -2
  9. package/dist/{chunk-3KCERYUB.js → chunk-WNR7DC4V.js} +5 -4
  10. package/dist/chunk-WNR7DC4V.js.map +1 -0
  11. package/dist/{foundation-models-embedding-model-strategy-RVJQSJPU.js → foundation-models-embedding-model-strategy-JJBN3TQI.js} +4 -4
  12. package/dist/{foundation-models-language-model-strategy-UWJ6FHBI.js → foundation-models-language-model-strategy-6ELKE34K.js} +5 -5
  13. package/dist/index.cjs +754 -347
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +1638 -10
  16. package/dist/index.d.ts +1638 -10
  17. package/dist/index.js +13 -14
  18. package/dist/index.js.map +1 -1
  19. package/dist/{orchestration-embedding-model-strategy-OMIXGLHJ.js → orchestration-embedding-model-strategy-QI72OB3E.js} +5 -5
  20. package/dist/{orchestration-language-model-strategy-UE7OQO5K.js → orchestration-language-model-strategy-X4FZNLSA.js} +51 -79
  21. package/dist/orchestration-language-model-strategy-X4FZNLSA.js.map +1 -0
  22. package/package.json +30 -24
  23. package/dist/chunk-3KCERYUB.js.map +0 -1
  24. package/dist/chunk-4JIMBRMV.js.map +0 -1
  25. package/dist/chunk-4PLJVJX4.js.map +0 -1
  26. package/dist/orchestration-language-model-strategy-UE7OQO5K.js.map +0 -1
  27. /package/dist/{chunk-RW6WSPU2.js.map → chunk-FY2HO62O.js.map} +0 -0
  28. /package/dist/{chunk-33WLQYKB.js.map → chunk-Q5JV4I6D.js.map} +0 -0
  29. /package/dist/{chunk-4SQ5HC6Y.js.map → chunk-TXZZURBA.js.map} +0 -0
  30. /package/dist/{foundation-models-embedding-model-strategy-RVJQSJPU.js.map → foundation-models-embedding-model-strategy-JJBN3TQI.js.map} +0 -0
  31. /package/dist/{foundation-models-language-model-strategy-UWJ6FHBI.js.map → foundation-models-language-model-strategy-6ELKE34K.js.map} +0 -0
  32. /package/dist/{orchestration-embedding-model-strategy-OMIXGLHJ.js.map → orchestration-embedding-model-strategy-QI72OB3E.js.map} +0 -0
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@jerome-benoit/sap-ai-provider/latest?label=npm&color=blue)](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider)
4
4
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
- [![Vercel AI SDK](https://img.shields.io/badge/Vercel%20AI%20SDK-5.0+-black.svg)](https://sdk.vercel.ai/docs)
6
- [![Language Model](https://img.shields.io/badge/Language%20Model-V3-green.svg)](https://sdk.vercel.ai/docs/ai-sdk-core/provider-management)
7
- [![Embedding Model](https://img.shields.io/badge/Embedding%20Model-V3-green.svg)](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings)
5
+ [![Vercel AI SDK](https://img.shields.io/badge/Vercel%20AI%20SDK-5%20%7C%206%20%7C%207-black.svg)](https://sdk.vercel.ai/docs)
6
+ [![Language Model](https://img.shields.io/badge/Language%20Model-V2%20%7C%20V3%20%7C%20V4-green.svg)](https://sdk.vercel.ai/docs/ai-sdk-core/provider-management)
7
+ [![Embedding Model](https://img.shields.io/badge/Embedding%20Model-V2%20%7C%20V3%20%7C%20V4-green.svg)](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings)
8
8
 
9
9
  A community provider for SAP AI Core that integrates seamlessly with the Vercel
10
10
  AI SDK. Built on top of the official **@sap-ai-sdk/orchestration** and
@@ -70,8 +70,8 @@ SAP's enterprise-grade AI models through the familiar Vercel AI SDK interface.
70
70
  - 🛡️ **Content Filtering** - Azure Content Safety and Llama Guard support
71
71
  - 🔧 **TypeScript Support** - Full type safety and IntelliSense
72
72
  - 🎨 **Multiple Models** - Support for OpenAI, Claude, Gemini, Nova, and more
73
- - ⚡ **Language Model V3** - Latest Vercel AI SDK specification with enhanced
74
- streaming
73
+ - 🔄 **AI SDK 5–7 Compatibility** - Versioned V2, V3, and V4 entrypoints
74
+ preserve the matching Vercel AI SDK provider specification
75
75
  - 📊 **Text Embeddings** - Generate vector embeddings for RAG and semantic
76
76
  search
77
77
  - 🔀 **Dual API Support** - Choose between Orchestration or Foundation Models
@@ -82,7 +82,7 @@ SAP's enterprise-grade AI models through the familiar Vercel AI SDK interface.
82
82
  ## Quick Start
83
83
 
84
84
  ```bash
85
- npm install @jerome-benoit/sap-ai-provider ai
85
+ npm install @jerome-benoit/sap-ai-provider ai@^6
86
86
  ```
87
87
 
88
88
  ```typescript
@@ -119,7 +119,7 @@ try {
119
119
 
120
120
  | Task | Code Pattern | Documentation |
121
121
  | ------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------- |
122
- | **Install** | `npm install @jerome-benoit/sap-ai-provider ai` | [Installation](#installation) |
122
+ | **Install** | `npm install @jerome-benoit/sap-ai-provider ai@^6` | [Installation](#installation) |
123
123
  | **Auth Setup** | Add `AICORE_SERVICE_KEY` to `.env` | [Environment Setup](./ENVIRONMENT_SETUP.md) |
124
124
  | **Create Provider** | `createSAPAIProvider()` or use `sapai` | [Provider Creation](#provider-creation) |
125
125
  | **Text Generation** | `generateText({ model: provider("gpt-4.1"), prompt })` | [Basic Usage](#text-generation) |
@@ -131,46 +131,56 @@ try {
131
131
 
132
132
  ## Installation
133
133
 
134
- **Requirements:** Node.js 20+ and Vercel AI SDK 5.0+ (6.0+ recommended)
134
+ **Requirements:** Node.js 22.12+. The provider entrypoint must match the installed
135
+ AI SDK major.
136
+
137
+ | AI SDK | Install | Provider import |
138
+ | ------ | -------------------------------------------------- | ----------------------------------- |
139
+ | 7 | `npm install @jerome-benoit/sap-ai-provider ai@^7` | `@jerome-benoit/sap-ai-provider/v4` |
140
+ | 6 | `npm install @jerome-benoit/sap-ai-provider ai@^6` | `@jerome-benoit/sap-ai-provider` |
141
+ | 5 | `npm install @jerome-benoit/sap-ai-provider ai@^5` | `@jerome-benoit/sap-ai-provider/v2` |
142
+
143
+ The Quick Start and inline snippets on this page use AI SDK 6 with the root V3
144
+ entrypoint. The runnable files in `examples/` use the repository's installed
145
+ AI SDK 7 with the V4 entrypoint.
146
+ For AI SDK 7, install `ai@^7` and import `createSAPAIProvider` or `sapai`
147
+ from `@jerome-benoit/sap-ai-provider/v4`:
135
148
 
136
149
  ```bash
137
- npm install @jerome-benoit/sap-ai-provider ai
150
+ npm install @jerome-benoit/sap-ai-provider ai@^7
138
151
  ```
139
152
 
140
- Or with other package managers:
153
+ The V4 entrypoint exposes the same provider aliases and version-independent
154
+ helpers as the root V3 entrypoint. Its standardized `reasoning` option maps to
155
+ SAP's `reasoning_effort` model parameter. `provider-default` preserves an
156
+ explicit `modelParams.reasoning_effort`; a stored `orchestrationConfigRef` owns
157
+ the model configuration and ignores local reasoning options with a warning.
158
+ See the [V4 API reference](./API_REFERENCE.md#v4-facade-api-ai-sdk-7) for the
159
+ full normalization and precedence contract.
160
+
161
+ **V2 facade:** AI SDK 5, AI SDK 6 through its V2 compatibility layer, and other `LanguageModelV2`/`EmbeddingModelV2`
162
+ consumers can use the main package's `v2` subpath or the dedicated V2 package:
141
163
 
142
164
  ```bash
143
- # Yarn
144
- yarn add @jerome-benoit/sap-ai-provider ai
165
+ npm install @jerome-benoit/sap-ai-provider ai@^5
166
+ # Alternatively: npm install @jerome-benoit/sap-ai-provider-v2 ai@^5
167
+ ```
145
168
 
146
- # pnpm
147
- pnpm add @jerome-benoit/sap-ai-provider ai
169
+ Both entrypoints expose the same V2 facade:
170
+
171
+ ```typescript
172
+ import { createSAPAIProvider } from "@jerome-benoit/sap-ai-provider/v2";
173
+ // Dedicated-package alternative:
174
+ // import { createSAPAIProvider } from "@jerome-benoit/sap-ai-provider-v2";
148
175
  ```
149
176
 
150
- > **V2 Facade Package Available:** For users requiring `LanguageModelV2`/`EmbeddingModelV2` interfaces, install the dedicated V2 facade package:
151
- >
152
- > ```bash
153
- > npm install @jerome-benoit/sap-ai-provider-v2 ai
154
- > ```
155
- >
156
- > This package provides a V2-compatible facade over the internal V3 implementation.
157
- >
158
- > Basic Usage Example:
159
- >
160
- > ```typescript
161
- > import { createSAPAIProvider } from "@jerome-benoit/sap-ai-provider-v2";
162
- > import { generateText } from "ai";
163
- >
164
- > const provider = createSAPAIProvider();
165
- > const result = await generateText({
166
- > model: provider("gpt-4.1"),
167
- > prompt: "Hello V2!",
168
- > });
169
- > console.log(result.text);
170
- > ```
171
- >
172
- > For a detailed understanding of the dual-package architecture, refer to
173
- > [Architecture - Dual-Package](./ARCHITECTURE.md#dual-package-architecture-v3--v2).
177
+ The V2 type contracts are bundled at build time; neither package installs a second
178
+ provider package through the `@ai-sdk/provider-v2` alias. When using V2 with AI SDK 6,
179
+ use the latest 6.x patch: the initial 6.0.0 embedding compatibility adapter has an
180
+ upstream warning-handling failure that is absent in 6.0.280.
181
+
182
+ See [Architecture - Versioned Packages](./ARCHITECTURE.md#versioned-package-architecture-v4--v3--v2)
183
+ for the V4/V3/V2 packaging model.
174
184
 
175
185
  ## Provider Creation
176
186
 
@@ -275,11 +285,11 @@ const embeddingModel = provider.embedding("text-embedding-3-small");
275
285
  | `provider.textEmbeddingModel(modelId)` | Creates embedding model (alias) |
276
286
 
277
287
  > `embedding()` and `embeddingModel()` are identical. `textEmbeddingModel()` is
278
- > deprecated in the V3 package — use `embeddingModel()` instead.
288
+ > deprecated in the V3 and V4 entrypoints — use `embeddingModel()` instead.
279
289
  >
280
290
  > **Note:** The V2 facade package (`@jerome-benoit/sap-ai-provider-v2`) only exposes
281
291
  > `textEmbeddingModel()` for embeddings per the `ProviderV2` specification. Use the
282
- > V3 package if you need `embedding()` or `embeddingModel()` aliases.
292
+ > V3 root with AI SDK 6 or V4 subpath with AI SDK 7 if you need these aliases.
283
293
 
284
294
  ## Authentication
285
295
 
@@ -461,7 +471,7 @@ modules.
461
471
  [examples/example-chat-completion-tool.ts](./examples/example-chat-completion-tool.ts)
462
472
 
463
473
  ```typescript
464
- import { generateText, tool } from "ai";
474
+ import { generateText, stepCountIs, tool } from "ai";
465
475
  import { z } from "zod";
466
476
  import { createSAPAIProvider } from "@jerome-benoit/sap-ai-provider";
467
477
 
@@ -469,7 +479,7 @@ const provider = createSAPAIProvider();
469
479
 
470
480
  const weatherTool = tool({
471
481
  description: "Get weather for a location",
472
- parameters: z.object({ location: z.string() }),
482
+ inputSchema: z.object({ location: z.string() }),
473
483
  execute: async (args) => `Weather in ${args.location}: sunny, 72°F`,
474
484
  });
475
485
 
@@ -477,7 +487,7 @@ const result = await generateText({
477
487
  model: provider("gpt-4.1"),
478
488
  prompt: "What's the weather in Tokyo?",
479
489
  tools: { getWeather: weatherTool },
480
- maxSteps: 3,
490
+ stopWhen: stepCountIs(3),
481
491
  });
482
492
  ```
483
493
 
@@ -719,8 +729,10 @@ deployment.
719
729
 
720
730
  ## Examples
721
731
 
722
- The `examples/` directory contains complete, runnable examples demonstrating key
723
- features:
732
+ The `examples/` directory contains complete, runnable examples using the
733
+ repository's AI SDK 7 dependency and the local `../src/index-v4` entrypoint.
734
+ In an AI SDK 7 application, import from `@jerome-benoit/sap-ai-provider/v4`.
735
+ See [Installation](#installation) for other AI SDK versions.
724
736
 
725
737
  | Example | Description | Key Features |
726
738
  | ----------------------------------- | --------------------------- | --------------------------------------- |
@@ -750,24 +762,25 @@ npx tsx examples/example-generate-text.ts
750
762
  ### Upgrading from v3.x to v4.x
751
763
 
752
764
  Version 4.0 migrates from **LanguageModelV2** to **LanguageModelV3**
753
- specification (AI SDK 5.0+). **See the
765
+ specification (AI SDK 6). Package release 4.x is not the V4 provider
766
+ specification used by AI SDK 7. **See the
754
767
  [Migration Guide](./MIGRATION_GUIDE.md#version-3x-to-4x-breaking-changes) for
755
768
  complete upgrade instructions.**
756
769
 
757
- **Key changes:**
770
+ **Key changes in direct provider results (`doGenerate`/`doStream`):**
758
771
 
759
772
  - **Finish Reason**: Changed from string to object
760
773
  (`result.finishReason.unified`)
761
774
  - **Usage Structure**: Nested format with detailed token breakdown
762
775
  (`result.usage.inputTokens.total`)
763
- - **Stream Events**: Structured blocks (`text-start`, `text-delta`, `text-end`)
764
- instead of simple deltas
776
+ - **Stream Events**: Text blocks retain `text-start`, `text-delta`, and
777
+ `text-end`; finish and warning payloads use the V3 format
765
778
  - **Warning Types**: Updated format with `feature` field for categorization
766
779
 
767
780
  **Impact by user type:**
768
781
 
769
- - High-level API users (`generateText`/`streamText`): ✅ Minimal impact (likely
770
- no changes)
782
+ - High-level API users (`generateText`/`streamText`): use AI SDK 6 with the root
783
+ entrypoint. High-level token totals remain flat numbers.
771
784
  - Direct provider users: ⚠️ Update type imports (`LanguageModelV2` →
772
785
  `LanguageModelV3`)
773
786
  - Custom stream parsers: ⚠️ Update parsing logic for V3 structure