SAP AI SDK Base Client
raw JSON → 3.4.0 verified Mon Apr 27 auth: no python
Core base client for SAP Cloud SDK for AI (Python), providing authentication, HTTP client, and configuration for interacting with SAP AI Core services. Current version 3.4.0, requires Python >=3.9. Released irregularly with semantic versioning.
pip install sap-ai-sdk-base Common errors
error ModuleNotFoundError: No module named 'sap_ai_sdk' ↓
cause Package installed as sap-ai-sdk-base but import uses sap_ai_sdk.base. The package name in PyPI is 'sap-ai-sdk-base' but the import package is 'sap_ai_sdk'.
fix
Ensure you installed 'sap-ai-sdk-base' (not 'sap-ai-sdk') and the import is 'from sap_ai_sdk.base import BaseClient'.
error TypeError: Client.__init__() got an unexpected keyword argument 'auth_url' ↓
cause Using older constructor arguments from v2.x. In v3.x, AICoreDestination expects 'auth_url' not 'url'.
fix
Use AICoreDestination with correct parameters: base_url, client_id, client_secret, auth_url, resource_group.
error AttributeError: module 'sap_ai_sdk' has no attribute 'base' ↓
cause Trying to import from 'sap_ai_sdk.base' but the package 'sap_ai_sdk' was not installed because you installed 'sap-ai-sdk' instead of 'sap-ai-sdk-base'.
fix
Uninstall 'sap-ai-sdk' and install 'sap-ai-sdk-base'. Then import 'from sap_ai_sdk.base import BaseClient'.
Warnings
breaking v3.x removed the sync HTTP client; only async HTTPX client is used. All calls are async even if not documented. ↓
fix Use async/await for all calls. Replace requests-based code with BaseClient.get/post/etc (async).
breaking v3.x renamed 'BaseDestination' to 'AICoreDestination' and changed its constructor parameters. ↓
fix Use AICoreDestination with new keyword arguments: base_url, client_id, client_secret, auth_url, resource_group.
deprecated Passing 'destination' as a string is deprecated in v3.3+; use AICoreDestination object. ↓
fix Instantiate AICoreDestination and pass it as destination parameter.
gotcha Environment variable 'AICORE_RESOURCE_GROUP' defaults to 'default'; if omitted, service may fail when resource group is required. ↓
fix Explicitly set AICORE_RESOURCE_GROUP unless your AI Core instance uses the 'default' group.
Imports
- BaseClient wrong
from sap_ai_sdk import BaseClientcorrectfrom sap_ai_sdk.base import BaseClient - AICoreDestination wrong
from sap_ai_sdk.destination import AICoreDestinationcorrectfrom sap_ai_sdk.base import AICoreDestination
Quickstart
from sap_ai_sdk.base import BaseClient, AICoreDestination
import os
dest = AICoreDestination(
base_url=os.environ.get('AICORE_BASE_URL', ''),
client_id=os.environ.get('AICORE_CLIENT_ID', ''),
client_secret=os.environ.get('AICORE_CLIENT_SECRET', ''),
auth_url=os.environ.get('AICORE_AUTH_URL', ''),
resource_group=os.environ.get('AICORE_RESOURCE_GROUP', 'default')
)
client = BaseClient(destination=dest)
print(client.base_url)