Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Integrates the SAP Cloud SDK for AI for Python (sap-ai-sdk-gen, formerly generative-ai-hub-sdk) into Python applications. Use when building Python apps with SAP AI Core, Generative AI Hub, or the Orchestration Service: chat completion, embeddings, streaming, LangChain integration, templating, content filtering, data masking, and document grounding. Supports OpenAI GPT models, Llama, Gemini, Amazon Nova, and other foundation models via SAP BTP.
.claude/skills/secondsky-sap-cloud-sdk-ai-python/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-11 | ✗→✓ | ▲ Improved | 205% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 228% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 125% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 337% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 56% | 0% |
> Package rename: The PyPI package generative-ai-hub-sdk is deprecated (v4.12.4 is the last release). > Its successor is sap-ai-sdk-gen (currently v6.10.0 per public PyPI registry evidence from 2026-06-15). Code and tutorials referencing > generative-ai-hub-sdk should migrate to sap-ai-sdk-gen; the import name remains gen_ai_hub.
The official Python SDK for SAP Generative AI Hub and Orchestration Service. It wraps the native SDKs of model providers (OpenAI, Amazon Bedrock, Google GenAI) and offers a harmonised LangChain integration and a full Orchestration client — all routed through SAP AI Core with unified authentication. Package freshness is registry-verified; AI Core runtime behavior and exact model availability still require target-tenant validation.
If your task involves working inside Databricks (notebooks, Unity Catalog, Spark, SAP Databricks in SAP Business Data Cloud), consider installing the Databricks agent skills plugin. Ask whether you would like help installing it — never install unprompted.
Use this skill when:
gen_ai_hub Python package (installed as sap-ai-sdk-gen)generative-ai-hub-sdk to sap-ai-sdk-genpythonfrom gen_ai_hub.proxy.native.openai import chat messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is SAP BTP?"} ] response = chat.completions.create( model_name="gpt-4o-mini", messages=messages ) print(response.choices[0].message.content)
pythonfrom gen_ai_hub.orchestration_v2 import ( OrchestrationConfig, OrchestrationService, ModuleConfig, PromptTemplatingModuleConfig, Template, UserMessage, LLMModelDetails ) config = OrchestrationConfig( modules=ModuleConfig( prompt_templating=PromptTemplatingModuleConfig( prompt=Template( template=[UserMessage(role="user", content="{{?question}}")] ), model=LLMModelDetails(name="gpt-4o-mini") ) ) ) service = OrchestrationService(config=config) response = service.run(placeholder_values={"question": "What is SAP?"}) print(response.final_result.choices[0].message.content)
bash# All providers + LangChain support pip install "sap-ai-sdk-gen[all]" # Default (OpenAI only, no LangChain) pip install sap-ai-sdk-gen # Specific providers (without LangChain) pip install "sap-ai-sdk-gen[google, amazon]"
The SDK reads credentials via AICoreV2Client.from_env(), which resolves credentials in this order:
GenAIHubProxyClient(...)AICORE_CLIENT_ID, AICORE_CLIENT_SECRET,AICORE_AUTH_URL, AICORE_BASE_URL, AICORE_RESOURCE_GROUP
$AICORE_HOME/config.json (or path set by AICORE_CONFIG);use AICORE_PROFILE to select a named profile
bashexport AICORE_CLIENT_ID="sb-..." export AICORE_CLIENT_SECRET="..." export AICORE_AUTH_URL="https://<tenant>.authentication.sap.hana.ondemand.com/oauth/token" export AICORE_BASE_URL="https://api.ai.prod.eu-central-1.aws.ml.hana.ondemand.com/v2" export AICORE_RESOURCE_GROUP="default"
bash# ~/.aicore/config.json { "AICORE_CLIENT_ID": "sb-...", "AICORE_CLIENT_SECRET": "...", "AICORE_AUTH_URL": "https://<tenant>.authentication.sap.hana.ondemand.com/oauth/token", "AICORE_BASE_URL": "https://api.ai.prod.eu-central-1.aws.ml.hana.ondemand.com/v2", "AICORE_RESOURCE_GROUP": "default" }
For detailed auth setup and troubleshooting, see references/getting-started-auth.md.
| Module | Import Path | Purpose | |--------|-------------|---------| | Proxy (native clients) | gen_ai_hub.proxy.native.* | Direct model access per provider | | LangChain integration | gen_ai_hub.proxy.langchain | init_llm, init_embedding_model, ChatOpenAI, etc. | | Orchestration | gen_ai_hub.orchestration_v2 | Templating, filtering, masking, grounding | | Document Grounding | gen_ai_hub.document_grounding | Pipeline, Vector, Retrieval APIs | | Prompt Registry | gen_ai_hub.prompt_registry | Template management and config storage | | Evaluations | gen_ai_hub.evaluations | Model evaluation runs and metrics | | SAP RPT-1 | gen_ai_hub.proxy.native.sap | Tabular prediction (classification, regression) |
| Provider | Import | Key Classes | |----------|--------|-------------| | OpenAI | gen_ai_hub.proxy.native.openai | OpenAI, completions, chat, embeddings, responses | | Amazon Bedrock | gen_ai_hub.proxy.native.amazon | Session, ClientWrapper | | Google GenAI | gen_ai_hub.proxy.native.google_genai | Client | | SAP RPT-1 | gen_ai_hub.proxy.native.sap | RPTClient, RPTRequest |
The Generative AI Hub catalog includes models from multiple providers. Check SAP's model catalog and the target tenant catalog for the authoritative model IDs. Example families:
| Provider | Example Families | |----------|------------------| | OpenAI | GPT-family chat, multimodal, reasoning, and embedding models | | Anthropic (via Bedrock) | Claude-family models | | Amazon | Nova/Titan-family models | | Google | Gemini-family models | | Mistral | Mistral-family models | | SAP | RPT-family tabular prediction models where enabled |
pythonfrom gen_ai_hub.proxy.native.openai import OpenAI client = OpenAI() response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Explain CAP in one paragraph."}] ) print(response.choices[0].message.content)
pythonfrom gen_ai_hub.proxy.native.openai import OpenAI client = OpenAI() stream = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Explain SAP CAP."}], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")
pythonfrom gen_ai_hub.proxy.native.openai import embeddings response = embeddings.create( input="Every decoding is another encoding.", model_name="text-embedding-3-small" ) print(response.data[0].embedding)
pythonfrom gen_ai_hub.proxy.langchain import init_llm, init_embedding_model llm = init_llm("gpt-4o-mini", max_tokens=300) result = llm.invoke("What is SAP BTP?") print(result.content) embeddings = init_embedding_model("text-embedding-3-small") vector = embeddings.embed_query("SAP Business Technology Platform")
pythonfrom gen_ai_hub.orchestration_v2 import ( OrchestrationConfig, OrchestrationService, ModuleConfig, PromptTemplatingModuleConfig, Template, UserMessage, LLMModelDetails, FilteringModuleConfig, InputFiltering, OutputFiltering, AzureContentSafetyInput, AzureContentSafetyOutput, AzureThreshold ) config = OrchestrationConfig( modules=ModuleConfig( prompt_templating=PromptTemplatingModuleConfig( prompt=Template(template=[UserMessage(role="user", content="{{?question}}")]), model=LLMModelDetails(name="gpt-4o-mini") ), filtering=FilteringModuleConfig( input=InputFiltering(filters=[ AzureContentSafetyInput(hate=AzureThreshold.ALLOW_SAFE, violence=AzureThreshold.ALLOW_SAFE) ]), output=OutputFiltering(filters=[ AzureContentSafetyOutput(hate=AzureThreshold.ALLOW_SAFE, violence=AzureThreshold.ALLOW_SAFE) ]) ) ) ) service = OrchestrationService(config=config) response = service.run(placeholder_values={"question": "Explain SAP."})
pythonfrom gen_ai_hub.orchestration_v2 import ( OrchestrationConfig, OrchestrationService, ModuleConfig, PromptTemplatingModuleConfig, Template, UserMessage, LLMModelDetails, MaskingModuleConfig, MaskingProviderConfig, DPIStandardEntity, MaskingMethod, DataMaskingProviderName ) config = OrchestrationConfig( modules=ModuleConfig( prompt_templating=PromptTemplatingModuleConfig( prompt=Template(template=[UserMessage(role="user", content="{{?text}}")]), model=LLMModelDetails(name="gpt-4o-mini") ), masking=MaskingModuleConfig( masking_providers=[ MaskingProviderConfig( type=DataMaskingProviderName.SAP_DATA_PRIVACY_INTEGRATION, method=MaskingMethod.ANONYMIZATION, entities=[ DPIStandardEntity(type="profile-email"), DPIStandardEntity(type="profile-person") ] ) ] ) ) ) service = OrchestrationService(config=config) response = service.run(placeholder_values={"text": "Contact john@example.com for details."})
pythonfrom gen_ai_hub.orchestration_v2 import ( OrchestrationConfig, OrchestrationService, ModuleConfig, PromptTemplatingModuleConfig, Template, UserMessage, LLMModelDetails, GroundingModuleConfig, DocumentGroundingConfig, DocumentGroundingFilter, DocumentGroundingPlaceholders, GroundingSearchConfig, DataRepositoryType, GroundingType ) config = OrchestrationConfig( modules=ModuleConfig( prompt_templating=PromptTemplatingModuleConfig( prompt=Template(template=[UserMessage(role="user", content="{{?question}}")]), model=LLMModelDetails(name="gpt-4o-mini") ), grounding=GroundingModuleConfig( type=GroundingType.DOCUMENT_GROUNDING_SERVICE, config=DocumentGroundingConfig( placeholders=DocumentGroundingPlaceholders( input=["{{?question}}"], output="{{?context}}" ), filters=[ DocumentGroundingFilter( id="my-vector-repo-id", data_repository_type=DataRepositoryType.VECTOR, search_config=GroundingSearchConfig(max_chunk_count=5) ) ] ) ) ) ) service = OrchestrationService(config=config) response = service.run(placeholder_values={"question": "What is the refund policy?"})
| Error | Cause | Solution | |-------|-------|----------| | No credentials found in any source | Missing AI Core service key/env vars | Set all AICORE_* environment variables or create a config file profile | | No deployment found | Model not deployed in AI Core | Deploy the model in your resource group, or use deployment_id directly | | AICORE_RESOURCE_GROUP not set | Missing resource group | Set AICORE_RESOURCE_GROUP env var or pass resource_group to the client | | ModuleNotFoundError: No module named 'gen_ai_hub' | Wrong package installed | Install sap-ai-sdk-gen (not generative-ai-hub-sdk) | | Import from generative_ai_hub_sdk fails | Using deprecated package name | The package was renamed; import from gen_ai_hub (installed via sap-ai-sdk-gen) | | ValidationError on proxy client init | Incomplete credentials | Verify all four required env vars: AICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_AUTH_URL, AICORE_BASE_URL |
references/getting-started-auth.md - Installation, authentication, and config setupreferences/native-clients-guide.md - Native client usage for OpenAI, Amazon, Google, and SAP RPT-1references/orchestration-guide.md - Orchestration service: templating, filtering, masking, grounding, embeddingsreferences/langchain-guide.md - LangChain integration: LLM/embedding init, chains, structured outputsreferences/troubleshooting.md - Common errors, version compatibility, migration from generative-ai-hub-sdkKeep this skill updated using these sources:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | pass→pass | 9,104 | 3,926 | -57% | 1 | 1 | 0% | 1,799 | 4,617 | +157% | 0 | 0 | — |
case-11 | fail→pass | 8,671 | 4,238 | -51% | 1 | 1 | 0% | 1,523 | 4,645 | +205% | 0 | 0 | — |
case-01 | pass→pass | 9,942 | 4,184 | -58% | 1 | 1 | 0% | 1,858 | 4,784 | +157% | 0 | 0 | — |
case-02 | fail→pass | 29,582 | 15,707 | -47% | 1 | 1 | 0% | 1,740 | 5,700 | +228% | 0 | 0 | — |
case-03 | fail→pass | 12,078 | 8,690 | -28% | 1 | 1 | 0% | 2,487 | 5,599 | +125% | 0 | 0 | — |
case-04 | fail→pass | 6,054 | 3,147 | -48% | 1 | 1 | 0% | 1,005 | 4,394 | +337% | 0 | 0 | — |
case-06 | fail→pass | 17,732 | 6,889 | -61% | 1 | 1 | 0% | 3,362 | 5,231 | +56% | 0 | 0 | — |
case-07 | fail→pass | 13,244 | 7,791 | -41% | 1 | 1 | 0% | 2,757 | 5,433 | +97% | 0 | 0 | — |
case-08 | pass→pass | 11,302 | 5,245 | -54% | 1 | 1 | 0% | 2,230 | 4,866 | +118% | 0 | 0 | — |
case-09 | fail→pass | 8,136 | 3,700 | -55% | 1 | 1 | 0% | 1,609 | 4,500 | +180% | 0 | 0 | — |
case-10 | fail→pass | 10,653 | 4,429 | -58% | 1 | 1 | 0% | 2,068 | 4,714 | +128% | 0 | 0 | — |
case-12 | fail→pass | 11,724 | 3,629 | -69% | 1 | 1 | 0% | 2,131 | 4,449 | +109% | 0 | 0 | — |
case-13 | pass→pass | 11,243 | 8,037 | -29% | 1 | 1 | 0% | 2,042 | 5,345 | +162% | 0 | 0 | — |
case-14 | fail→pass | 10,076 | 6,046 | -40% | 1 | 1 | 0% | 1,729 | 4,900 | +183% | 0 | 0 | — |
case-15 | fail→pass | 5,539 | 4,039 | -27% | 1 | 1 | 0% | 1,002 | 4,491 | +348% | 0 | 0 | — |
case-16 | fail→pass | 8,971 | 5,065 | -44% | 1 | 1 | 0% | 1,520 | 4,886 | +221% | 0 | 0 | — |
case-17 | fail→pass | 7,400 | 3,168 | -57% | 1 | 1 | 0% | 1,267 | 4,361 | +244% | 0 | 0 | — |
case-18 | fail→pass | 5,564 | 4,119 | -26% | 1 | 1 | 0% | 1,104 | 4,664 | +322% | 0 | 0 | — |
case-19 | fail→pass | 10,791 | 2,042 | -81% | 1 | 1 | 0% | 2,146 | 4,104 | +91% | 0 | 0 | — |
case-20 | pass→fail | 13,630 | 12,456 | -9% | 1 | 1 | 0% | 2,762 | 6,356 | +130% | 0 | 0 | — |
case-21 | pass→pass | 10,427 | 7,857 | -25% | 1 | 1 | 0% | 2,053 | 5,467 | +166% | 0 | 0 | — |
case-22 | pass→pass | 6,368 | 5,747 | -10% | 1 | 1 | 0% | 1,123 | 4,810 | +328% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +64 percentage points is the difference between those two pass rates over the 21 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.