Skip to content

apoorvaeerly/SAP_BTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAP BTP & Eerly AI Studio Integration

This project facilitates the technical integration between Eerly AI Studio and SAP BTP, specifically focusing on leveraging unused Generative AI tokens (Capacity Units) from an existing SAP subscription.

📖 Background & Objective

The Problem

Many organizations have SAP BTP subscriptions that include Generative AI token allocations (Capacity Units). Often, these tokens go unused because they are not fully consumed by the existing SAP-native workflows.

The Solution

Eerly AI Studio acts as an external AI platform that can tap into this "remaining capacity." By connecting Eerly AI to SAP AI Core and BTP Usage APIs, we can:

  1. Run Inferences: Use the client's already-paid-for LLMs via SAP AI Core.
  2. Monitor Consumption: Fetch real-time and monthly usage data to compute "Unused Tokens."
  3. Optimize Spend: Ensure no BTP credits go to waste by prioritizing consumption of existing SAP capacity.

🚀 Technical Milestones Achieved

We have successfully implemented and validated the OAuth 2.0 Client Credentials authentication pattern required for SAP BTP services and successfully passed all API connectivity checks on a Pay-As-You-Go (PAYG) account.

Validated Components:

  • SAP AI Core (Base): Successfully authenticated and retrieved resource groups.
  • Generative AI Hub: Successfully retrieved Foundation Model scenarios (foundation-models, orchestration, etc.) proving LLM API access.
  • SAP Service Manager: Successfully authenticated and retrieved service offerings (Trial/PAYG).
  • SAP Usage Data Management: Successfully authenticated to the Billing API.

🗺️ End-to-End PAYG Account Setup

To enable the full integration with Generative AI Hub, you must use a Pay-As-You-Go (PAYG) or enterprise account. Trial accounts do not support the required extended plan.

(Note: If you have previously created failed instances, it is highly recommended to create a fresh Subaccount to avoid SAP BTP's Service Broker cache bugs).

1. BTP Commercial & Subaccount Setup

  1. Enable the Pay-As-You-Go (PAYG) or CPEA model for your Global Account.
  2. Create a new Subaccount (e.g., Eerly-AI-SAP-AI-Core) in an AWS region that supports GenAI Hub (e.g., us10 or eu10).

2. Service Entitlements

Go to Global Account → Entitlements → Subaccount Assignments and assign the following to your new subaccount:

  • SAP AI Core: Give it the extended plan (mandatory for Generative AI Hub).
  • SAP AI Launchpad: Give it the standard plan.

3. Create Subscriptions and Instances

Inside your new Subaccount, go to Services → Instances and Subscriptions:

  1. Click Create and subscribe to SAP AI Launchpad (standard plan).
  2. Click Create and instantiate SAP AI Core (must be the extended plan!).

4. Create the Service Key

  1. Click on the name of your new extended AI Core instance.
  2. Go to the Service Keys tab.
  3. Click Create to generate a key (e.g., eerly-payg-key).
  4. Click View Credentials and copy the entire JSON object.

5. Access & Permissions (Required for UI Access)

To use the SAP AI Launchpad web interface, assign these Role Collections to your user in the Subaccount (Security → Users):

  • AI Core Administrator
  • AI Core Developer
  • Generative AI Hub User

🛠️ Local Setup & Replication

Follow these steps to replicate the successful ping tests locally to prove API connectivity.

Prerequisites

  • Python 3.x
  • Dependencies:
    pip install requests python-dotenv

Configuration (.env)

Create a .env file in the project root containing your Service Keys.

# ── SAP AI Core (PAYG) Credentials ──────────────────────────────────────────
AI_CORE_CLIENT_ID=your_aicore_clientid
AI_CORE_CLIENT_SECRET=your_aicore_clientsecret
AI_CORE_AUTH_URL=https://<tenant>.authentication.<region>.hana.ondemand.com/oauth/token
AI_CORE_API_URL=https://api.ai.prod.us-east-1.aws.ml.hana.ondemand.com
AI_CORE_RESOURCE_GROUP=default

# ── Service Manager Credentials (Optional) ──────────────────────────────────
BTP_CLIENT_ID=your_sm_clientid
BTP_CLIENT_SECRET=your_sm_clientsecret
BTP_AUTH_URL=https://<tenant>.authentication.../oauth/token
BTP_API_BASE_URL=https://service-manager.cfapps...

# ── Usage Data Management Credentials (Optional) ────────────────────────────
USAGE_CLIENT_ID=your_uas_clientid
USAGE_CLIENT_SECRET=your_uas_clientsecret
USAGE_AUTH_URL=https://<tenant>-ga.authentication.../oauth/token
USAGE_API_BASE_URL=https://uas-reporting.cfapps...

Running the Ping Tests

Primary Test: SAP AI Core & Generative AI Hub This checks if the AI models are truly accessible.

# Run with UTF-8 flag to support emojis in Windows Terminal
python -X utf8 ping_test_payg.py

Secondary Test: Service Manager & Usage Billing

python ping_test.py

⏭️ Next Product Steps

With API connectivity 100% proven, the actual product engineering inside Eerly AI Studio can begin:

  1. Usage Math Execution: Implement the API logic to calculate Purchased CUs - Consumed CUs = Remaining Tokens.
  2. LLM Router Integration: Send LLM inference requests from Eerly AI directly to the SAP AI Core foundation-models scenario via the /v2/inference/deployments endpoint.

About

this repository contains ping tests for SAP BTP connection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages