@ai-foundry/sap-aicore-provider
v0.0.10
Published
SAP AI Core Foundation Models provider plugin for Vercel AI SDK
Downloads
247
Readme
sap-aicore-provider
SAP AI Core Foundation Models provider plugin for Vercel AI SDK
Overview
This package enables seamless integration of SAP AI Core Foundation Models with the Vercel AI SDK. Use it to access SAP-hosted foundation language models in your Node.js AI applications.
Installation
npm install @ai-foundry/sap-aicore-provider aiUsage
Using sap-aicore-provider
import { sapAiCore } from '@ai-foundry/sap-aicore-provider';
import { generateText } from 'ai';
const { text } = await generateText({
model: sapAiCore('sap-aicore/gpt-4o'),
prompt: 'Hello, how are you?'
});Configuration
You can configure the SAP AI Core provider using the createSapAiCore function. Below are the most common options:
Basic Example
import { createSapAiCore } from '@ai-foundry/sap-aicore-provider';
const sapAiCore = createSapAiCore({
deploymentUrl: 'https://your-sap-aicore-instance', // Required: Your SAP AI Core deployment URL
headers: {
'Custom-Header': 'value' // Optional: Add any custom headers
}
});Using a Token Provider
To automatically fetch an access token before each request, use the tokenProvider option:
const sapAiCore = createSapAiCore({
deploymentUrl: 'https://your-sap-aicore-instance',
tokenProvider: {
accessTokenBaseUrl: 'https://auth.example.com/token', // Auth endpoint
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
cacheMaxAgeMs: 3600000 // Optional: Token cache duration (default 1h)
}
});Environment Variables
You can also provide configuration values using environment variables:
AICORE_DEPLOYMENT_URLAICORE_AUTH_URLAICORE_CLIENT_IDAICORE_CLIENT_SECRET
Tokens are cached for one hour by default to reduce token provider requests.
License
MIT
Contributing
Contributions are welcome! Please open issues or pull requests on GitHub.
