SAP AI Core Provider
The AI SDK supports SAP AI Core through two community providers:
- jerome-benoit/sap-ai-provider - Language Model V3 for AI SDK 5.x & 6.x (recommended)
- jerome-benoit/sap-ai-provider-v2 - Language Model V2 for AI SDK 5.x
Both providers are built on the official @sap-ai-sdk/orchestration and @sap-ai-sdk/foundation-models packages, providing language model and embedding support through the familiar AI SDK interface.
Features
Both providers offer:
- Dual API Support: Choose between Orchestration API (with data masking, content filtering, document grounding, translation) or Foundation Models API (direct model access)
- Tool calling and multi-modal input (images)
- Streaming support for real-time text generation
- Text embeddings for RAG and semantic search
Setup
@jerome-benoit/sap-ai-provider (recommended)
pnpm add @jerome-benoit/sap-ai-provider
@jerome-benoit/sap-ai-provider-v2
pnpm add @jerome-benoit/sap-ai-provider-v2
Authentication is handled automatically via the AICORE_SERVICE_KEY environment variable (local) or VCAP_SERVICES (SAP BTP).
Provider Instance
You can import the default provider instance sapai from @jerome-benoit/sap-ai-provider:
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:
import { createSAPAIProvider } from '@jerome-benoit/sap-ai-provider';
const sapai = createSAPAIProvider({ resourceGroup: 'default', api: 'orchestration', // or 'foundation-models'});You can use the following optional settings to customize the SAP AI 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.
-
api string
API to use:
'orchestration'(default) or'foundation-models'. Orchestration API supports data masking, content filtering, document grounding, and translation. -
defaultSettings object
Default model settings including
modelParams,masking,filtering,grounding, andtranslation.
Language Models
You can create models that call the SAP AI Core API using the provider instance. The first argument is the model id. Model naming follows SAP AI Core conventions with vendor prefixes:
const model = sapai('gpt-4o');const claudeModel = sapai('anthropic--claude-3.5-sonnet');const geminiModel = sapai('gemini-2.0-flash');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 .embeddingModel() factory method:
const model = sapai.embeddingModel('text-embedding-ada-002');