Sap Cloud Sdk Ai Python logo

Sap Cloud Sdk Ai Python

Community
secondsky
sap-cloud-sdk-ai-python

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.

Overview

Publishersecondsky
Repositorysap-skills
Skill namesap-cloud-sdk-ai-python
Stars
445
Forks
117
Bundled files
6
LicenseGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 6 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by secondsky on GitHub. Read the source before you install it.

Installation

Install the Sap Cloud Sdk Ai Python AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/secondsky/sap-skills.git /tmp/sap-skills
mkdir -p .claude/skills
cp -r /tmp/sap-skills/plugins/sap-cloud-sdk-ai-python/skills/sap-cloud-sdk-ai-python .claude/skills/sap-cloud-sdk-ai-python
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sap Cloud Sdk Ai Python in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sap Cloud Sdk Ai Python on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sap Cloud Sdk Ai Python is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SAP Cloud SDK for AI (Python)

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.

Related Skills

  • sap-ai-core: Platform setup, deployments, resource groups, and model management in SAP AI Core
  • sap-cloud-sdk-ai: JavaScript/TypeScript and Java equivalents of this SDK
  • sap-hana-ml: HANA-side machine learning in Python
  • sap-dependency-security: Pip dependency hygiene and upgrade patterns

Related external skills

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.

When to Use This Skill

Use this skill when:

  • Building Python applications that call LLMs through SAP AI Core / Generative AI Hub
  • Using the gen_ai_hub Python package (installed as sap-ai-sdk-gen)
  • Integrating OpenAI, Amazon Bedrock, or Google GenAI models via SAP's proxy
  • Implementing LangChain chains with SAP AI Core as the backend
  • Using the Orchestration Service from Python (templating, filtering, masking, grounding)
  • Migrating code from the deprecated generative-ai-hub-sdk to sap-ai-sdk-gen
  • Generating embeddings through SAP AI Core
  • Working with SAP RPT-1 (Relational Pretrained Transformer) for tabular predictions

Table of Contents

Quick Start

Native OpenAI Chat Completion

python
from 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)

Orchestration Service

python
from 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)

Installation

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]"

Authentication

The SDK reads credentials via AICoreV2Client.from_env(), which resolves credentials in this order:

  1. Keyword arguments passed to GenAIHubProxyClient(...)
  2. Environment variablesAICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_AUTH_URL, AICORE_BASE_URL, AICORE_RESOURCE_GROUP
  3. Config file$AICORE_HOME/config.json (or path set by AICORE_CONFIG); use AICORE_PROFILE to select a named profile
  4. VCAP_SERVICES — automatic on Cloud Foundry/Kyma when the AI Core service is bound

Local Development (Environment Variables)

bash
export 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"

Config File Profile

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.

Available Modules

ModuleImport PathPurpose
Proxy (native clients)gen_ai_hub.proxy.native.*Direct model access per provider
LangChain integrationgen_ai_hub.proxy.langchaininit_llm, init_embedding_model, ChatOpenAI, etc.
Orchestrationgen_ai_hub.orchestration_v2Templating, filtering, masking, grounding
Document Groundinggen_ai_hub.document_groundingPipeline, Vector, Retrieval APIs
Prompt Registrygen_ai_hub.prompt_registryTemplate management and config storage
Evaluationsgen_ai_hub.evaluationsModel evaluation runs and metrics
SAP RPT-1gen_ai_hub.proxy.native.sapTabular prediction (classification, regression)

Native Clients by Provider

ProviderImportKey Classes
OpenAIgen_ai_hub.proxy.native.openaiOpenAI, completions, chat, embeddings, responses
Amazon Bedrockgen_ai_hub.proxy.native.amazonSession, ClientWrapper
Google GenAIgen_ai_hub.proxy.native.google_genaiClient
SAP RPT-1gen_ai_hub.proxy.native.sapRPTClient, RPTRequest

Supported Models

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:

ProviderExample Families
OpenAIGPT-family chat, multimodal, reasoning, and embedding models
Anthropic (via Bedrock)Claude-family models
AmazonNova/Titan-family models
GoogleGemini-family models
MistralMistral-family models
SAPRPT-family tabular prediction models where enabled

Core Features

Chat Completion with OpenAI Client

python
from 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)

Streaming

python
from 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="")

Embeddings

python
from 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)

LangChain Integration

python
from 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")

Content Filtering (via Orchestration)

python
from 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."})

Data Masking (via Orchestration)

python
from 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."})

Document Grounding (via Orchestration)

python
from 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?"})

Common Errors

ErrorCauseSolution
No credentials found in any sourceMissing AI Core service key/env varsSet all AICORE_* environment variables or create a config file profile
No deployment foundModel not deployed in AI CoreDeploy the model in your resource group, or use deployment_id directly
AICORE_RESOURCE_GROUP not setMissing resource groupSet AICORE_RESOURCE_GROUP env var or pass resource_group to the client
ModuleNotFoundError: No module named 'gen_ai_hub'Wrong package installedInstall sap-ai-sdk-gen (not generative-ai-hub-sdk)
Import from generative_ai_hub_sdk failsUsing deprecated package nameThe package was renamed; import from gen_ai_hub (installed via sap-ai-sdk-gen)
ValidationError on proxy client initIncomplete credentialsVerify all four required env vars: AICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_AUTH_URL, AICORE_BASE_URL

Bundled Resources

Reference Documentation

  1. references/getting-started-auth.md - Installation, authentication, and config setup
  2. references/native-clients-guide.md - Native client usage for OpenAI, Amazon, Google, and SAP RPT-1
  3. references/orchestration-guide.md - Orchestration service: templating, filtering, masking, grounding, embeddings
  4. references/langchain-guide.md - LangChain integration: LLM/embedding init, chains, structured outputs
  5. references/troubleshooting.md - Common errors, version compatibility, migration from generative-ai-hub-sdk

Documentation Sources

Keep this skill updated using these sources:

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Sap Cloud Sdk Ai Python AI skill do?

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.

Why use Sap Cloud Sdk Ai Python on TypingMind?

Because you install it once and use it with any model. Sap Cloud Sdk Ai Python is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sap Cloud Sdk Ai Python in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/secondsky/sap-skills/tree/main/plugins/sap-cloud-sdk-ai-python/skills/sap-cloud-sdk-ai-python. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Sap Cloud Sdk Ai Python?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sap Cloud Sdk Ai Python?

As many as you like. As long as a model supports skills, you can use Sap Cloud Sdk Ai Python with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sap Cloud Sdk Ai Python AI skill free?

Yes. It is published on GitHub by secondsky under the GPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇