SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
β€’ Open full site

Prompt optimization

This tutorial demonstrates how to use Prompt Optimization in SAP AI Core to automatically refine prompt templates using labeled datasets and evaluation metrics.

Overview

🎓 beginner 45 min. SAP Ai CoreBeginnerArtificial IntelligenceMachine Learning

You will learn

  • βœ”How to prepare datasets and object stores for prompt optimization.
  • βœ”How to create and register prompt templates in the Prompt Registry.
  • βœ”How to configure and run prompt optimization via AI Launchpad, Bruno, and the Python SDK.
  • βœ”How to monitor executions, review metrics, and save optimized prompts for reuse.
Smita Naik S Smita Naik April 1, 2026
Created by November 12, 2025
Contributors

Prerequisites

Prerequisites

  1. BTP Account
    Set up your SAP Business Technology Platform (BTP) account.
    Create a BTP Account
  2. For SAP Developers or Employees
    Internal SAP stakeholders should refer to the following documentation: How to create BTP Account For Internal SAP Employee, SAP AI Core Internal Documentation
  3. For External Developers, Customers, or Partners
    Follow this tutorial to set up your environment and entitlements: External Developer Setup Tutorial, SAP AI Core External Documentation
  4. Create BTP Instance and Service Key for SAP AI Core
    Follow the steps to create an instance and generate a service key for SAP AI Core:
    Create Service Key and Instance
  5. AI Core Setup Guide
    Step-by-step guide to set up and get started with SAP AI Core:
    AI Core Setup Tutorial
  6. An Extended SAP AI Core service plan is required, as the Generative AI Hub is not available in the Free or Standard tiers. For more details, refer to SAP AI Core Service Plans
  7. You’ve prepared a prompt template and your template is available in the prompt registry. For more information, see Save a Template

Steps

The process optimizes a prompt for a specific model, stores metrics in the ML Tracking Service, and saves the optimized prompt and results back to the Prompt Registry and Object Store.

Step 1 Pre-Read
β€”

Before starting this tutorial, ensure that you:

  • Understand the basics of Generative AI workflows in SAP AI Core.
  • Are familiar with creating and managing prompt templates, artifacts, and object stores
  • Have the required roles such as genai_manager or custom_evaluation.
  • Have completed the Quick Start tutorial or equivalent setup for SAP AI Core and AI Launchpad access.
Step 2 Architecture Overview
+
Step 3 Notebook Reference
+
Step 4 Environment Variables Setup
+
Step 5 Register Object Store Secret in AI Core
+
Step 6 Prepare Dataset
+
Step 7 Register Dataset Artifact
+
Step 8 Create and save the prompt template
+
Step 9 Register an Optimization Configuration
+
Step 10 Run the Prompt Optimization Execution
+
Step 11 Monitor and View Optimization Progress
+
Step 12 Review Optimization Results
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 12
1. Pre-Read 2. Architecture Overview 3. Notebook Reference 4. Environment Variables Setup 5. Register Object Store Secret in AI Core 6. Prepare Dataset 7. Register Dataset Artifact 8. Create and save the prompt template 9. Register an Optimization Configuration 10. Run the Prompt Optimization Execution 11. Monitor and View Optimization Progress 12. Review Optimization Results

Learn more →