analytics-cloud-rpt15-prediction-demo
A FastAPI backend that triggers SAP-RPT-1.5 payment-delay predictions from an SAP Analytics CloudSAP Analytics CloudSAP's SaaS front end for analytics: business intelligence, planning and predictive in one product, and the place a Datasphere analytic model is meant to end up being read.sap official, btp Multi Action and writes the results back to HANA.
Calling a predictive model from SAP Analytics CloudSAP Analytics CloudSAP's SaaS front end for analytics: business intelligence, planning and predictive in one product, and the place a Datasphere analytic model is meant to end up being read.sap official, btp needs an intermediary that SAC's asynchronous External API step can poll, and this project is that intermediary: a FastAPI service on the Cloud Foundry runtimeSAP BTP, Cloud Foundry RuntimeThe Cloud Foundry runtime of SAP BTP: memory for applications in a Cloud Foundry org, run from SAP's Java, Node.js and Python buildpacks or community buildpacks and managed with the standard Cloud Foundry tools.sap official, btp that reads every row of a V_PAYMENT_DELAY_PREDICTION view in SAP DatasphereSAP DatasphereSAP's cloud data warehouse: spaces, modelled views and analytic models over data brought in or federated from source systems, with the business context carried along rather than rebuilt.sap official, btp or SAP HANA CloudSAP HANA CloudThe managed database under most of this: CAP's default target, the store Datasphere and Analytics Cloud sit on, and a service with plans and components.sap official, btp, sends the rows whose Days_Late is null to an RPT-1.5 deployment on SAP AI CoreSAP AI CoreSAP's AI service on BTP: the runtime for AI assets, and through the Generative AI Hub inside it the access to foundation models, the orchestration service with its templating, masking, filtering and grounding modules, the Prompt Registry and Document Grounding.sap official, btp with the scored rows alongside them as context, and upserts the predicted value and confidence interval into a staging table for the SAC story to read. A Multi Action button starts the job and polls a second endpoint until it reports done. It answers one scenario, payment-delay prediction, and needs its own SAP AI Core, Datasphere or HANA Cloud and Cloud Foundry setup already in place.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerjonas-200Contributes to this
In the atlas: contributes to 1@jonas-2001 contributor
What it declares
Every artifact
- Type
- Sample
- Origin
- By SAP
- Use as
- A reference
As a sample
- Form
- A reference application
Connections
Training, deploying and calling predictive models on tabular data
AI runtime on BTP with the Generative AI Hub
SaaS for business intelligence, planning and predictive analytics
Cloud data warehouse with spaces, views and analytic models
AI runtime on BTP with the Generative AI Hub
Cloud Foundry runtime of SAP BTP for polyglot applications
Cloud data warehouse with spaces, views and analytic models
Managed SAP HANA database service on BTP
Download
README
quoted from SAP-samples/analytics-cloud-rpt15-prediction-demo under Apache-2.0, readRPT-1.5 Payment Delay Prediction — SAP Analytics Cloud Demo
Description
Run RPT-1.5 predictions directly from SAP Analytics Cloud (SAC).
This project is the backend for an end-to-end setup that predicts how many days late a customer will pay. RPT-1.5 is deployed in SAP AI Core, the data lives in SAP Datasphere, and this FastAPI service — deployed to Cloud Foundry — wraps the prediction call. From SAC, a Multi Action button triggers the prediction, polls for the result, and writes the predicted values back so they show up in a story.
How it works
SAC Multi Action ──POST /predict──▶ FastAPI (Cloud Foundry)
│ │
│ ├─ read V_PAYMENT_DELAY_PREDICTION (Datasphere / HANA)
│ ├─ call RPT-1.5 deployment (AI Core)
│ └─ write predictions → PREDICTION_RESULTS (HANA)
│ │
└──GET /predict/{job_id}──poll──────▶ status / result
- SAC calls
POST /predict, which starts a background job and returns ajobIdplus aLocationheader (async pattern SAC's External API step expects). - The job reads every row from the
V_PAYMENT_DELAY_PREDICTIONview. Rows with aNULLDays_Lateare marked[PREDICT]; all other rows are sent as context so RPT-1.5 can make accurate in-context predictions. - Predictions (value + confidence interval) are upserted into a staging table (
<HANA_USER>.PREDICTION_RESULTS). - SAC polls
GET /predict/{job_id}until the job isdone, then reads the results back into the story.
Project structure
| File | Purpose |
|---|---|
main.py | FastAPI app — async /predict (start job) and /predict/{job_id} (poll), with HTTP Basic auth |
prediction.py | Reads from HANA, builds the RPT-1.5 payload, calls the AI Core deployment, writes results back |
manifest.yaml | Cloud Foundry deployment manifest |
requirements.txt | Python dependencies |
.env.example | Template for required environment variables |
test.ipynb | Notebook for local experimentation |
API
All endpoints require HTTP Basic auth (API_USERNAME / API_PASSWORD).
| Method | Path | Description |
|---|---|---|
GET | / | Health check → {"status": "ok"} |
POST | /predict | Start a prediction job. Returns 202 with jobId and a Location header |
GET | /predict/{job_id} | Poll job status → running / done / failed, plus predicted count |
Requirements
- SAP AI Core with an RPT-1.5 Large deployment
- SAP Datasphere / SAP HANA Cloud with a
V_PAYMENT_DELAY_PREDICTIONview - Cloud Foundry space (SAP BTP) for deployment
- Python 3.10+
Download and Installation
Run locally
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then fill in your values
uvicorn main:app --reload
Run the prediction pipeline directly (without the API):
python prediction.py
Deploy to Cloud Foundry
cf push
Set the environment variables in Cloud Foundry (e.g. cf set-env rpt1-demo <KEY> <VALUE>) or bind them through a service — do not commit your .env.
Configuration
Copy .env.example to .env and fill in the values:
- SAP HANA Cloud —
HANA_HOST,HANA_PORT,HANA_USER,HANA_SCHEMA,HANA_PASSWORD - SAP AI Core —
AICORE_AUTH_URL,AICORE_CLIENT_ID,AICORE_CLIENT_SECRET,AICORE_BASE_URL,AICORE_RESOURCE_GROUP,RPT1.5LARGE_DEPLOYMENT_ID - API auth —
API_USERNAME,API_PASSWORD
Known Issues
No known issues.
How to obtain support
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
Contributing
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.
License
Copyright 2026 SAP SE or an SAP affiliate company and analytics-cloud-rpt15-prediction-demo contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-analytics-cloud-rpt15-prediction-demo- JSON
- /artifacts/sap-samples-analytics-cloud-rpt15-prediction-demo.json
- MCP
- Connecting an agent