Troubleshooting
Common Errors and Solutions
Authentication Errors
ValidationError: No credentials found in any source
Cause: The SDK cannot find AI Core credentials in any of the four resolution sources (keyword arguments, environment variables, config file, VCAP_SERVICES).
Solution:
- Verify environment variables are set:
AICORE_CLIENT_ID,AICORE_CLIENT_SECRET,AICORE_AUTH_URL,AICORE_BASE_URL - Check for typos in variable names (all prefixed with
AICORE_, notAI_CORE_) - If using a config file, verify the path:
echo $AICORE_CONFIGor check~/.aicore/config.json - On Cloud Foundry, verify the service is bound:
cf env <APP_NAME> | grep AICORE
# Quick verification
env | grep AICORE401 Unauthorized or 403 Forbidden
Cause: Expired or invalid credentials.
Solution:
- Regenerate the service key in SAP BTP cockpit
- Verify the
AICORE_AUTH_URLincludes/oauth/tokenas the token endpoint - Check that the service instance is on the correct plan (Extended plan required for GenAI Hub)
AICORE_RESOURCE_GROUP not set (warning)
Cause: No resource group specified.
Solution: Set AICORE_RESOURCE_GROUP or pass resource_group to the client constructor.
Model and Deployment Errors
No deployment found with: deployment.model_name == 'gpt-4o-mini'
Cause: No model deployment matching the requested model name exists in the specified resource group.
Solution:
- Check available deployments in SAP AI Launchpad under your resource group
- Verify the model name matches exactly (including provider prefix for some models)
- Try deploying the model if it's not already deployed
- Use
deployment_iddirectly if you know it:
from gen_ai_hub.proxy.native.openai import chat
response = chat.completions.create(
deployment_id="dcef02e219ae4916",
messages=[{"role": "user", "content": "Hello!"}]
)Model not found or 404 Not Found
Cause: The model is not available in your AI Core region or plan.
Solution:
- Check SAP's model catalog for regional availability
- Verify your AI Core service plan supports the model
- Some models require specific resource group configurations
Package and Import Errors
ModuleNotFoundError: No module named 'gen_ai_hub'
Cause: The SDK is not installed, or the wrong package was installed.
Solution:
pip uninstall generative-ai-hub-sdk # Remove deprecated package if present
pip install "sap-ai-sdk-gen[all]"ImportError from generative_ai_hub_sdk
Cause: Code was written for the deprecated generative-ai-hub-sdk package.
Solution: The import name is gen_ai_hub for both old and new packages.
Update your import statements:
# Old (may work with deprecated package, but should be updated)
import gen_ai_hub # This import path is correct for both packages
# Ensure you have the new package installed
# pip install sap-ai-sdk-genOrchestration Errors
Orchestration deployment not found
Cause: No orchestration deployment exists in the specified resource group.
Solution:
- Deploy orchestration in your AI Core resource group (default resource group typically has this)
- Specify a
deployment_idwhen creatingOrchestrationService:
service = OrchestrationService(deployment_id="your-orchestration-deployment-id")Content filter violation
Cause: Input or output was blocked by the configured content safety filter.
Solution:
- Review the filter thresholds (e.g.,
AzureThreshold.ALLOW_SAFEis the strictest useful setting) - Relax thresholds if appropriate:
AzureThreshold.ALLOW_SAFE_LOW_MEDIUMallows more content - Modify the input to avoid triggering the filter
- Check
response.intermediate_failuresfor details on which filter blocked the request
Token limit exceeded
Cause: The response exceeds the model's maximum token limit.
Solution:
- Set
max_tokensin the model parameters:
LLMModelDetails(name="gpt-4o-mini", params={"max_tokens": 500})- Use a model with a larger context window
- Reduce the prompt length
Network and Timeout Errors
ConnectionError or timeout
Cause: Network connectivity issues between your environment and AI Core.
Solution:
- Verify
AICORE_BASE_URLis correct and accessible - Check firewall/proxy settings in your network
- Increase timeout:
service = OrchestrationService(config=config, timeout=120)- For BTP environments, ensure the AI Core service instance is in the same region
LangChain-Specific Errors
init_llm fails for a new model
Cause: The model is not yet in init_llm's auto-detection catalog.
Solution: Pass an explicit init_func:
from gen_ai_hub.proxy.langchain import init_llm
from gen_ai_hub.proxy.langchain.amazon import init_chat_converse_model
llm = init_llm(
"anthropic--claude-new",
model_id="anthropic.claude-new-v1:0",
init_func=init_chat_converse_model
)Bedrock model requires model_id
Cause: Amazon Bedrock models need both a model name and a Bedrock model ID.
Solution: Always provide model_id for Bedrock models:
llm = init_llm("anthropic--claude-4-sonnet", model_id="anthropic.claude-sonnet-4-20250514-v1:0")Migration from generative-ai-hub-sdk
Package Rename
| Old | New |
|---|---|
pip install generative-ai-hub-sdk |
pip install sap-ai-sdk-gen |
pip install "generative-ai-hub-sdk[all]" |
pip install "sap-ai-sdk-gen[all]" |
PyPI: generative-ai-hub-sdk |
PyPI: sap-ai-sdk-gen |
Import Paths
The import name gen_ai_hub is unchanged. All import paths remain compatible:
# These imports work with both old and new packages
from gen_ai_hub.proxy.native.openai import chat
from gen_ai_hub.proxy.langchain import init_llm
from gen_ai_hub.orchestration_v2 import OrchestrationServiceVersion Differences
The generative-ai-hub-sdk stopped at v4.12.4. The sap-ai-sdk-gen starts at v5.0.0
and is currently at v6.10.0. Key additions since the rename include:
- Responses API support (
gen_ai_hub.proxy.native.openai.responses) - SAP RPT-1 client (
gen_ai_hub.proxy.native.sap.RPTClient) - Orchestration v2 with enhanced configuration model
- Prompt Registry integration for orchestration config references
- Evaluations module (
gen_ai_hub.evaluations) - Google GenAI native client (using
google-genaiSDK) - Structured outputs (
.parse()methods,response_formatin orchestration)
Migration Steps
Update
requirements.txtorpyproject.toml:# Before generative-ai-hub-sdk[all]>=4.0 # After sap-ai-sdk-gen[all]>=6.0Install the new package:
pip uninstall generative-ai-hub-sdk pip install "sap-ai-sdk-gen[all]"Test existing code — import paths under
gen_ai_hubare compatible.Update any direct references to the package name in CI/CD configs or Dockerfiles.
Check for deprecated model names (e.g.,
gpt-35-turbo→gpt-4o-mini).
Version Compatibility
| sap-ai-sdk-gen | Python | ai-core-sdk | Key Feature |
|---|---|---|---|
| 6.10.0 | 3.9+ | Bundled | Responses API, RPT-1, Orchestration v2 |
| 6.x | 3.9+ | Bundled | Google GenAI native client |
| 5.x | 3.8+ | Bundled | Initial rename from generative-ai-hub-sdk |
The ai-core-sdk (AICoreV2Client) is included as a dependency of sap-ai-sdk-gen.
Resources
- PyPI: https://pypi.org/project/sap-ai-sdk-gen/
- SDK Reference: https://help.sap.com/doc/generative-ai-hub-sdk/CLOUD/en-US/_reference/gen_ai_hub.html
- Deprecated Package: https://pypi.org/project/generative-ai-hub-sdk/
- SAP Community: https://community.sap.com/