From 475f5c9b19b063f5361ffd4fd67e84b539b1db65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 27 Jan 2026 22:17:17 +0100 Subject: [PATCH 1/6] docs(community-providers): update SAP AI Core provider to @jerome-benoit/sap-ai-provider --- .../03-community-providers/39-sap-ai.mdx | 301 +++++------------- 1 file changed, 75 insertions(+), 226 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index dafecff6205e..6ba638431c83 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -5,240 +5,184 @@ description: SAP AI Core Provider for the AI SDK # SAP AI Core +[SAP AI Core](https://help.sap.com/docs/ai-core) is SAP's enterprise-grade AI platform providing access to 80+ models from OpenAI, Anthropic, Google, Amazon, and more through a unified, secure infrastructure. This community provider enables seamless integration with the Vercel AI SDK. + ## Important Note -> **Third-Party Provider**: This SAP AI Core provider (`@mymediset/sap-ai-provider`) is developed and maintained by Mymediset, not by SAP SE. While it uses the official SAP AI SDK and integrates with SAP AI Core services, it is not an official SAP product. For official SAP AI solutions, please refer to the [SAP AI Core Documentation](https://help.sap.com/docs/ai-functions). +> **Third-Party Provider**: This provider (`@jerome-benoit/sap-ai-provider`) is developed by jerome-benoit, not SAP SE. It uses the official SAP AI SDK but is not an official SAP product. -[SAP AI Core](https://help.sap.com/docs/ai-core) is SAP's enterprise-grade AI platform that provides access to leading AI models from OpenAI, Anthropic, Google, Amazon, and more through a unified, secure, and scalable infrastructure. The SAP AI Core provider for the AI SDK enables seamless integration with enterprise AI capabilities while offering unique advantages: +## Features -- **Multi-Model Access**: Support for 40+ models including GPT-4, Claude, Gemini, and Amazon Nova -- **Automatic Authentication**: Built-in credential handling via SAP AI SDK -- **Data Masking**: Built-in SAP Data Privacy Integration (DPI) for privacy +- **Multi-Model Access**: 80+ models (GPT-4o, Claude, Gemini, Amazon Nova, Llama) +- **Language Model V3**: Latest AI SDK specification with enhanced streaming +- **Text Embeddings**: Vector embeddings for RAG and semantic search +- **Tool Calling**: Full function calling capabilities +- **Multi-modal Input**: Text and image inputs +- **Data Masking**: Built-in SAP DPI integration for privacy - **Content Filtering**: Azure Content Safety and Llama Guard support -- **Cost Management**: Enterprise billing and usage tracking through SAP BTP -- **High Availability**: Enterprise-grade infrastructure with SLA guarantees -- **Hybrid Deployment**: Support for both cloud and on-premise deployments -- **Tool Calling**: Full function calling capabilities for compatible models -- **Multi-modal Support**: Text and image inputs for compatible models - -Learn more about SAP AI Core's capabilities in the [SAP AI Core Documentation](https://help.sap.com/docs/ai-core). +- **Automatic Authentication**: Via SAP AI SDK credentials ## Setup -The SAP AI Core provider is available in the `@mymediset/sap-ai-provider` module. You can install it with: - - + - + - + - + ## Provider Instance -To create an SAP AI Core provider instance, use the `createSAPAIProvider` function. The provider is now **synchronous** and authentication is handled automatically via the SAP AI SDK: - ```typescript -import { createSAPAIProvider } from '@mymediset/sap-ai-provider'; +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; // Authentication via AICORE_SERVICE_KEY environment variable const sapai = createSAPAIProvider(); -``` -You can obtain your SAP AI Core service key from your SAP BTP Cockpit by creating a service key for your AI Core instance, then set it as the `AICORE_SERVICE_KEY` environment variable. +// Or use the default instance +import { sapai } from '@jerome-benoit/sap-ai-provider'; +``` ## Language Models -You can create SAP AI Core models using the provider instance and model name: - ```typescript -// Azure OpenAI models const gpt4Model = sapai('gpt-4o'); - -// Anthropic models (via AWS Bedrock) const claudeModel = sapai('anthropic--claude-3.5-sonnet'); - -// Google Vertex AI models const geminiModel = sapai('gemini-2.5-flash'); - -// Amazon Nova models (via AWS Bedrock) const novaModel = sapai('amazon--nova-pro'); ``` ## Supported Models -The provider supports a wide range of models available in your SAP AI Core deployment: - -### Azure OpenAI Models +### Azure OpenAI -- `gpt-4o`, `gpt-4o-mini` -- `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano` +- `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano` - `o1`, `o3`, `o3-mini`, `o4-mini` -### Anthropic Models (AWS Bedrock) +### Anthropic (AWS Bedrock) - `anthropic--claude-3-haiku`, `anthropic--claude-3-sonnet`, `anthropic--claude-3-opus` - `anthropic--claude-3.5-sonnet`, `anthropic--claude-3.7-sonnet` - `anthropic--claude-4-sonnet`, `anthropic--claude-4-opus` -### Google Vertex AI Models +### Google Vertex AI - `gemini-2.0-flash`, `gemini-2.0-flash-lite` - `gemini-2.5-flash`, `gemini-2.5-pro` -### Amazon Nova Models (AWS Bedrock) +### Amazon Nova (AWS Bedrock) - `amazon--nova-premier`, `amazon--nova-pro`, `amazon--nova-lite`, `amazon--nova-micro` -### AI Core Open Source Models +### Open Source -- `mistralai--mistral-large-instruct`, `mistralai--mistral-medium-instruct`, `mistralai--mistral-small-instruct` +- `mistralai--mistral-large-instruct`, `meta--llama3.1-70b-instruct` - `cohere--command-a-reasoning` -Note: Model availability may vary based on your SAP AI Core subscription and region. Some models may require additional configuration or permissions. +> Model availability depends on your SAP AI Core tenant configuration. ## Examples -Here are examples of using SAP AI Core with the AI SDK: - ### generateText ```typescript -import { createSAPAIProvider } from '@mymediset/sap-ai-provider'; +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; import { generateText } from 'ai'; -// Authentication via AICORE_SERVICE_KEY environment variable const sapai = createSAPAIProvider(); const { text } = await generateText({ model: sapai('gpt-4o'), prompt: 'What are the benefits of enterprise AI platforms?', }); - -console.log(text); ``` ### streamText ```typescript -import { createSAPAIProvider } from '@mymediset/sap-ai-provider'; +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; import { streamText } from 'ai'; const sapai = createSAPAIProvider(); -const result = await streamText({ +const result = streamText({ model: sapai('anthropic--claude-3.5-sonnet'), prompt: 'Write a short story about AI.', }); -for await (const textPart of result.textStream) { - process.stdout.write(textPart); +for await (const delta of result.textStream) { + process.stdout.write(delta); } ``` -### Tool Calling +### Embeddings ```typescript -import { createSAPAIProvider } from '@mymediset/sap-ai-provider'; -import { generateText, tool } from 'ai'; -import { z } from 'zod'; +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +import { embed, embedMany } from 'ai'; const sapai = createSAPAIProvider(); -const result = await generateText({ - model: sapai('gpt-4o'), - prompt: 'What is the current status of our inventory system?', - tools: { - checkInventory: tool({ - description: 'Check current inventory levels', - parameters: z.object({ - item: z.string().describe('Item to check'), - location: z.string().describe('Warehouse location'), - }), - execute: async ({ item, location }) => { - // Your inventory system integration - return { item, location, quantity: 150, status: 'In Stock' }; - }, - }), - }, - maxSteps: 3, +const { embedding } = await embed({ + model: sapai.embedding('text-embedding-ada-002'), + value: 'What is machine learning?', }); -console.log(result.text); +const { embeddings } = await embedMany({ + model: sapai.embedding('text-embedding-3-small'), + values: ['Hello world', 'AI is amazing', 'Vector search'], +}); ``` -### Multi-modal Input +### Tool Calling ```typescript -import { createSAPAIProvider } from '@mymediset/sap-ai-provider'; -import { generateText } from 'ai'; +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +import { generateText, tool } from 'ai'; +import { z } from 'zod'; const sapai = createSAPAIProvider(); const result = await generateText({ model: sapai('gpt-4o'), - messages: [ - { - role: 'user', - content: [ - { type: 'text', text: 'Analyze this business process diagram.' }, - { - type: 'image', - image: new URL('https://example.com/diagram.jpg'), - }, - ], - }, - ], + prompt: 'What is the weather in Tokyo?', + tools: { + getWeather: tool({ + description: 'Get weather for a location', + parameters: z.object({ location: z.string() }), + execute: async ({ location }) => `Weather in ${location}: sunny, 72°F`, + }), + }, + maxSteps: 3, }); - -console.log(result.text); ``` ### Data Masking (SAP DPI) -Use SAP's Data Privacy Integration to automatically mask sensitive data: - ```typescript import { createSAPAIProvider, buildDpiMaskingProvider, -} from '@mymediset/sap-ai-provider'; -import { generateText } from 'ai'; +} from '@jerome-benoit/sap-ai-provider'; const dpiConfig = buildDpiMaskingProvider({ method: 'anonymization', - entities: [ - 'profile-email', - 'profile-person', - { - type: 'profile-phone', - replacement_strategy: { method: 'constant', value: 'REDACTED' }, - }, - ], + entities: ['profile-email', 'profile-person', 'profile-phone'], }); const sapai = createSAPAIProvider({ defaultSettings: { - masking: { - masking_providers: [dpiConfig], - }, + masking: { masking_providers: [dpiConfig] }, }, }); - -const result = await generateText({ - model: sapai('gpt-4o'), - prompt: 'Email john@example.com about the meeting.', -}); - -console.log(result.text); ``` ### Content Filtering @@ -247,7 +191,7 @@ console.log(result.text); import { createSAPAIProvider, buildAzureContentSafetyFilter, -} from '@mymediset/sap-ai-provider'; +} from '@jerome-benoit/sap-ai-provider'; const sapai = createSAPAIProvider({ defaultSettings: { @@ -267,131 +211,36 @@ const sapai = createSAPAIProvider({ ## Configuration -### Provider Settings - -```typescript -interface SAPAIProviderSettings { - resourceGroup?: string; // SAP AI Core resource group (default: 'default') - deploymentId?: string; // Specific deployment ID (auto-resolved if not set) - destination?: HttpDestinationOrFetchOptions; // Custom destination - defaultSettings?: SAPAISettings; // Default settings for all models -} -``` - -### Model Settings - ```typescript -interface SAPAISettings { - modelVersion?: string; // Model version (default: 'latest') - modelParams?: { - maxTokens?: number; // Maximum tokens to generate - temperature?: number; // Sampling temperature (0-2) - topP?: number; // Nucleus sampling parameter - frequencyPenalty?: number; // Frequency penalty (-2 to 2) - presencePenalty?: number; // Presence penalty (-2 to 2) - n?: number; // Number of completions - parallel_tool_calls?: boolean; // Enable parallel tool calls - }; - masking?: MaskingModule; // Data masking configuration - filtering?: FilteringModule; // Content filtering configuration -} +const sapai = createSAPAIProvider({ + resourceGroup: 'default', // SAP AI Core resource group + deploymentId: 'your-deployment-id', // Optional, auto-resolved if not set + defaultSettings: { + modelParams: { + temperature: 0.7, + maxTokens: 2000, + topP: 0.9, + }, + }, +}); ``` -## Environment Variables +## Environment Setup -### On SAP BTP (Recommended) +### SAP BTP (Recommended) -When running on SAP BTP, bind an AI Core service instance to your application. The SDK will automatically detect the service binding from `VCAP_SERVICES`. +Bind an AI Core service instance to your app. The SDK auto-detects `VCAP_SERVICES`. ### Local Development -Set the `AICORE_SERVICE_KEY` environment variable with your service key JSON: +Set `AICORE_SERVICE_KEY` with your service key JSON: ```bash AICORE_SERVICE_KEY='{"serviceurls":{"AI_API_URL":"https://..."},"clientid":"...","clientsecret":"...","url":"..."}' ``` -Get your service key from SAP BTP: - -1. Go to your SAP BTP Cockpit -2. Navigate to your AI Core instance -3. Create a service key -4. Copy the JSON and set it as the environment variable - -## Enterprise Features - -SAP AI Core offers several enterprise-grade features: - -- **Multi-Tenant Architecture**: Isolated environments for different business units -- **Cost Allocation**: Detailed usage tracking and cost center allocation -- **Custom Models**: Deploy and manage your own fine-tuned models -- **Hybrid Deployment**: Support for both cloud and on-premise installations -- **Integration Ready**: Native integration with SAP S/4HANA, SuccessFactors, and other SAP solutions - -For more information about these features and advanced configuration options, visit the [SAP AI Core Documentation](https://help.sap.com/docs/ai-core). - -## Migration from v1 - -Version 2.0 is a complete rewrite using the official SAP AI SDK. Here are the key changes: - -### Authentication - -**Before (v1):** - -```typescript -const provider = await createSAPAIProvider({ - serviceKey: process.env.SAP_AI_SERVICE_KEY, -}); -``` - -**After (v2):** - -```typescript -// Set AICORE_SERVICE_KEY env var instead -const provider = createSAPAIProvider(); -``` - -### Provider is now synchronous - -**Before (v1):** - -```typescript -const provider = await createSAPAIProvider({ serviceKey }); -``` - -**After (v2):** - -```typescript -const provider = createSAPAIProvider(); -``` - -### Data Masking Configuration - -**Before (v1):** - -```typescript -const dpiMasking = { - type: 'sap_data_privacy_integration', - method: 'anonymization', - entities: [{ type: 'profile-email' }], -}; -``` - -**After (v2):** - -```typescript -import { buildDpiMaskingProvider } from '@mymediset/sap-ai-provider'; - -const dpiMasking = buildDpiMaskingProvider({ - method: 'anonymization', - entities: ['profile-email'], -}); -``` - ## Additional Resources -- [SAP AI Provider Repository](https://github.com/BITASIA/sap-ai-provider) +- [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) - [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) - [SAP BTP Documentation](https://help.sap.com/docs/btp) -- [SAP Community](https://community.sap.com/t5/c-khhcw49343/SAP+AI+Core/pd-p/73555000100800003283) -- [SAP AI Core Service Guide](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide) From ab354b1dc41052f9527409695dd735dae472b6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 27 Jan 2026 22:23:04 +0100 Subject: [PATCH 2/6] docs: add package versions section and reduce duplication - Add table showing both NPM packages (V3 and V2) - Clarify AI SDK version compatibility - Add Document Grounding and Translation to features - Remove detailed model list (refer to repo docs) - Remove advanced examples (DPI, Content Filtering) to avoid duplication - Link to V2 repository in Additional Resources --- .../03-community-providers/39-sap-ai.mdx | 91 ++++--------------- 1 file changed, 16 insertions(+), 75 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index 6ba638431c83..354bd11d0e81 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -9,7 +9,18 @@ description: SAP AI Core Provider for the AI SDK ## Important Note -> **Third-Party Provider**: This provider (`@jerome-benoit/sap-ai-provider`) is developed by jerome-benoit, not SAP SE. It uses the official SAP AI SDK but is not an official SAP product. +> **Third-Party Provider**: This provider is developed by jerome-benoit, not SAP SE. It uses the official SAP AI SDK but is not an official SAP product. + +## Package Versions + +Two package versions are available depending on your AI SDK version: + +| Package | AI SDK | Language Model Spec | NPM | +|---------|--------|---------------------|-----| +| `@jerome-benoit/sap-ai-provider` | 5.x & 6.x | V3 (recommended) | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) | +| `@jerome-benoit/sap-ai-provider-v2` | 5.x only | V2 | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider-v2) | + +> Use the V3 package (`@jerome-benoit/sap-ai-provider`) for new projects. The V2 package is maintained for compatibility with AI SDK 5.x projects that require Language Model V2 specification. ## Features @@ -20,6 +31,8 @@ description: SAP AI Core Provider for the AI SDK - **Multi-modal Input**: Text and image inputs - **Data Masking**: Built-in SAP DPI integration for privacy - **Content Filtering**: Azure Content Safety and Llama Guard support +- **Document Grounding**: RAG with vector databases +- **Translation**: Automatic input/output translation - **Automatic Authentication**: Via SAP AI SDK credentials ## Setup @@ -60,35 +73,6 @@ const geminiModel = sapai('gemini-2.5-flash'); const novaModel = sapai('amazon--nova-pro'); ``` -## Supported Models - -### Azure OpenAI - -- `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano` -- `o1`, `o3`, `o3-mini`, `o4-mini` - -### Anthropic (AWS Bedrock) - -- `anthropic--claude-3-haiku`, `anthropic--claude-3-sonnet`, `anthropic--claude-3-opus` -- `anthropic--claude-3.5-sonnet`, `anthropic--claude-3.7-sonnet` -- `anthropic--claude-4-sonnet`, `anthropic--claude-4-opus` - -### Google Vertex AI - -- `gemini-2.0-flash`, `gemini-2.0-flash-lite` -- `gemini-2.5-flash`, `gemini-2.5-pro` - -### Amazon Nova (AWS Bedrock) - -- `amazon--nova-premier`, `amazon--nova-pro`, `amazon--nova-lite`, `amazon--nova-micro` - -### Open Source - -- `mistralai--mistral-large-instruct`, `meta--llama3.1-70b-instruct` -- `cohere--command-a-reasoning` - -> Model availability depends on your SAP AI Core tenant configuration. - ## Examples ### generateText @@ -165,50 +149,6 @@ const result = await generateText({ }); ``` -### Data Masking (SAP DPI) - -```typescript -import { - createSAPAIProvider, - buildDpiMaskingProvider, -} from '@jerome-benoit/sap-ai-provider'; - -const dpiConfig = buildDpiMaskingProvider({ - method: 'anonymization', - entities: ['profile-email', 'profile-person', 'profile-phone'], -}); - -const sapai = createSAPAIProvider({ - defaultSettings: { - masking: { masking_providers: [dpiConfig] }, - }, -}); -``` - -### Content Filtering - -```typescript -import { - createSAPAIProvider, - buildAzureContentSafetyFilter, -} from '@jerome-benoit/sap-ai-provider'; - -const sapai = createSAPAIProvider({ - defaultSettings: { - filtering: { - input: { - filters: [ - buildAzureContentSafetyFilter('input', { - hate: 'ALLOW_SAFE', - violence: 'ALLOW_SAFE_LOW_MEDIUM', - }), - ], - }, - }, - }, -}); -``` - ## Configuration ```typescript @@ -241,6 +181,7 @@ AICORE_SERVICE_KEY='{"serviceurls":{"AI_API_URL":"https://..."},"clientid":"..." ## Additional Resources -- [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) +- [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) - Full documentation, API reference, and examples +- [SAP AI Provider V2 Repository](https://github.com/jerome-benoit/sap-ai-provider-v2) - V2 version for AI SDK 5.x - [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) - [SAP BTP Documentation](https://help.sap.com/docs/btp) From 4b87bf27af3fb59e175cb522fa642c63ce218fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 27 Jan 2026 22:29:20 +0100 Subject: [PATCH 3/6] docs: address Copilot review comments - Add NPM link to Additional Resources section - Fix gemini-2.5-flash to gemini-2.0-flash (verified model name) - Clarify sapai singleton import pattern with better comment - Add version requirement note (v4.3.0+) in Package Versions section - Add explanatory text for embedding model naming convention - Add console.log output to examples for completeness --- .../03-community-providers/39-sap-ai.mdx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index 354bd11d0e81..cbb50541cd51 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -20,7 +20,7 @@ Two package versions are available depending on your AI SDK version: | `@jerome-benoit/sap-ai-provider` | 5.x & 6.x | V3 (recommended) | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) | | `@jerome-benoit/sap-ai-provider-v2` | 5.x only | V2 | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider-v2) | -> Use the V3 package (`@jerome-benoit/sap-ai-provider`) for new projects. The V2 package is maintained for compatibility with AI SDK 5.x projects that require Language Model V2 specification. +> Use the V3 package (`@jerome-benoit/sap-ai-provider`) for new projects (requires v4.3.0+). The V2 package is maintained for compatibility with AI SDK 5.x projects that require Language Model V2 specification. ## Features @@ -57,10 +57,10 @@ Two package versions are available depending on your AI SDK version: ```typescript import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; -// Authentication via AICORE_SERVICE_KEY environment variable +// Create provider with automatic authentication via AICORE_SERVICE_KEY environment variable const sapai = createSAPAIProvider(); -// Or use the default instance +// Or use the default singleton instance (no custom configuration) import { sapai } from '@jerome-benoit/sap-ai-provider'; ``` @@ -69,7 +69,7 @@ import { sapai } from '@jerome-benoit/sap-ai-provider'; ```typescript const gpt4Model = sapai('gpt-4o'); const claudeModel = sapai('anthropic--claude-3.5-sonnet'); -const geminiModel = sapai('gemini-2.5-flash'); +const geminiModel = sapai('gemini-2.0-flash'); const novaModel = sapai('amazon--nova-pro'); ``` @@ -87,6 +87,8 @@ const { text } = await generateText({ model: sapai('gpt-4o'), prompt: 'What are the benefits of enterprise AI platforms?', }); + +console.log(text); ``` ### streamText @@ -109,6 +111,8 @@ for await (const delta of result.textStream) { ### Embeddings +The provider supports both `embedding()` and the standard `embeddingModel()` methods. Embedding model names follow SAP AI Core conventions (e.g., `text-embedding-ada-002`, `text-embedding-3-small`). + ```typescript import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; import { embed, embedMany } from 'ai'; @@ -120,10 +124,14 @@ const { embedding } = await embed({ value: 'What is machine learning?', }); +console.log('Embedding dimensions:', embedding.length); + const { embeddings } = await embedMany({ model: sapai.embedding('text-embedding-3-small'), values: ['Hello world', 'AI is amazing', 'Vector search'], }); + +console.log('Generated', embeddings.length, 'embeddings'); ``` ### Tool Calling @@ -182,6 +190,7 @@ AICORE_SERVICE_KEY='{"serviceurls":{"AI_API_URL":"https://..."},"clientid":"..." ## Additional Resources - [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) - Full documentation, API reference, and examples +- [SAP AI Provider on NPM](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) - Package information and version history - [SAP AI Provider V2 Repository](https://github.com/jerome-benoit/sap-ai-provider-v2) - V2 version for AI SDK 5.x - [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) - [SAP BTP Documentation](https://help.sap.com/docs/btp) From 92ff0190892abb64da2201202b48ac8ecae9a8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 27 Jan 2026 22:32:04 +0100 Subject: [PATCH 4/6] docs: harmonize MDX with Vercel community provider conventions - Follow Ollama pattern for documenting two provider packages - Add 'Choosing Your Provider' section like other multi-package providers - Add separate Setup tabs for V3 and V2 packages - Document provider options in standard format (baseURL, headers style) - Add Language Models and Embedding Models sections (standard pattern) - Add Model Capabilities table with Check/Cross icons - Move third-party disclaimer to end as Note (standard placement) - Remove Features bullet list (link to repo for details) - Remove Package Versions table (non-standard format) - Use 'ts' code blocks instead of 'typescript' (Vercel convention) - Add Note components for important information --- .../03-community-providers/39-sap-ai.mdx | 205 ++++++++++-------- 1 file changed, 118 insertions(+), 87 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index cbb50541cd51..a6e0c13724cf 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -1,42 +1,39 @@ --- title: SAP AI Core -description: SAP AI Core Provider for the AI SDK +description: Learn how to use the SAP AI Core provider for the AI SDK. --- -# SAP AI Core +# SAP AI Core Provider -[SAP AI Core](https://help.sap.com/docs/ai-core) is SAP's enterprise-grade AI platform providing access to 80+ models from OpenAI, Anthropic, Google, Amazon, and more through a unified, secure infrastructure. This community provider enables seamless integration with the Vercel AI SDK. +The AI SDK supports [SAP AI Core](https://help.sap.com/docs/ai-core) through two community providers: -## Important Note +- [@jerome-benoit/sap-ai-provider](https://github.com/jerome-benoit/sap-ai-provider) - Language Model V3 for AI SDK 5.x & 6.x (recommended) +- [@jerome-benoit/sap-ai-provider-v2](https://github.com/jerome-benoit/sap-ai-provider-v2) - Language Model V2 for AI SDK 5.x -> **Third-Party Provider**: This provider is developed by jerome-benoit, not SAP SE. It uses the official SAP AI SDK but is not an official SAP product. +Both providers are built on the official **@sap-ai-sdk/orchestration** package and provide access to 80+ models (GPT-4o, Claude, Gemini, Amazon Nova, Llama) through SAP's enterprise-grade AI platform. -## Package Versions +## Choosing Your Provider -Two package versions are available depending on your AI SDK version: +### For New Projects (Recommended) -| Package | AI SDK | Language Model Spec | NPM | -|---------|--------|---------------------|-----| -| `@jerome-benoit/sap-ai-provider` | 5.x & 6.x | V3 (recommended) | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) | -| `@jerome-benoit/sap-ai-provider-v2` | 5.x only | V2 | [npm](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider-v2) | +[@jerome-benoit/sap-ai-provider](https://github.com/jerome-benoit/sap-ai-provider) implements Language Model V3 specification with: -> Use the V3 package (`@jerome-benoit/sap-ai-provider`) for new projects (requires v4.3.0+). The V2 package is maintained for compatibility with AI SDK 5.x projects that require Language Model V2 specification. +- AI SDK 5.x and 6.x compatibility +- Enhanced streaming with structured V3 blocks +- Latest AI SDK features support -## Features +### For AI SDK 5.x with V2 Specification -- **Multi-Model Access**: 80+ models (GPT-4o, Claude, Gemini, Amazon Nova, Llama) -- **Language Model V3**: Latest AI SDK specification with enhanced streaming -- **Text Embeddings**: Vector embeddings for RAG and semantic search -- **Tool Calling**: Full function calling capabilities -- **Multi-modal Input**: Text and image inputs -- **Data Masking**: Built-in SAP DPI integration for privacy -- **Content Filtering**: Azure Content Safety and Llama Guard support -- **Document Grounding**: RAG with vector databases -- **Translation**: Automatic input/output translation -- **Automatic Authentication**: Via SAP AI SDK credentials +[@jerome-benoit/sap-ai-provider-v2](https://github.com/jerome-benoit/sap-ai-provider-v2) is maintained for projects that require Language Model V2 specification compatibility. + +Both providers share the same API surface and features - only the underlying specification differs. ## Setup +Choose and install your preferred provider: + +### @jerome-benoit/sap-ai-provider (V3) + @@ -52,37 +49,93 @@ Two package versions are available depending on your AI SDK version: -## Provider Instance +### @jerome-benoit/sap-ai-provider-v2 (V2) -```typescript -import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; + + + + + + + + + + + + + + + +### Environment Variables -// Create provider with automatic authentication via AICORE_SERVICE_KEY environment variable -const sapai = createSAPAIProvider(); +Authentication is handled via the `AICORE_SERVICE_KEY` environment variable containing your SAP AI Core service key JSON. -// Or use the default singleton instance (no custom configuration) +## Provider Instance + +You can import the default provider instance `sapai` from the package: + +```ts import { sapai } from '@jerome-benoit/sap-ai-provider'; ``` +If you need a customized setup, you can import `createSAPAIProvider` and create a provider instance with your settings: + +```ts +import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; + +const sapai = createSAPAIProvider({ + resourceGroup: 'default', + // optional settings +}); +``` + +You can use the following optional settings to customize the provider instance: + +- **resourceGroup** _string_ + + SAP AI Core resource group. Defaults to `'default'`. + +- **deploymentId** _string_ + + Specific deployment ID. If not provided, the SDK resolves deployment automatically. + ## Language Models -```typescript +You can create models that call the SAP AI Core Orchestration API using the provider instance. The first argument is the model id. + +```ts +const model = sapai('gpt-4o'); +``` + +Model naming follows SAP AI Core conventions. Some models require vendor prefixes: + +```ts const gpt4Model = sapai('gpt-4o'); const claudeModel = sapai('anthropic--claude-3.5-sonnet'); const geminiModel = sapai('gemini-2.0-flash'); const novaModel = sapai('amazon--nova-pro'); ``` + + Model availability depends on your SAP AI Core tenant configuration and region. + + +## Embedding Models + +You can create models that call the SAP AI Core embeddings API using the `.embedding()` factory method. + +```ts +const model = sapai.embedding('text-embedding-ada-002'); +``` + ## Examples -### generateText +### `generateText` -```typescript -import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +```ts +import { sapai } from '@jerome-benoit/sap-ai-provider'; import { generateText } from 'ai'; -const sapai = createSAPAIProvider(); - const { text } = await generateText({ model: sapai('gpt-4o'), prompt: 'What are the benefits of enterprise AI platforms?', @@ -91,59 +144,47 @@ const { text } = await generateText({ console.log(text); ``` -### streamText +### `streamText` -```typescript -import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +```ts +import { sapai } from '@jerome-benoit/sap-ai-provider'; import { streamText } from 'ai'; -const sapai = createSAPAIProvider(); - const result = streamText({ model: sapai('anthropic--claude-3.5-sonnet'), prompt: 'Write a short story about AI.', }); -for await (const delta of result.textStream) { - process.stdout.write(delta); +for await (const textPart of result.textStream) { + process.stdout.write(textPart); } ``` ### Embeddings -The provider supports both `embedding()` and the standard `embeddingModel()` methods. Embedding model names follow SAP AI Core conventions (e.g., `text-embedding-ada-002`, `text-embedding-3-small`). - -```typescript -import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +```ts +import { sapai } from '@jerome-benoit/sap-ai-provider'; import { embed, embedMany } from 'ai'; -const sapai = createSAPAIProvider(); - const { embedding } = await embed({ model: sapai.embedding('text-embedding-ada-002'), value: 'What is machine learning?', }); -console.log('Embedding dimensions:', embedding.length); - const { embeddings } = await embedMany({ model: sapai.embedding('text-embedding-3-small'), values: ['Hello world', 'AI is amazing', 'Vector search'], }); - -console.log('Generated', embeddings.length, 'embeddings'); ``` ### Tool Calling -```typescript -import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider'; +```ts +import { sapai } from '@jerome-benoit/sap-ai-provider'; import { generateText, tool } from 'ai'; import { z } from 'zod'; -const sapai = createSAPAIProvider(); - -const result = await generateText({ +const { text } = await generateText({ model: sapai('gpt-4o'), prompt: 'What is the weather in Tokyo?', tools: { @@ -157,40 +198,30 @@ const result = await generateText({ }); ``` -## Configuration +## Advanced Features -```typescript -const sapai = createSAPAIProvider({ - resourceGroup: 'default', // SAP AI Core resource group - deploymentId: 'your-deployment-id', // Optional, auto-resolved if not set - defaultSettings: { - modelParams: { - temperature: 0.7, - maxTokens: 2000, - topP: 0.9, - }, - }, -}); -``` +The provider supports SAP AI Core enterprise features: -## Environment Setup +- **Data Masking** - SAP Data Privacy Integration (DPI) for anonymization +- **Content Filtering** - Azure Content Safety and Llama Guard +- **Document Grounding** - RAG with vector databases +- **Translation** - Automatic input/output translation -### SAP BTP (Recommended) +For complete documentation on these features, see the [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider). -Bind an AI Core service instance to your app. The SDK auto-detects `VCAP_SERVICES`. +## Model Capabilities -### Local Development - -Set `AICORE_SERVICE_KEY` with your service key JSON: - -```bash -AICORE_SERVICE_KEY='{"serviceurls":{"AI_API_URL":"https://..."},"clientid":"...","clientsecret":"...","url":"..."}' -``` +| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | +| ----------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `gpt-4o` | | | | | +| `anthropic--claude-3.5-sonnet`| | | | | +| `gemini-2.0-flash` | | | | | +| `amazon--nova-pro` | | | | | -## Additional Resources + + Google Gemini models have a 1 tool limit per request. For multi-tool applications, use GPT-4o, Claude, or Amazon Nova models. + -- [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) - Full documentation, API reference, and examples -- [SAP AI Provider on NPM](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) - Package information and version history -- [SAP AI Provider V2 Repository](https://github.com/jerome-benoit/sap-ai-provider-v2) - V2 version for AI SDK 5.x -- [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) -- [SAP BTP Documentation](https://help.sap.com/docs/btp) + + This provider is developed by jerome-benoit, not SAP SE. While it uses the official SAP AI SDK, it is not an official SAP product. + From 30d47764d94a6644f6a4984ab12f59d5834b24b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 27 Jan 2026 22:38:20 +0100 Subject: [PATCH 5/6] docs(sap-ai): address review comments and harmonize with Vercel conventions - Use .embeddingModel() instead of .embedding() per AI SDK convention - Add console.log to all code examples for completeness - Add note about embedding model naming convention - Add Resources section with NPM link - Add version requirement note (v4.3.0+) - Fix table alignment for model capabilities --- .../03-community-providers/39-sap-ai.mdx | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index a6e0c13724cf..49b273798f14 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -66,6 +66,10 @@ Choose and install your preferred provider: + + The features documented below require version 4.3.0 or higher of the provider package. + + ### Environment Variables Authentication is handled via the `AICORE_SERVICE_KEY` environment variable containing your SAP AI Core service key JSON. @@ -122,12 +126,14 @@ const novaModel = sapai('amazon--nova-pro'); ## Embedding Models -You can create models that call the SAP AI Core embeddings API using the `.embedding()` factory method. +You can create models that call the SAP AI Core embeddings API using the `.embeddingModel()` factory method. ```ts -const model = sapai.embedding('text-embedding-ada-002'); +const model = sapai.embeddingModel('text-embedding-ada-002'); ``` +Embedding models use the same naming convention as language models. Azure OpenAI embedding models (e.g., `text-embedding-ada-002`, `text-embedding-3-small`) do not require a vendor prefix. + ## Examples ### `generateText` @@ -167,14 +173,18 @@ import { sapai } from '@jerome-benoit/sap-ai-provider'; import { embed, embedMany } from 'ai'; const { embedding } = await embed({ - model: sapai.embedding('text-embedding-ada-002'), + model: sapai.embeddingModel('text-embedding-ada-002'), value: 'What is machine learning?', }); +console.log(embedding); + const { embeddings } = await embedMany({ - model: sapai.embedding('text-embedding-3-small'), + model: sapai.embeddingModel('text-embedding-3-small'), values: ['Hello world', 'AI is amazing', 'Vector search'], }); + +console.log(embeddings); ``` ### Tool Calling @@ -196,6 +206,8 @@ const { text } = await generateText({ }, maxSteps: 3, }); + +console.log(text); ``` ## Advanced Features @@ -211,17 +223,23 @@ For complete documentation on these features, see the [SAP AI Provider Repositor ## Model Capabilities -| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | -| ----------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | -| `gpt-4o` | | | | | -| `anthropic--claude-3.5-sonnet`| | | | | -| `gemini-2.0-flash` | | | | | -| `amazon--nova-pro` | | | | | +| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | +| ------------------------------ | ------------------- | ------------------- | ------------------- | ------------------- | +| `gpt-4o` | | | | | +| `anthropic--claude-3.5-sonnet` | | | | | +| `gemini-2.0-flash` | | | | | +| `amazon--nova-pro` | | | | | Google Gemini models have a 1 tool limit per request. For multi-tool applications, use GPT-4o, Claude, or Amazon Nova models. +## Resources + +- [SAP AI Provider Repository](https://github.com/jerome-benoit/sap-ai-provider) +- [SAP AI Provider on NPM](https://www.npmjs.com/package/@jerome-benoit/sap-ai-provider) +- [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) + This provider is developed by jerome-benoit, not SAP SE. While it uses the official SAP AI SDK, it is not an official SAP product. From 8a3bdb5f09b1c1d182c0445e4b806de50b690f81 Mon Sep 17 00:00:00 2001 From: "vercel-ai-sdk[bot]" <225926702+vercel-ai-sdk[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 10:21:23 +0000 Subject: [PATCH 6/6] style: prettier --- .../providers/03-community-providers/39-sap-ai.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/content/providers/03-community-providers/39-sap-ai.mdx b/content/providers/03-community-providers/39-sap-ai.mdx index 49b273798f14..16bec2ef27b9 100644 --- a/content/providers/03-community-providers/39-sap-ai.mdx +++ b/content/providers/03-community-providers/39-sap-ai.mdx @@ -67,7 +67,8 @@ Choose and install your preferred provider: - The features documented below require version 4.3.0 or higher of the provider package. + The features documented below require version 4.3.0 or higher of the provider + package. ### Environment Variables @@ -121,7 +122,8 @@ const novaModel = sapai('amazon--nova-pro'); ``` - Model availability depends on your SAP AI Core tenant configuration and region. + Model availability depends on your SAP AI Core tenant configuration and + region. ## Embedding Models @@ -231,7 +233,8 @@ For complete documentation on these features, see the [SAP AI Provider Repositor | `amazon--nova-pro` | | | | | - Google Gemini models have a 1 tool limit per request. For multi-tool applications, use GPT-4o, Claude, or Amazon Nova models. + Google Gemini models have a 1 tool limit per request. For multi-tool + applications, use GPT-4o, Claude, or Amazon Nova models. ## Resources @@ -241,5 +244,6 @@ For complete documentation on these features, see the [SAP AI Provider Repositor - [SAP AI Core Documentation](https://help.sap.com/docs/ai-core) - This provider is developed by jerome-benoit, not SAP SE. While it uses the official SAP AI SDK, it is not an official SAP product. + This provider is developed by jerome-benoit, not SAP SE. While it uses the + official SAP AI SDK, it is not an official SAP product.