Generative AI Hub SDK (Deprecated)

raw JSON →
4.12.4 verified Fri May 01 auth: no python deprecated

DEPRECATED. The generative AI hub SDK provides a Python interface to interact with SAP AI Core's generative AI hub and foundation models. Version 4.12.4 final release. No longer maintained; superseded by the AI Core SDK.

pip install generative-ai-hub-sdk
error ModuleNotFoundError: No module named 'generative_ai_hub'
cause The package installs as 'gen_ai_hub' module, not 'generative_ai_hub'.
fix
Use correct import: 'from gen_ai_hub import gen_ai_hub'.
error ImportError: cannot import name 'AICoreClient' from 'gen_ai_hub'
cause AICoreClient is under gen_ai_hub.gen_ai_hub, not directly in gen_ai_hub.
fix
Use: 'from gen_ai_hub import gen_ai_hub; client = gen_ai_hub.AICoreClient(...)'
deprecated This library is deprecated. SAP officially recommends migrating to the AI Core SDK (ai-core-sdk). No new features or security patches will be released.
fix Uninstall generative-ai-hub-sdk and replace with ai-core-sdk. See migration guide at https://help.sap.com/docs/AI_CORE.
gotcha The correct import module is 'gen_ai_hub', not 'generative_ai_hub' or 'gen_ai_hub_sdk'. Many users mistakenly use the PyPI package name.
fix Use 'from gen_ai_hub import gen_ai_hub' or 'from gen_ai_hub.models import ...'.
breaking Breaking change in v4.0.0: The 'ai_core' module was renamed to 'gen_ai_hub'. Old code using 'from generative_ai_hub import ai_core' will break.
fix Change imports to 'from gen_ai_hub import gen_ai_hub'.

Initialize the AI Core client and fetch first deployment.

from gen_ai_hub import gen_ai_hub
# Replace with your actual AI Core service key values or environment variables
ai_core_client = gen_ai_hub.AICoreClient(
    base_url=os.environ.get('AICORE_BASE_URL', ''),
    auth_url=os.environ.get('AICORE_AUTH_URL', ''),
    client_id=os.environ.get('AICORE_CLIENT_ID', ''),
    client_secret=os.environ.get('AICORE_CLIENT_SECRET', '')
)
print(ai_core_client.get_deployments()[:1])