SAP AI Core SDK
raw JSON → 2.6.2 verified Fri May 01 auth: no python deprecated
[DEPRECATED] Official SAP AI Core SDK for Python (version 2.6.2, requires Python >=3.9). This library provides programmatic access to SAP AI Core services for training, deployment, and inference. It is in maintenance mode and has been superseded by the AI SDK (ai-sdk). Users are advised to migrate away.
pip install ai-core-sdk Common errors
error ModuleNotFoundError: No module named 'ai_core_sdk' ↓
cause Package not installed or installed in wrong environment.
fix
Run 'pip install ai-core-sdk' in the correct Python environment.
error AttributeError: module 'ai_core_sdk' has no attribute 'AIAPIClient' ↓
cause Direct import from top-level module, which does not export the class.
fix
Use 'from ai_core_sdk.ai_core_v2_client import AIAPIClient'.
error ai_core_sdk.resources.clients.credential_handler.AuthenticationError: Authentication failed ↓
cause Missing or incorrect auth_url or api_key.
fix
Ensure AICORE_AUTH_URL and AICORE_API_KEY environment variables are set correctly.
Warnings
breaking Library is deprecated. New features and bug fixes occur only for critical security issues. Migrate to the new AI SDK (ai-sdk). ↓
fix Replace with 'ai-sdk' (pip install ai-sdk) and update import paths.
deprecated The module path changed in v2.0.0. Using 'from ai_core_sdk import AIAPIClient' fails. ↓
fix Import from ai_core_sdk.ai_core_v2_client instead.
gotcha Authentication requires both base_url and auth_url. Many examples online omit auth_url, causing 401 errors. ↓
fix Always pass auth_url when using API key authentication.
Imports
- AIAPIClient wrong
from ai_core_sdk import AIAPIClientcorrectfrom ai_core_sdk.ai_core_v2_client import AIAPIClient - AICoreV2Client
from ai_core_sdk.ai_core_v2_client import AICoreV2Client
Quickstart
import os
from ai_core_sdk.ai_core_v2_client import AIAPIClient
# Use environment variables for authentication
api_key = os.environ.get('AICORE_API_KEY', '')
auth_url = os.environ.get('AICORE_AUTH_URL', '')
base_url = os.environ.get('AICORE_BASE_URL', '')
client = AIAPIClient(
base_url=base_url,
auth_url=auth_url,
api_key=api_key
)
# List scenarios
print(client.scenario.query())