This file provides guidance to Code Agents such Claude Code (claude.ai/code) when working with code in this repository.
SAP AI Core Foundation Models provider plugin for Vercel AI SDK. Enables integration of SAP-hosted foundation language models with the Vercel AI SDK in Node.js applications.
# Full CI validation (run before committing)
pnpm run ci:check
# Individual commands
pnpm run build # Build all packages with tsup
pnpm run test # Run vitest tests
pnpm run lint # TypeScript type checking
pnpm run format # Format with Prettier
pnpm run format:check # Check formatting
# Run the basic example
pnpm --filter basic-example start
# Run the streaming example
pnpm --filter streaming-example start
# Validate package exports
pnpm --filter @ai-foundry/sap-aicore-provider exports:checkpackages/sap-aicore-provider/- Main Vercel AI SDK provider package for SAP AI Core (@ai-foundry/sap-aicore-provider)packages/sap-aicore-nano-sdk/- Lightweight SDK helpers for SAP AI Core (@ai-foundry/sap-aicore-nano-sdk)examples/basic/- Basic usage example withgenerateTextexamples/streaming/- Streaming example withstreamTextexamples/mastra-agents/- Example using Mastra Agents with SAP AI Coreexamples/openai-agents/- Example using OpenAI Agents SDK with SAP AI Core
Provider Factory (sap-aicore-provider.ts)
createSapAiCore()- Factory function that configures and returns a Vercel AI SDK v3-compatible providersapAiCore- Default instance export for simple usage- Only chat models are supported; other model types throw
NoSuchModelError
API Client (sap-aicore-nano-sdk.ts)
- Handles OAuth 2.0 client credentials authentication with token caching
- Resolves model IDs to deployment URLs via SAP AI Core API
- Caches deployment URLs to minimize API calls
Request Interceptors (fetch-with-interceptors.ts)
- Custom fetch wrapper that chains request interceptors
- Injects Authorization headers with Bearer tokens
- Resolves
<deployment:modelId>URL placeholders to actual deployment URLs
- User calls
sapAiCore('sap-aicore/gpt-4o')to get a model instance - Model requests go through
fetchWithInterceptors - First interceptor adds OAuth Bearer token (fetched/cached by API client)
- Second interceptor resolves
<deployment:modelId>placeholder to actual deployment URL - Request is sent to SAP AI Core with proper authentication
AICORE_BASE_URL- SAP AI Core base URLAICORE_AUTH_URL- OAuth token endpointAICORE_CLIENT_ID- OAuth client IDAICORE_CLIENT_SECRET- OAuth client secretAICORE_RESOURCE_GROUP- Optional resource group (defaults to "default")
Use Conventional Commits with Gitmoji:
<type>(<scope?>): <gitmoji> <summary>
Types and their gitmoji:
feat: ✨ (new feature)refactor: ♻️ (code restructuring)fix: 🐛 (bug fix)docs: 📝 (documentation)test: ✅ (tests)chore: 🔧 (maintenance/tooling)
Always run pnpm run ci:check before committing.
- Node.js >=24 required (see
.node-version) - Uses pnpm workspaces for monorepo management
- Dual CJS/ESM output via tsup
- Uses
@ai-sdk/openai-compatiblefor OpenAI protocol compatibility - Azure OpenAI API version:
2025-04-01-preview