SAP AI SDK Core
raw JSON → 3.3.0 verified Mon Apr 27 auth: no python
Core library for the SAP Cloud SDK for AI (Python), providing client and base classes for interacting with SAP AI Core services. Current version: 3.3.0, requires Python >=3.9. Released approximately quarterly.
pip install sap-ai-sdk-core Common errors
error ModuleNotFoundError: No module named 'sap_ai_sdk_core' ↓
cause Using wrong import path (e.g., 'sap.ai.sdk.core') or not having the package installed.
fix
Install: pip install sap-ai-sdk-core; then import: from sap_ai_sdk_core import AICoreClient
error TypeError: __init__() missing 1 required positional argument: 'base_url' ↓
cause Using old initialization pattern from version 2.x without providing required `base_url`.
fix
Add base_url parameter: AICoreClient(base_url='https://...', auth_url=..., ...)
error sap_ai_sdk_core.exceptions.AIClientError: (403) Forbidden ↓
cause Missing or invalid resource group; the default 'default' may not exist.
fix
Set the resource_group parameter to an existing resource group (e.g., from environment variable AICORE_RESOURCE_GROUP).
Warnings
breaking In version 2.x, the client was instantiated directly with credentials. In 3.x, the constructor parameters changed: `base_url` is now required instead of `ai_core_url`. ↓
fix Update instantiation: pass `base_url` (required) and remove old `ai_core_url`.
deprecated The `AICoreClient` constructor parameter `api_version` with `AIAPIVersion.V3` is deprecated and will be removed in a future release. ↓
fix Use `AIAPIVersion.V4` as the default API version.
gotcha The `resource_group` parameter defaults to `"default"` which may not be valid for all SAP AI Core instances. Not providing a valid resource group leads to 403 errors. ↓
fix Always set `resource_group` to an existing resource group from your AI Core instance (e.g., `os.environ.get("AICORE_RESOURCE_GROUP", "default")`).
Imports
- AICoreClient wrong
from sap.ai.sdk.core import AICoreClientcorrectfrom sap_ai_sdk_core import AICoreClient - AIAPIVersion
from sap_ai_sdk_core import AIAPIVersion
Quickstart
import os
from sap_ai_sdk_core import AICoreClient, AIAPIVersion
client = AICoreClient(
base_url=os.environ.get("AI_CORE_BASE_URL", ""),
auth_url=os.environ.get("AI_CORE_AUTH_URL", ""),
client_id=os.environ.get("AI_CORE_CLIENT_ID", ""),
client_secret=os.environ.get("AI_CORE_CLIENT_SECRET", ""),
resource_group=os.environ.get("AI_CORE_RESOURCE_GROUP", "default"),
api_version=AIAPIVersion.V4
)
print("Client created")