# The generative AI hub for architects: model catalogue, lifecycle and a model policy

> Decide which hub models each use case may call, in which region, under which data terms and version rules, and enforce it with an allow list.

- Course: Orchestrate, Unit 23 · Joule and the AI platform: the architect's view
- Page: https://erpfde.com/topics/generative-ai-hub-for-architects/
- Updated: 2026-11-29
- Reading time: Foundational 8 min, Deep 36 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

SAP's **generative AI hub** gives a company one door to many large language models: OpenAI's through Azure, Anthropic's through AWS, Google's Gemini, Mistral models SAP hosts itself, and SAP's own models. Developers pick a model by name and version. Earlier topics showed them how ([the generative AI hub and orchestration](https://erpfde.com/topics/sap-generative-ai-hub-and-orchestration/), [choosing and calling LLMs](https://erpfde.com/topics/choosing-and-calling-llms/)).

An architect asks different questions. **Which** of those models may this use case call? **Where** is the model served, and may our data go there? **What happens** when SAP retires the version we tested? **Who** confirmed the data terms? Without answers, each team picks its own model, and the company finds out about a retirement or a residency problem when something breaks.

The answer is a short **model policy**: an approved list by data class, region rules, version rules, a data terms record per provider, and an owner for each use case. SAP gives you a way to enforce part of it: an **allow list** on the orchestration deployment, so only approved models can be called through it.

The decision this topic helps you make: no production use case calls a hub model that isn't on the approved list for its data and region, pinned to a version someone tested, with a named owner who re-tests before a retirement date.

### Why it matters to the business

Take Calder Pumpworks, the course's fictional pump maker. By late 2026 it has six use cases on the hub: three agents (order exceptions, invoice triage, supply watch), a nightly batch that codes maintenance notifications, an HR staffing assistant, and a planned extraction of Augsburg's supplier invoices for `CP20`, the German company code. A partner wrote a model policy in May. Reviewed in November, it has ten failures. Four of them would cost real money:

- **A retirement nobody saw.** The batch job is pinned to a model version that the catalogue marks deprecated and that retires within weeks in this course's data. SAP's lifecycle page says a deployment that names a version "stops working" on that date ([Model Lifecycle](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-lifecycle-313fe25.md)).
- **A model that isn't there.** The Augsburg extraction was designed on a small model that SAP's matrix lists for US10 but not EU10, where Calder keeps `CP20`'s data.
- **Data that may leave the region.** Its embedding model is marked `Yes*` in EU10: available, but it "may be accessed from a cross-regional location" for load balancing and failover ([Model Availability by Region](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-availability-by-region-3794e87.md)). For data that must stay in the EU, that is a finding.
- **An old API.** One agent still calls the orchestration V1 API, which SAP will decommission on 31 December 2026 ([What's New, 3 November 2026](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/what-s-new-for-sap-ai-core-b7f76ad.md)).

Each one is cheap to fix in a design review and expensive to fix in production. The policy is how the review finds them.

> **Note** **For functional consultants.** A model change is a change to the process: it can change how an agent words a note, classifies a notification or reads an invoice. Treat it like a configuration change: the use case's test set runs again, the business owner signs, and the date goes in the change log.

### How SAP does it

As of 29 November 2026, these are the pieces SAP provides (all in SAP AI Core's documentation unless noted):

- **The extended service plan.** Generative AI hub access comes with SAP AI Core's extended plan, priced per resource plus model or token usage. You can't downgrade from extended to standard ([Service Plans](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/service-plans-c7244c6.md)).
- **A catalogue per tenant.** A model discovery endpoint lists the models your tenant can use, with each version's context length, cost figures, a `deprecated` flag and a `retirementDate` ([Supported Models](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/supported-models-509e588.md)). SAP Note 3437766 holds token conversion rates, rate limits and deprecation dates; it needs an SAP login.
- **Regional matrices.** SAP publishes which model versions and which features are available in each region, "on a best-effort basis" ([models](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-availability-by-region-3794e87.md), [features](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/feature-availability-by-region-d8e5363.md)).
- **Two upgrade options.** Use `latest` and move to new versions automatically, or name a version and move by hand ([Model Lifecycle](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-lifecycle-313fe25.md)).
- **Model restriction.** An allow or deny list on an orchestration deployment, which SAP describes as a way to implement internal standards where only certain models are approved ([Model Restriction](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-restriction-4d499ee.md)).
- **Data terms.** SAP's Responsible AI page says SAP does not share customer data with third-party LLM providers to train their models, and that data sent to a third-party hosted model is processed only, "not stored or otherwise retained by the model provider" ([sap.com](https://www.sap.com/products/artificial-intelligence/ai-ethics.html)).
- **Rate limits.** Requests per minute per model, shared by the tenant's resource groups unless you set group limits ([Rate Limit Management](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/rate-limit-management-6cbc230.md)).

What SAP doesn't provide is the policy itself: which models your company approves for which data, and who answers for each use case. That is yours to write.

### The model policy on one page

| Part | What it says | Calder's example |
| --- | --- | --- |
| Data classes | How sensitive the data in a prompt is | D1 internal, D2 business confidential, D3 personal, D4 never sent |
| Approved list | Model and version, and the classes each may receive | `gpt-5.4` for D1 to D3; `gemini-3.8-flash` for D1 and D2 |
| Region rule | Where each instance runs, and whether `Yes*` is acceptable | `CP20` data in EU10, `Yes*` not accepted there |
| Version rule | Pinned in production, `latest` only in development | Every production use case names a version |
| Lifecycle rule | How early a retirement must be acted on | Fail within 60 days, warn within 120 (course rule) |
| Fallback rule | A second approved model, from another provider | `gpt-5.4` falls back to `anthropic--claude-4.5-sonnet` |
| Data terms record | Where each provider's terms are stated, who confirmed, when | SAP's Responsible AI page, confirmed by the privacy contact |
| Use case register | Owner and evaluation set for each use case | Order exceptions: owner `00100296`, set `uat-set-v1` |
| Enforcement | The allow list on each orchestration deployment | Generated from the approved list, per region |

The policy is short on purpose. Its job is to make three things true: nobody calls a model the company hasn't approved for that data, nobody is surprised by a retirement, and every model change is re-tested by someone who owns the result.

### Questions to ask

- **To your team:** Which data class does each use case send to a model, and where is that written down?
- **To your team:** Which use cases name a model version, and which use `latest`? Who watches the retirement dates?
- **To your team:** Is there an allow list on each orchestration deployment, and is it generated from the policy or typed by hand?
- **To SAP:** Is the model we plan to use available in our region, and is it marked `Yes*` there? Please confirm against our tenant's catalogue.
- **To SAP:** Which contract documents carry the data terms for remote models, and do they cover every provider on our list?
- **To the partner:** If a model on our list retires during the project, who re-runs the tests, and is that in the estimate?

### Common misconceptions

- **"One approved list is enough."** A model can be approved and still unavailable in the region where your data must stay. The list needs a region view.
- **"`latest` means we never have to think about lifecycle."** SAP warns that behavior can change from version to version. `latest` trades a broken deployment for an untested one.
- **"A model listed in the region is served from the region."** `Yes*` means it may be served from another data center.
- **"SAP's terms cover everything, so no record is needed."** A record says which page or contract you relied on, on what date, and who checked it. Terms change; a record shows when to look again.
- **"The allow list governs every call."** SAP documents it for orchestration deployments. A team that creates its own direct model deployment goes around it, so who may create deployments matters too.

### Key terms

- **Generative AI hub:** the part of SAP AI Core and SAP AI Launchpad that gives access to large language models from several providers, plus orchestration.
- **Model catalogue:** the list of models and versions a tenant can use, read from the model discovery endpoint.
- **Model version:** a dated release of a model, which SAP deprecates and later retires.
- **Deprecation and retirement:** a deprecated version still works but is on its way out; a retired version stops working.
- **`Yes*`:** SAP's mark for a model available in a region that may be served from another region.
- **Data class:** a label for how sensitive the data in a prompt is, which decides the models it may go to.
- **Allow list (model restriction):** the models an orchestration deployment will accept; everything else is refused.
- **Data terms record:** a dated note of where a provider's data handling terms are stated and who confirmed them.

### Check yourself

1. What is the main job of a model policy for the generative AI hub?
   - A. To pick the single best model for the whole company
   - B. To set which models each use case may call, and where
   - C. To replace SAP's data processing agreement with the company's own
   - D. To list every model SAP adds to the hub each month

   Answer: B. The hub offers many models. The policy decides, per data class and region, which ones a use case may call, how versions are handled and who owns each use case.

2. Calder's Augsburg invoices must stay in the EU. Their embedding model is marked Yes* in EU10. What does that mean for the design?
   - A. Nothing, because the model is listed for the EU10 region
   - B. The model needs a larger rate limit set in that region
   - C. It may be served from another region, so it fails the EU rule
   - D. It is a preview model that SAP may withdraw at short notice

   Answer: C. SAP's matrix says Yes* models are available but may be accessed from a cross-regional location. For data that must stay in the EU, choose a model marked Yes in EU10.

3. A batch job is pinned to a model version that SAP marks deprecated. What happens if nobody acts?
   - A. The job moves to the newest version on its own
   - B. The job stops working on that version's date
   - C. The job keeps running but at a higher price
   - D. The job falls back to another provider's model

   Answer: B. SAP's lifecycle page says a deployment that names a version stops working on that version's deprecation date. Only `latest` moves automatically, and it moves untested.

4. Why does the policy pin versions in production instead of using latest?
   - A. Pinned versions are cheaper per token than the latest ones
   - B. SAP only supports pinned versions for production plans
   - C. A new version may behave differently and needs a test
   - D. Latest versions are not offered in European regions

   Answer: C. SAP warns that model behavior can change from version to version. Pinning keeps the tested version until an owner re-runs the evaluation and moves on purpose.

5. Which control can SAP enforce for you, rather than leaving it to each team?
   - A. Which data class each prompt in every use case belongs to
   - B. Who confirmed a provider's data terms and when
   - C. Which models an orchestration deployment will accept
   - D. Which use case owner re-tests a model change

   Answer: C. Model restriction puts an allow or deny list on an orchestration deployment. Data classes, terms records and owners are the company's own policy and process.

6. A vendor says SAP's terms already promise that providers don't train on your data, so no terms record is needed. What is the best reply?
   - A. Agree, since SAP's statement covers every provider by default
   - B. Ask each model provider to sign a separate contract with you
   - C. Stop using remote models and keep only SAP-hosted ones
   - D. Keep a dated record of the source and who confirmed it

   Answer: D. SAP's Responsible AI page does state that position, but terms change and contracts differ. A dated record shows what you relied on and when to check again.

## Deep layer

### Mental model

Treat a hub model the way you treat any **external dependency**: it has a supplier, a version, a region where it runs, terms of use, and an end-of-life date. A model policy is the dependency policy for that one kind of component. It answers four questions per call: **may** this data go to this model (data class and terms), **can** it in this region (availability and residency), **which** version (pinned and tested), and **until when** (retirement and the owner who acts).

Then put the enforcement where calls actually pass. Every orchestration call goes through a deployment in a resource group, so an allow list on that deployment turns part of the policy into a hard control. The rest stays a review: a script that checks the policy and the catalogue on a date, and a register that names owners.

### How it works

```mermaid
flowchart LR
  A[Agent or app<br/>AGT_ORDER_EXC] -->|orchestration v2,<br/>model + version| O[Orchestration deployment<br/>in a resource group]
  O -->|allow list:<br/>approved models| M{Model in<br/>the list?}
  M -->|no| X[Refused]
  M -->|yes| P[Provider<br/>Azure, AWS, Google,<br/>SAP-hosted]
  D[Direct deployment<br/>foundation-models] --> P
  C[(Catalogue:<br/>discovery endpoint,<br/>SAP Note 3437766)] -.-> R[Policy review<br/>model_policy.py]
  R -.->|generates| O
```

#### The catalogue and its fields

The model discovery endpoint, `GET $AI_API_URL/v2/lm/scenarios/foundation-models/models` with an `AI-Resource-Group` header, returns what your tenant can use ([Supported Models](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/supported-models-509e588.md)). SAP's regional page calls the endpoint the authoritative list for your landscape and its own tables best-effort. The fields an architect reads:

| Field | Why the policy needs it |
| --- | --- |
| `executableId`, `model` | Which provider route, and the name the deployment uses |
| `accessType`, `provider` | Remote, SAP-hosted or SAP-managed: who runs the model |
| `allowedScenarios` | Whether the model can be used through `orchestration`, `foundation-models` or both |
| `versions[].name`, `isLatest` | What to pin, and what `latest` currently resolves to |
| `versions[].deprecated`, `retirementDate` | The lifecycle signal the review reacts to |
| `versions[].contextLength`, `capabilities`, `inputTypes` | Whether the model fits the use case at all |
| `versions[].cost` | A relative figure; SAP's page doesn't state its unit, so price from SAP Note 3437766 and your contract |

#### Access types and who runs the model

SAP's regional page names three access types: **SAP-hosted** (on SAP's own infrastructure), **SAP-managed** (on "SAP's tenant-isolated Hyperscaler infrastructure") and **remote** (hosted and managed by a provider such as AWS, reached through SAP AI Core). The supported-models page adds that Azure OpenAI models are reached through a private instance of the chat completions API that isn't publicly available. For a data terms record this matters: SAP's Responsible AI statement about providers not storing data is about third-party hosted models, the remote ones.

#### Regions and `Yes*`

The model matrix gives `Yes`, `Yes*` or `No` for each version in each region. `Yes*` means the model "may be accessed from a cross-regional location", which SAP uses to harmonize the offer across data centers and for load balancing and failover. SAP's own example: `mistralai--mistral-small` is `Yes*` in US10 and `Yes` in EU10. As read on 29 November 2026 (SAP's documentation source last changed on 5 November), Calder's two regions look like this for the models in its policy:

| Model and version | Access | US10 | EU10 |
| --- | --- | --- | --- |
| `gpt-5.4` 2026-03-05 | Azure | Yes | Yes |
| `gpt-5.4-nano` 2026-03-17 | Azure | Yes | No |
| `gpt-4.1` 2025-04-14 | Azure | Yes | Yes |
| `text-embedding-3-small` 1 | Azure | Yes | Yes* |
| `anthropic--claude-4.5-sonnet` 1 | AWS | Yes | Yes |
| `gemini-3.8-flash` 001 | Google | Yes | Yes |
| `mistralai--mistral-small` 2603 | SAP-hosted | Yes* | Yes |
| `nvidia--llama-3.2-nv-embedqa-1b` 2 | SAP-managed | Yes | Yes |

Features have their own matrix. As read on the same day, for example, the LLM batch service is listed as unavailable in every Asia Pacific region in the table ([Feature Availability by Region](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/feature-availability-by-region-d8e5363.md)). A design that needs batch, grounding or prompt optimization checks the feature as well as the model.

> **Note** Residency is a design question, not a product setting. SAP Learning says generative AI processing "may occur on SAP-managed infrastructure or approved external model providers" and that regional options are subject to availability ([SAP Learning](https://learning.sap.com/courses/building-confidence-in-ai-with-sap/data-residency-and-digital-sovereignty-for-ai)). Your policy says which data needs which region; the matrix and your tenant's catalogue say which models can meet it.

#### Versions, deprecation and retirement

SAP's lifecycle page offers two options. **Auto upgrade**: the deployment's configuration says `latest`, and existing deployments use a new version as soon as SAP supports it. **Manual upgrade**: the configuration names a version, and you patch the deployment with a new configuration when you choose. If no version is given, it is `latest`. A deployment pinned to a version "stops working on the deprecation date of that model version" ([Model Lifecycle](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-lifecycle-313fe25.md)). The regional page adds that on `latest` you are moved when a version is deprecated, and that "model behavior can change from version to version".

So neither option is free. Pinning needs someone to watch dates; `latest` needs someone to notice behavior changes after the fact. Calder's policy pins in production and allows `latest` in development, where a change is cheap. SAP's own APIs deprecate too: the orchestration V1 workflow API, first set to end on 31 October 2026, now ends on 31 December 2026 ([What's New](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/what-s-new-for-sap-ai-core-b7f76ad.md)).

#### Model restriction: the allow list

When you create a deployment for orchestration, you can bind two parameters: `modelFilterList`, a JSON list of `modelName` and optional `modelVersions` (no versions means all versions), and `modelFilterListType`, `allow` or `deny` ([Model Restriction](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-restriction-4d499ee.md)). An allow list is the stricter choice: a model SAP adds next month is refused until the policy approves it. A deny list lets every new model in by default.

The orchestration deployment comes from the global scenario `orchestration` and executable `orchestration`, and SAP says you likely already have one running in your default resource group. A restricted deployment is a new deployment created from a configuration with those bindings ([Create a Deployment for Orchestration](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/create-a-deployment-for-orchestration-4387aa7.md)). Two consequences for the design: the unrestricted default deployment must not stay reachable in production resource groups, and direct `foundation-models` deployments, which bypass orchestration, need their own control through who may create deployments.

#### Rate limits

Limits are requests per minute per model, per tenant, shared by all resource groups unless a group has its own limit, and all versions of a model share one limit. A `429` can also mean the provider is out of capacity. SAP's advice includes retries with backoff, fallback models and separate resource groups per workload; limit increases are requested through an API and approved by SAP ([Rate Limit Management](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/rate-limit-management-6cbc230.md)). For the policy, that makes the fallback rule an availability rule as well as a quality one: a fallback from another provider family isn't hit by the same capacity problem. The code for fallbacks is in [model routing with fallbacks](https://erpfde.com/topics/model-routing-with-fallbacks-in-the-sap-cloud-sdk/).

#### Data terms

Three statements from SAP define the baseline, each with its source:

- SAP AI Core "acts as the data processor"; customers, as data controllers, are responsible for data protection duties for what they store and process ([Data Storage and Processing](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/data-storage-and-processing-74fc987.md)).
- SAP does not share customer data with third-party LLM providers for training; data sent to a third-party hosted model is processed only and not stored or retained by the provider. The same page says SAP may use customer data to improve its own products where the agreement allows ([Responsible AI](https://www.sap.com/products/artificial-intelligence/ai-ethics.html)).
- Data masking and filtering are modules you switch on in orchestration, not defaults ([the generative AI hub and orchestration](https://erpfde.com/topics/sap-generative-ai-hub-and-orchestration/), [data security and PII](https://erpfde.com/topics/data-security-and-pii/)).

The policy turns those into rules: personal data (D3) only with the masking module on, restricted data (D4) never, and a dated terms record for each provider family on the approved list.

### Build it yourself

You will write a script that holds Calder's six hub use cases, a catalogue snapshot with SAP's regional availability, and a model policy. It checks the policy against eleven course rules on a given date, then writes a model register and an allow list for each AI Core instance in the shape SAP's model restriction expects.

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/) and [Set up for Unit 23](https://erpfde.com/topics/set-up-for-unit-23/). This script needs no account and no network.

```mermaid
flowchart LR
  P[policy_draft.json<br/>policy_reviewed.json] --> S[model_policy.py]
  C[Built-in catalogue:<br/>SAP's region matrix,<br/>course lifecycle dates] --> S
  L[Optional: your tenant's<br/>discovery response] -.-> S
  S --> T[Findings in the terminal]
  S --> R[model_register.md]
  S --> A[allowlist_calder-aicore.json<br/>allowlist_calder-aicore-eu.json]
```

> **Note** New words in this walkthrough:
> - **Policy file:** a JSON file (a text format of names and values in braces) holding the approved list, terms records and use cases.
> - **Finding:** one line of the review, `OK`, `WARN` or `FAIL`, with the rule that produced it.
> - **Discovery response:** the JSON your own SAP AI Core tenant returns from the model discovery endpoint, saved to a file.
> - **Exit code:** a number a program returns when it ends; `0` means no failures, `2` means at least one `FAIL`, so a pipeline can stop on it.

#### What you need

- Your course folder `orchestrate-course` with `.venv`.
- About 30 minutes.
- Cost: free. No account, no network, no model calls. Step 7 is optional and needs an SAP AI Core tenant.

#### Step 1: Open your course folder and turn on the virtual environment

1. Open VS Code, choose **File > Open Folder**, and open `orchestrate-course`.
2. Open a terminal: **Terminal > New Terminal**.
3. If the prompt doesn't start with `(.venv)`, turn it on:

   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

4. Make sure the `unit23` folder exists. The command does nothing if it is already there.

   - **Windows (PowerShell):**

     ```powershell
     New-Item -ItemType Directory -Force unit23
     ```

   - **macOS / Linux:**

     ```bash
     mkdir -p unit23
     ```

#### Step 2: Create the script

1. In VS Code, create the file `unit23/model_policy.py`, paste the code below, and save.

```python
"""Check Calder Pumpworks' use of generative AI hub models against a model policy.

Run it from your course folder:
    python unit23/model_policy.py --init                  # write the draft and reviewed policy files
    python unit23/model_policy.py                         # review the partner's draft
    python unit23/model_policy.py --policy reviewed       # review the fixed policy and write the outputs
Options:
    --policy draft|reviewed|PATH   which policy file to review (default: draft)
    --today YYYY-MM-DD             the date to judge lifecycle and review dates (default 2026-11-29)
    --catalogue PATH               a model discovery response saved from your own SAP AI Core
                                   tenant; its deprecated and retirementDate values replace the
                                   built-in ones for the models it lists

Built-in modules only, no network, no randomness. Calder, its use cases, owners, data classes,
lead times and rules are course values. The regional availability is SAP's matrix as published
on 5 November 2026. The deprecation flags and retirement dates are course values: SAP keeps the
real ones in SAP Note 3437766 and the model discovery endpoint of your own tenant.
"""
import argparse
import json
from datetime import date
from pathlib import Path

HERE = Path(__file__).resolve().parent / "models"
TODAY = "2026-11-29"
FAIL_DAYS = 60     # course rule: a version retiring within 60 days fails
WARN_DAYS = 120    # course rule: within 120 days warns
TERMS_DAYS = 180   # course rule: a provider terms record is re-confirmed every 180 days
V1_END = "2026-12-31"  # SAP: orchestration V1 decommissioning date, as extended on 3 November 2026

# Catalogue: (model, version) -> facts. executableId, provider family and access type as SAP's
# matrix shows them; "US10"/"EU10" are SAP's Yes / Yes* / No. deprecated and retirement are course values.
CATALOGUE = {
    ("gpt-5.4", "2026-03-05"): dict(exe="azure-openai", family="Azure", access="remote", US10="Yes", EU10="Yes", deprecated=False, retirement=""),
    ("gpt-5.4-nano", "2026-03-17"): dict(exe="azure-openai", family="Azure", access="remote", US10="Yes", EU10="No", deprecated=False, retirement=""),
    ("gpt-4.1", "2025-04-14"): dict(exe="azure-openai", family="Azure", access="remote", US10="Yes", EU10="Yes", deprecated=False, retirement="2027-04-14"),
    ("gpt-4o", "2024-05-13"): dict(exe="azure-openai", family="Azure", access="remote", US10="Yes", EU10="Yes", deprecated=True, retirement="2026-12-31"),
    ("text-embedding-3-small", "1"): dict(exe="azure-openai", family="Azure", access="remote", US10="Yes", EU10="Yes*", deprecated=False, retirement=""),
    ("anthropic--claude-4.5-sonnet", "1"): dict(exe="aws-bedrock", family="AWS", access="remote", US10="Yes", EU10="Yes", deprecated=False, retirement=""),
    ("gemini-3.8-flash", "001"): dict(exe="gcp-vertexai", family="Google", access="remote", US10="Yes", EU10="Yes", deprecated=False, retirement=""),
    ("mistralai--mistral-small", "2603"): dict(exe="aicore-mistralai", family="SAP-hosted", access="SAP-hosted", US10="Yes*", EU10="Yes", deprecated=False, retirement=""),
    ("nvidia--llama-3.2-nv-embedqa-1b", "2"): dict(exe="aicore-nvidia", family="SAP-managed", access="SAP-managed", US10="Yes", EU10="Yes", deprecated=False, retirement=""),
    ("sonar", "perplexity-us"): dict(exe="perplexity-ai", family="Perplexity", access="remote", US10="Yes", EU10="Yes*", deprecated=False, retirement=""),
}

INSTANCES = {"calder-aicore": "US10", "calder-aicore-eu": "EU10"}

SAP_TERMS = ("sap.com Responsible AI FAQ: customer data not shared with third-party LLM providers "
             "to train their models; data sent to a third-party hosted model is processed only, "
             "not stored or retained by the provider")

USE_CASES = [
    dict(id="U01", name="Order exception notes", agent="AGT_ORDER_EXC", owner="00100296", eval="uat-set-v1",
         data="D2", instance="calder-aicore", residency="", api="orchestration-v2", masking=False,
         primary=["gpt-5.4", "2026-03-05"], fallback=["anthropic--claude-4.5-sonnet", "1"], stage="production"),
    dict(id="U02", name="Invoice exception triage", agent="AGT_INV_TRIAGE", owner="00100244", eval="trajectory-T1-T6",
         data="D2", instance="calder-aicore", residency="", api="orchestration-v2", masking=False,
         primary=["gpt-5.4", "2026-03-05"], fallback=["anthropic--claude-4.5-sonnet", "1"], stage="production"),
    dict(id="U03", name="Supply watch briefings", agent="AGT_SUPPLY_WATCH", owner="00100153", eval="supply-watch-v1",
         data="D2", instance="calder-aicore", residency="", api="orchestration-v2", masking=False,
         primary=["gemini-3.8-flash", "001"], fallback=["gpt-5.4", "2026-03-05"], stage="production"),
    dict(id="U04", name="Notification damage coding (batch)", agent="W07 notification-coding-batch", owner="00100288",
         eval="local-0001-sample", data="D1", instance="calder-aicore", residency="", api="batch", masking=False,
         primary=["gpt-4.1", "2025-04-14"], fallback=None, stage="production"),
    dict(id="U05", name="Augsburg supplier invoice extraction", agent="E01 CP20 invoices", owner="00100241",
         eval="cp20-invoices-40", data="D2", instance="calder-aicore-eu", residency="EU", api="orchestration-v2",
         masking=False, primary=["gpt-5.4", "2026-03-05"], fallback=["mistralai--mistral-small", "2603"],
         embedding=["nvidia--llama-3.2-nv-embedqa-1b", "2"], stage="production"),
    dict(id="U06", name="Staffing shortlist explanations", agent="AGT_STAFFING", owner="00100306", eval="staffing-H01-H10",
         data="D3", instance="calder-aicore", residency="", api="orchestration-v2", masking=True,
         primary=["anthropic--claude-4.5-sonnet", "1"], fallback=["mistralai--mistral-small", "2603"], stage="production"),
]

APPROVED = [
    dict(model="gpt-5.4", versions=["2026-03-05"], classes=["D1", "D2", "D3"]),
    dict(model="anthropic--claude-4.5-sonnet", versions=["1"], classes=["D1", "D2", "D3"]),
    dict(model="gemini-3.8-flash", versions=["001"], classes=["D1", "D2"]),
    dict(model="gpt-4.1", versions=["2025-04-14"], classes=["D1", "D2"]),
    dict(model="mistralai--mistral-small", versions=["2603"], classes=["D1", "D2", "D3"]),
    dict(model="gpt-5.4-nano", versions=["2026-03-17"], classes=["D1", "D2"]),
    dict(model="text-embedding-3-small", versions=["1"], classes=["D1", "D2"]),
    dict(model="nvidia--llama-3.2-nv-embedqa-1b", versions=["2"], classes=["D1", "D2", "D3"]),
]

TERMS = {fam: dict(source=SAP_TERMS, confirmed_by="00100292", confirmed="2026-11-27")
         for fam in ["Azure", "AWS", "Google", "SAP-hosted", "SAP-managed"]}


def reviewed_policy():
    return dict(name="Calder model policy", version="1.0", owner="00100290", reviewed="2026-11-27",
                data_classes={"D1": "internal, no customer or personal data",
                              "D2": "business confidential: orders, prices, invoices, supplier names",
                              "D3": "personal data: employees and contact persons (masking required)",
                              "D4": "restricted: bank details and payroll, never sent to a model"},
                approved=APPROVED, terms=TERMS, use_cases=USE_CASES,
                allowlists={"calder-aicore": "generated", "calder-aicore-eu": "generated"})


def draft_policy():
    p = json.loads(json.dumps(reviewed_policy()))
    p["reviewed"] = "2026-05-12"
    p["approved"].append(dict(model="gpt-4o", versions=["2024-05-13"], classes=["D1", "D2"]))
    p["approved"].append(dict(model="sonar", versions=["perplexity-us"], classes=["D1", "D2"]))
    uc = {u["id"]: u for u in p["use_cases"]}
    uc["U01"]["primary"] = ["gpt-5.4", "latest"]              # M03: not pinned in production
    uc["U02"]["api"] = "orchestration-v1"                     # M09: V1 decommissioned 2026-12-31
    uc["U03"]["fallback"] = None                              # M06: no fallback
    uc["U03"]["eval"] = ""                                    # M08: no evaluation set
    uc["U04"]["primary"] = ["gpt-4o", "2024-05-13"]           # M04: deprecated, retires 2026-12-31
    uc["U05"]["primary"] = ["gpt-5.4-nano", "2026-03-17"]     # M02: not in EU10
    uc["U05"]["embedding"] = ["text-embedding-3-small", "1"]  # M02: Yes* in EU10, EU residency
    uc["U06"]["masking"] = False                              # M07: personal data without masking
    p["allowlists"] = {}                                      # M05: no model restriction anywhere
    return p


def days(a, b):
    return (date.fromisoformat(b) - date.fromisoformat(a)).days


class Review:
    def __init__(self):
        self.rows = []

    def add(self, level, rule, obj, text):
        self.rows.append((level, rule, obj, text))


def approved_for(policy, model, version, data_class):
    for a in policy["approved"]:
        if a["model"] == model and version in a["versions"]:
            return data_class in a["classes"]
    return None


def allowlist(policy, instance, catalogue):
    """Models approved in the policy and usable in the instance's region, in SAP's modelFilterList shape."""
    region = INSTANCES[instance]
    eu_only = any(u["instance"] == instance and u["residency"] for u in policy["use_cases"])
    entries = []
    for a in policy["approved"]:
        vers = []
        for v in a["versions"]:
            c = catalogue.get((a["model"], v))
            if not c or c[region] == "No" or (eu_only and c[region] != "Yes"):
                continue
            vers.append(v)
        if vers:
            entries.append({"modelName": a["model"], "modelVersions": vers})
    return entries


def check(policy, today, catalogue):
    r = Review()
    for u in policy["use_cases"]:
        region = INSTANCES[u["instance"]]
        models = [("primary", u["primary"]), ("fallback", u.get("fallback")), ("embedding", u.get("embedding"))]
        # M08 owner and evaluation set
        if not u.get("owner") or not u.get("eval"):
            r.add("FAIL", "M08", u["id"], "no owner or no evaluation set: a model change can't be re-tested")
        else:
            r.add("OK", "M08", u["id"], f"owner {u['owner']}, evaluation set {u['eval']}")
        # M07 data class
        if u["data"] == "D4":
            r.add("FAIL", "M07", u["id"], "D4 data is never sent to a model")
        elif u["data"] == "D3" and not u["masking"]:
            r.add("FAIL", "M07", u["id"], "D3 personal data without the data masking module")
        else:
            r.add("OK", "M07", u["id"], f"data class {u['data']}" + (", masking on" if u["masking"] else ""))
        # M09 orchestration version
        if u["api"] == "orchestration-v1":
            r.add("FAIL", "M09", u["id"], f"orchestration V1 is deprecated, decommissioned {V1_END} ({days(today, V1_END)} days)")
        else:
            r.add("OK", "M09", u["id"], f"calls through {u['api']}")
        # M06 fallback
        if u["api"].startswith("orchestration"):
            fb = u.get("fallback")
            if not fb:
                r.add("WARN", "M06", u["id"], "no fallback model: a 429 or an outage stops the use case")
            elif catalogue.get(tuple(fb), {}).get("family") == catalogue.get(tuple(u["primary"]), {}).get("family"):
                r.add("WARN", "M06", u["id"], "fallback from the same provider family as the primary")
            else:
                r.add("OK", "M06", u["id"], f"fallback {fb[0]}")
        for role, m in models:
            if not m:
                continue
            model, version = m
            label = f"{u['id']} {role} {model} {version}"
            # M03 pinned version
            if version in ("latest", ""):
                if u["stage"] == "production":
                    r.add("FAIL", "M03", label, "production uses latest: behavior can change without a re-test")
                    pinned = [k for k in catalogue if k[0] == model]
                    version = pinned[0][1] if pinned else version
                else:
                    r.add("OK", "M03", label, "latest is allowed outside production")
            else:
                r.add("OK", "M03", label, "version pinned")
            c = catalogue.get((model, version))
            if not c:
                r.add("FAIL", "M02", label, "not in the catalogue of this tenant")
                continue
            # M01 approved for the data class
            ok = approved_for(policy, model, version, u["data"])
            if ok is None:
                r.add("FAIL", "M01", label, "not on the approved list")
            elif not ok:
                r.add("FAIL", "M01", label, f"approved, but not for {u['data']} data")
            else:
                r.add("OK", "M01", label, f"approved for {u['data']}")
            # M02 region and residency
            avail = c[region]
            if avail == "No":
                r.add("FAIL", "M02", label, f"not available in {region}")
            elif avail == "Yes*" and u["residency"]:
                r.add("FAIL", "M02", label, f"Yes* in {region}: may be served from another region, {u['residency']} residency required")
            elif avail == "Yes*":
                r.add("OK", "M02", label, f"Yes* in {region}: may be served cross-region (no residency rule)")
            else:
                r.add("OK", "M02", label, f"available in {region}")
            # M04 lifecycle
            if c["deprecated"] or (c["retirement"] and days(today, c["retirement"]) <= FAIL_DAYS):
                when = c["retirement"] or "no date"
                r.add("FAIL", "M04", label, f"deprecated or retiring soon (retirement {when})")
            elif c["retirement"] and days(today, c["retirement"]) <= WARN_DAYS:
                r.add("WARN", "M04", label, f"retires {c['retirement']} ({days(today, c['retirement'])} days): plan the move")
            else:
                r.add("OK", "M04", label, "no retirement within " + str(WARN_DAYS) + " days")
    # M05 model restriction on each production orchestration instance
    for inst in INSTANCES:
        if not any(u["instance"] == inst and u["api"].startswith("orchestration") for u in policy["use_cases"]):
            continue
        if policy.get("allowlists", {}).get(inst) != "generated":
            r.add("FAIL", "M05", inst, "orchestration deployment without an allow list: any model in the tenant can be called")
        else:
            n = len(allowlist(policy, inst, catalogue))
            r.add("OK", "M05", inst, f"allow list generated from the policy ({n} models)")
    # M10 terms record per provider family on the approved list
    fams = sorted({catalogue[(a["model"], v)]["family"] for a in policy["approved"] for v in a["versions"]
                   if (a["model"], v) in catalogue})
    for fam in fams:
        t = policy["terms"].get(fam)
        if not t:
            r.add("FAIL", "M10", fam, "approved models from this provider, but no data terms record")
        elif days(t["confirmed"], today) > TERMS_DAYS:
            r.add("WARN", "M10", fam, f"terms confirmed {t['confirmed']}, more than {TERMS_DAYS} days ago")
        else:
            r.add("OK", "M10", fam, f"terms confirmed {t['confirmed']} by {t['confirmed_by']}")
    # policy review date (course rule: 90 days)
    age = days(policy["reviewed"], today)
    r.add("WARN" if age > 90 else "OK", "M10", "policy", f"policy reviewed {policy['reviewed']} ({age} days ago)")
    return r


def write_outputs(policy, review, catalogue, today):
    HERE.mkdir(exist_ok=True)
    for inst in INSTANCES:
        body = {"name": f"orchestration-{inst}-restricted", "executableId": "orchestration",
                "scenarioId": "orchestration",
                "parameterBindings": [
                    {"key": "modelFilterList", "value": json.dumps(allowlist(policy, inst, catalogue))},
                    {"key": "modelFilterListType", "value": "allow"}]}
        (HERE / f"allowlist_{inst}.json").write_text(json.dumps(body, indent=2) + "\n")
    lines = [f"# {policy['name']} {policy['version']}: model register", "",
             f"Reviewed {today}. Owner {policy['owner']}. Course values; regional availability from SAP's matrix.", "",
             "| Use case | Agent | Data | Instance | Primary | Fallback | Owner | Evaluation |",
             "| --- | --- | --- | --- | --- | --- | --- | --- |"]
    for u in policy["use_cases"]:
        fb = " ".join(u["fallback"]) if u.get("fallback") else "none"
        lines.append(f"| {u['id']} {u['name']} | {u['agent']} | {u['data']} | {u['instance']} | "
                     f"{' '.join(u['primary'])} | {fb} | {u['owner']} | {u['eval']} |")
    lines += ["", "## Next retirements", ""]
    used = {tuple(m) for u in policy["use_cases"] for m in (u["primary"], u.get("fallback"), u.get("embedding")) if m}
    dated = sorted((catalogue[k]["retirement"], k) for k in used if k in catalogue and catalogue[k]["retirement"])
    lines += [f"- {k[0]} {k[1]}: retires {d}" for d, k in dated] or ["- none recorded"]
    lines += ["", "## Open findings", ""]
    open_rows = [x for x in review.rows if x[0] != "OK"]
    lines += [f"- {lv} {rule} {obj}: {txt}" for lv, rule, obj, txt in open_rows] or ["- none"]
    (HERE / "model_register.md").write_text("\n".join(lines) + "\n")


def main():
    ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    ap.add_argument("--init", action="store_true")
    ap.add_argument("--policy", default="draft")
    ap.add_argument("--today", default=TODAY)
    ap.add_argument("--catalogue")
    a = ap.parse_args()
    if a.init:
        HERE.mkdir(exist_ok=True)
        (HERE / "policy_draft.json").write_text(json.dumps(draft_policy(), indent=2) + "\n")
        (HERE / "policy_reviewed.json").write_text(json.dumps(reviewed_policy(), indent=2) + "\n")
        print(f"Wrote {HERE / 'policy_draft.json'} and {HERE / 'policy_reviewed.json'}")
        return
    path = HERE / f"policy_{a.policy}.json" if a.policy in ("draft", "reviewed") else Path(a.policy)
    if not path.exists():
        print("No policy file yet. Run: python unit23/model_policy.py --init")
        return
    policy = json.loads(path.read_text())
    catalogue = {k: dict(v) for k, v in CATALOGUE.items()}
    if a.catalogue:
        live = json.loads(Path(a.catalogue).read_text())
        n = 0
        for res in live.get("resources", []):
            for v in res.get("versions", []):
                key = (res.get("model"), v.get("name"))
                if key in catalogue:
                    catalogue[key]["deprecated"] = bool(v.get("deprecated"))
                    catalogue[key]["retirement"] = v.get("retirementDate") or ""
                    n += 1
        print(f"Lifecycle dates taken from {a.catalogue} for {n} model versions")
    review = check(policy, a.today, catalogue)
    print(f"{policy['name']} {policy['version']}: {path.name}, as of {a.today}")
    for lv, rule, obj, txt in review.rows:
        if lv != "OK":
            print(f"  {lv:4}  {rule}  {obj}: {txt}")
    counts = {lv: sum(1 for x in review.rows if x[0] == lv) for lv in ("OK", "WARN", "FAIL")}
    print(f"Summary: {counts['OK']} OK, {counts['WARN']} WARN, {counts['FAIL']} FAIL")
    write_outputs(policy, review, catalogue, a.today)
    print(f"Wrote {HERE.name}/model_register.md and {HERE.name}/allowlist_<instance>.json")
    raise SystemExit(2 if counts["FAIL"] else 0)


if __name__ == "__main__":
    main()
```

> **Note** Calder, its use cases, owners, data classes, lead times and rules are fictional course values. The `US10` and `EU10` columns are SAP's regional matrix as published on 5 November 2026 and read on 29 November 2026; they can change. The `deprecated` flags and retirement dates are **course values**: SAP keeps the real ones in SAP Note 3437766 and in your tenant's discovery endpoint (Step 7).

#### Step 3: Write the two policy files

1. Run:

   ```bash
   python unit23/model_policy.py --init
   ```

2. You should see one line naming `unit23/models/policy_draft.json` and `unit23/models/policy_reviewed.json`. Open the draft in VS Code and find the `use_cases` list: six entries, `U01` to `U06`.

#### Step 4: Review the partner's draft

1. Run the review. The same command works in PowerShell and macOS/Linux while `.venv` is active:

   ```bash
   python unit23/model_policy.py
   ```

**What success looks like:**

```text
Calder model policy 1.0: policy_draft.json, as of 2026-11-29
  FAIL  M03  U01 primary gpt-5.4 latest: production uses latest: behavior can change without a re-test
  FAIL  M09  U02: orchestration V1 is deprecated, decommissioned 2026-12-31 (32 days)
  FAIL  M08  U03: no owner or no evaluation set: a model change can't be re-tested
  WARN  M06  U03: no fallback model: a 429 or an outage stops the use case
  FAIL  M04  U04 primary gpt-4o 2024-05-13: deprecated or retiring soon (retirement 2026-12-31)
  FAIL  M02  U05 primary gpt-5.4-nano 2026-03-17: not available in EU10
  FAIL  M02  U05 embedding text-embedding-3-small 1: Yes* in EU10: may be served from another region, EU residency required
  FAIL  M07  U06: D3 personal data without the data masking module
  FAIL  M05  calder-aicore: orchestration deployment without an allow list: any model in the tenant can be called
  FAIL  M05  calder-aicore-eu: orchestration deployment without an allow list: any model in the tenant can be called
  FAIL  M10  Perplexity: approved models from this provider, but no data terms record
  WARN  M10  policy: policy reviewed 2026-05-12 (201 days ago)
Summary: 64 OK, 2 WARN, 10 FAIL
Wrote models/model_register.md and models/allowlist_<instance>.json
```

2. Read the findings from the top. Each names a rule, the use case and the reason. Only `WARN` and `FAIL` lines print; the `OK` lines are counted in the summary.
3. Notice the two `M02` lines for `U05`. The approved list allows both models, but EU10 can't serve one of them at all and may serve the other from elsewhere. Approval and region are separate questions.
4. The script ends with exit code `2` because there are failures. In a pipeline, that stops the change.

> **Note** These findings come from a fictional company and course lifecycle dates. They show the method, not a finding about any real landscape. The output is the same on every run: the script has no randomness.

#### Step 5: Review the fixed policy

1. Run:

   ```bash
   python unit23/model_policy.py --policy reviewed
   ```

2. Check the result:

   ```text
   Calder model policy 1.0: policy_reviewed.json, as of 2026-11-29
   Summary: 79 OK, 0 WARN, 0 FAIL
   Wrote models/model_register.md and models/allowlist_<instance>.json
   ```

3. Compare the two files to see each fix: `U01` pins `2026-03-05`; `U02` calls orchestration V2; `U03` has a fallback and an evaluation set; `U04` uses `gpt-4.1`; `U05` uses `gpt-5.4` with `mistralai--mistral-small` as fallback and the SAP-managed embedding model; `U06` turns masking on; `gpt-4o` and `sonar` leave the approved list; both instances get generated allow lists; the policy carries a November review date.
4. Open `unit23/models/allowlist_calder-aicore-eu.json`. It is a configuration body with `modelFilterList` and `modelFilterListType: allow`. It holds six models; the US file holds eight. `gpt-5.4-nano` (not in EU10) and `text-embedding-3-small` (`Yes*`, and that instance holds EU-only data) are left out automatically.
5. Open `unit23/models/model_register.md`: one row per use case with model, fallback, owner and evaluation set, the next retirement in use, and open findings (none).

#### Step 6: Look ahead in time

1. Judge the reviewed policy as of 10 January 2027:

   ```bash
   python unit23/model_policy.py --policy reviewed --today 2027-01-10
   ```

2. You should see one warning: `WARN  M04  U04 primary gpt-4.1 2025-04-14: retires 2027-04-14 (94 days): plan the move`. That is the cue for the batch job's owner to test a replacement.
3. Try `--today 2027-03-01`. The same line is now a `FAIL`, and the policy itself warns that its last review was more than 90 days ago.

#### Step 7 (optional): Use your own tenant's lifecycle dates

This step needs an SAP AI Core instance on a plan with the generative AI hub, such as a trial. Skip it if you don't have one.

1. With your token and URL in environment variables (set up in [the generative AI hub and orchestration](https://erpfde.com/topics/sap-generative-ai-hub-and-orchestration/)), save the discovery response:

   - **Windows (PowerShell):**

     ```powershell
     curl.exe -s "$env:AI_API_URL/v2/lm/scenarios/foundation-models/models" -H "AI-Resource-Group: default" -H "Authorization: Bearer $env:AUTH_TOKEN" -o unit23/models/discovery.json
     ```

   - **macOS / Linux:**

     ```bash
     curl -s "$AI_API_URL/v2/lm/scenarios/foundation-models/models" -H "AI-Resource-Group: default" -H "Authorization: Bearer $AUTH_TOKEN" -o unit23/models/discovery.json
     ```

2. Run:

   ```bash
   python unit23/model_policy.py --policy reviewed --catalogue unit23/models/discovery.json
   ```

3. The first line says how many model versions took their `deprecated` and `retirementDate` from your file. Findings now reflect your tenant's dates for those versions.

> **Warning** The token is a secret. Keep it in an environment variable or `.env`, never in a script or a file you commit. Don't commit `discovery.json` from a customer tenant either.

#### Step 8: Save your work in Git

```bash
git add unit23/model_policy.py unit23/models/policy_draft.json unit23/models/policy_reviewed.json unit23/models/model_register.md unit23/models/allowlist_calder-aicore.json unit23/models/allowlist_calder-aicore-eu.json
git commit -m "Unit 23: Calder model policy and allow lists"
```

#### How the code works

| Part | What it does |
| --- | --- |
| `CATALOGUE` | One row per model version: route, provider family, access type, SAP's US10 and EU10 availability, course lifecycle values |
| `USE_CASES`, `APPROVED`, `TERMS` | Calder's reviewed policy: six use cases, the approved list by data class, one terms record per provider family |
| `draft_policy()` | Copies the reviewed policy and puts back the partner's ten mistakes, each commented with its rule |
| `check()` | Applies the rules per use case and model (M01 to M04, M06 to M09), then per instance (M05) and per provider (M10) |
| `allowlist()` | Builds `modelFilterList` from approved models available in the instance's region, dropping `Yes*` where the instance holds EU-only data |
| `write_outputs()` | Writes the two configuration bodies and `model_register.md` |
| `--catalogue` | Replaces lifecycle values with those from your tenant's discovery response for matching versions |
| Exit code | `2` if any `FAIL`, so a pipeline can block the change |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized, or `command not found` | Python isn't installed or the virtual environment is off | Turn on `.venv` (Step 1); see [Set up your computer](https://erpfde.com/topics/set-up-your-computer/) |
| `No policy file yet` | You skipped Step 3 | Run `python unit23/model_policy.py --init` |
| `json.decoder.JSONDecodeError` | A policy file was edited and a comma or quote is missing | Run `--init` again to rewrite both files, then redo your edit |
| `KeyError: 'calder-aicore-x'` | A use case names an instance that isn't in `INSTANCES` | Use `calder-aicore` or `calder-aicore-eu`, or add the instance and its region |
| `Lifecycle dates taken ... for 0 model versions` | Your tenant's file lists none of the policy's models or versions | Check the file isn't an error message; compare `model` and `versions[].name` with `CATALOGUE` |
| `401` or `403` in `discovery.json` (Step 7) | Missing or expired token, or wrong resource group | Get a new token; check the `AI-Resource-Group` header |
| Network or proxy errors (Step 7 only) | Your network blocks the AI Core URL | Ask IT to allow it, or skip Step 7; the rest needs no network |

### The SAP way

On a real project, each part of the policy has a home in SAP's tools, as of 29 November 2026:

| Policy part | Where it lives in SAP | Watch out for |
| --- | --- | --- |
| Catalogue | Model discovery endpoint per tenant; SAP AI Launchpad's model library | The regional tables are best-effort; the endpoint is authoritative for your tenant |
| Lifecycle dates | `deprecated` and `retirementDate` in the endpoint; SAP Note 3437766 | SAP's page recommends marking the note as a favorite to be told when it changes |
| New models | SAP AI Core's What's New page | New entries point to SAP Note 3437766 for details |
| Enforcement | `modelFilterList` on an orchestration deployment | Applies to orchestration; direct deployments need role control |
| Versions | `modelVersion` in the deployment's configuration | A blank version means `latest` |
| Isolation and limits | Resource groups, quota APIs | Up to 50 resource groups per tenant; rate limits shared by default |
| Templates and configurations | Prompt registry, orchestration configurations | Version them with the model choice so a change is reviewable |

**SAP AI Launchpad.** The model library shows the catalogue with a catalog, leaderboard and chart mode, model cards with input types and cost information, and a deprecation icon on affected models; it needs one of the roles `genai_experimenter`, `genai_manager`, `genai_administrator` or `orchestration_executor` ([Model Library](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-launchpad/model-library-fce6fea.md)). It is a good place for a business owner to look at a model card before signing a change.

**Where the AI Core side is designed.** Instances, resource groups, tenancy and rate limits are the subject of the AI Core and AI Launchpad topic in this unit. How SAP meters and sells AI, including AI Units, is in [AI Units and SAP's commercial model](https://erpfde.com/topics/ai-units-and-commercial-model/); [model tiers and prices in late 2026](https://erpfde.com/topics/model-tiers-and-prices-late-2026/) covers the providers' own price changes.

> **Note** Creating restricted orchestration deployments, reading SAP Note 3437766 and requesting quota changes need a customer's SAP AI Core tenant on the extended plan and an S-user. SAP's 30-day trial is for exploring the hub; treat production settings as project tasks.

### Build vs. SAP

| Need | Use SAP's hub | Build or add your own |
| --- | --- | --- |
| Many providers behind one API | Orchestration's harmonized API | Only if you also need models the hub doesn't offer |
| Approved models only | `modelFilterList` allow list | A gateway in front, when non-SAP apps share the policy ([AI gateways](https://erpfde.com/topics/ai-gateways-for-model-and-agent-traffic/)) |
| Lifecycle tracking | Discovery endpoint and SAP Note 3437766 | A scheduled check like this topic's script, which SAP doesn't provide |
| Data class rules | Masking and filtering modules | The mapping from use case to data class is always yours |
| Owners and re-tests | Not provided | A register in Git or in your agent register ([AI Agent Hub](https://erpfde.com/topics/ai-agent-hub-and-governance/)) |
| Regional placement | Region of the AI Core instance; the matrices | A second instance per region where data must stay put |

### Architecture view

**Where it sits.** Calder's agents run on SAP BTP and in Joule Studio and call the hub through orchestration deployments in `calder-aicore` (US10, `calder-ai-prod`). Augsburg's invoice extraction, which handles `CP20` data, uses a second instance, `calder-aicore-eu`, in EU10, in line with the EU subaccounts of the [BTP account model](https://erpfde.com/topics/btp-account-model/). The nightly batch calls a model directly through the batch service, outside orchestration.

```mermaid
flowchart LR
  subgraph US10["US10: calder-aicore"]
    O1[Orchestration, allow list US]
    B[Batch, W07]
  end
  subgraph EU10["EU10: calder-aicore-eu"]
    O2[Orchestration, allow list EU]
  end
  AG[AGT_ORDER_EXC<br/>AGT_INV_TRIAGE<br/>AGT_SUPPLY_WATCH<br/>AGT_STAFFING] --> O1
  E[CP20 invoice<br/>extraction] --> O2
  O1 --> PR[Azure, AWS, Google,<br/>SAP-hosted models]
  O2 --> PR
  B --> AZ[Azure batch]
  POL[model_policy.py<br/>in CI] -.-> O1
  POL -.-> O2
```

**Non-functional requirements that decide the design.**

| Requirement | Typical target | What breaks if missed |
| --- | --- | --- |
| Data residency | EU-only data on `Yes` models in EU10 | A privacy finding; a transfer the contract doesn't cover |
| Continuity | No production version within 60 days of retirement | A use case stops on a fixed date |
| Availability | A fallback from another provider family | One provider's `429`s or outage stop the process |
| Change control | Every model change re-runs the use case's evaluation | A silent behavior change reaches users |
| Cost | Model choice per use case, priced from SAP Note 3437766 | A large model used where a small one would do |

**Integration and identity.** Applications reach the hub with the AI Core instance's service binding and a resource group header, so the hub sees the application, not the end user. User identity and authorizations are enforced before the call, in the agent and in SAP ([agent permissions](https://erpfde.com/topics/agent-permissions-and-sap-authorizations/)). The data class of a call follows the use case, so the register is where identity and data meet: which use case, run for whom, sends which class.

**The decision to record.**

- **Context:** Augsburg's supplier invoices hold `CP20` business data that Calder's privacy contact requires to stay in the EU. The partner's design used `gpt-5.4-nano` and `text-embedding-3-small` on the US instance's settings; SAP's matrix lists the first as unavailable in EU10 and the second as `Yes*`.
- **Options:** A run extraction on `calder-aicore` in US10 with the partner's models; B a second instance `calder-aicore-eu` in EU10 with models marked `Yes` there; C keep extraction in ECC until the July 2027 rollout without AI; D accept `Yes*` with a documented exception.
- **Decision:** B, with `gpt-5.4` as primary, `mistralai--mistral-small` (SAP-hosted, `Yes` in EU10) as fallback and the SAP-managed embedding model, enforced by a generated allow list.
- **Consequences:** A second instance to operate; models added to the hub reach Augsburg only after the policy approves them and the matrix shows `Yes` in EU10; the choice is re-checked against the tenant's catalogue at each policy review.

**What a design review will ask.**

1. Which data class does each use case send, and which approved models may receive it?
2. For each production call, which region serves it, and is any model `Yes*` where data must stay put?
3. Which versions are pinned, when does each retire, and who owns the move?
4. Is the default unrestricted orchestration deployment still reachable from production?
5. Which source and date does each provider's data terms record rest on?

### Production concerns

- **Security and authorizations.** Only the platform team creates deployments in production resource groups; developers use a development instance. The allow list closes the orchestration path, and role control closes the direct deployment path. Keep the AI Core service key in the binding, never in code ([BTP services and bindings](https://erpfde.com/topics/btp-services-and-bindings/)).
- **Evaluation.** Each use case has a frozen evaluation set; a model or version change runs it and needs the owner's sign-off, the same way as the [UAT and sign-off](https://erpfde.com/topics/uat-and-sign-off-for-ai-in-sap-programs/) gates.
- **Cost.** Approve the smallest model that passes the evaluation for each use case, and record why a larger one was chosen. Price changes by provider are tracked in [model tiers and prices](https://erpfde.com/topics/model-tiers-and-prices-late-2026/).
- **Operations.** Run the policy check in the pipeline on every change and on a weekly schedule, so a retirement date turns into a ticket months ahead. Watch for `429`s per model and resource group ([batch and observability](https://erpfde.com/topics/batch-and-observability-in-the-generative-ai-hub/)).
- **Data protection.** Inference observability can store requests and responses in your own object store; deleting the inference records doesn't delete what is stored there, which SAP leaves to you ([Deleting Inference Record Data](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/deleting-inference-record-data-637b8a8.md)). Put retention for that store in the policy.
- **Clean core.** The hub sits on BTP, outside S/4HANA. Model changes never touch the core, which is the point: they can be governed and rolled back on their own schedule.

### Where AI fits

Here AI is the subject, so the question is what it changes in governance. Models are the fastest-moving dependency in an SAP landscape: SAP's What's New page added supported models in most months of 2026, and model versions carry their own retirement dates. A governance process built for yearly releases misses that pace; a dated policy, a generated allow list and a scheduled check keep up with it. AI can also help run the policy, for example by drafting a change note from the catalogue's new entries, but a person decides what joins the approved list, and the allow list is generated from the policy file, not from a model's answer. Model choice by task is in [model selection and routing](https://erpfde.com/topics/model-selection-and-routing/); the program-level governance that this policy feeds is in [AI governance for SAP programs](https://erpfde.com/topics/ai-governance-for-sap-programs/).

### Pitfalls

- **An approved list without regions.** It lets a team design on a model the target region can't serve.
- **Reading `Yes*` as `Yes`.** For residency rules, the star is the whole point.
- **`latest` in production.** The deployment never breaks, and nobody notices that its answers changed.
- **Typing the allow list by hand.** It drifts from the policy; generate it.
- **Leaving the default orchestration deployment open.** The restricted deployment is only a control if callers can't use the unrestricted one.
- **A terms record without a date.** Nobody can tell when it was last true.
- **No owner per use case.** A retirement notice reaches the platform team, who can't judge whether the replacement is good enough.

### Exercise

Add a rule that keeps deprecated models off the approved list itself, and register a seventh use case.

1. Open `unit23/model_policy.py`.
2. Find the line `    # policy review date (course rule: 90 days)` in `check()`. Just above it, add:

   ```python
       # M11 nothing deprecated stays on the approved list
       for a in policy["approved"]:
           for v in a["versions"]:
               c = catalogue.get((a["model"], v))
               if c and (c["deprecated"] or (c["retirement"] and days(today, c["retirement"]) <= FAIL_DAYS)):
                   r.add("FAIL", "M11", f"{a['model']} {v}", "on the approved list but deprecated or retiring soon")
   ```

3. Run `python unit23/model_policy.py`. Check that a new line `FAIL  M11  gpt-4o 2024-05-13: on the approved list but deprecated or retiring soon` appears and the summary reads `64 OK, 2 WARN, 11 FAIL`.
4. Open `unit23/models/policy_reviewed.json`. In the `use_cases` list, after the closing `}` of `U06`, type a comma and paste:

   ```json
   {"id": "U07", "name": "Inspection lot summaries", "agent": "AGT_QM_WATCH", "owner": "00100326",
    "eval": "qm-lots-v1", "data": "D2", "instance": "calder-aicore", "residency": "",
    "api": "orchestration-v2", "masking": false, "primary": ["gemini-3.8-flash", "001"],
    "fallback": ["anthropic--claude-4.5-sonnet", "1"], "stage": "production"}
   ```

5. Run `python unit23/model_policy.py --policy reviewed`. Check that the summary reads `91 OK, 0 WARN, 0 FAIL` and that `model_register.md` has a `U07` row owned by quality engineer `00100326`.
6. Commit with the message `Unit 23: M11 and the inspection lot use case`.

**Done when:** step 3 shows the `M11` failure, step 5 passes with seven use cases, and the register lists `U07`. The register and the two allow lists go into the platform section of your capstone design pack.

### Check yourself

1. Which source does SAP call authoritative for the models your own tenant can use?
   - A. The regional availability tables in SAP's documentation
   - B. The model cards in SAP AI Launchpad's leaderboard view
   - C. The model discovery endpoint called in your tenant
   - D. The What's New page for SAP AI Core

   Answer: C. SAP says its regional tables are maintained on a best-effort basis and points to the discovery endpoint for the authoritative list. The policy check can read lifecycle dates from a saved discovery response.

2. What does modelFilterListType allow do on an orchestration deployment?
   - A. It refuses only the models named in modelFilterList
   - B. It accepts only the models and versions listed
   - C. It applies the list to every deployment in the tenant
   - D. It moves calls to the latest version of each named model

   Answer: B. With allow, only listed models and versions can be used through that orchestration deployment. A deny list does the opposite and lets new models in by default.

3. The allow list leaves out text-embedding-3-small for calder-aicore-eu, though the model is listed in EU10. Why?
   - A. The model isn't approved for D2 data in the policy
   - B. The model retires within the policy's 60-day review window
   - C. It is Yes* there and that instance holds EU-only data
   - D. Embedding models can't be restricted in orchestration

   Answer: C. `allowlist()` drops models that aren't plain Yes in the region when a use case on that instance requires EU residency. Yes* means the model may be served from another region.

4. A use case's deployment configuration has no modelVersion. What does the policy check report in production, and why?
   - A. OK, because a blank version is pinned to the first release
   - B. WARN, because SAP will ask for a version at deployment
   - C. OK, because orchestration chooses the cheapest version
   - D. FAIL, because a blank version means latest, untested

   Answer: D. SAP's lifecycle page says the version defaults to latest when none is given. The course rule M03 allows latest only outside production.

5. Calder's team creates a direct foundation-models deployment of a model that isn't approved. Which control catches it?
   - A. The allow list on the orchestration deployment
   - B. Role control over who creates production deployments
   - C. The rate limit set on the tenant for that model version
   - D. The data masking module in orchestration

   Answer: B. Model restriction is documented for orchestration deployments. A direct deployment bypasses orchestration, so only control over who may create deployments, plus the scheduled policy check, closes that path.

6. On 1 March 2027 the review fails U04 because gpt-4.1 retires on 14 April. Who should act, and how?
   - A. The platform team switches the job to latest so it keeps running
   - B. SAP moves the deployment to a newer version on that date
   - C. The use case owner tests a replacement on the evaluation set
   - D. The privacy contact renews the Azure terms record first

   Answer: C. The owner of `U04` judges whether a replacement is good enough on the frozen evaluation set, then the platform team patches the deployment with the new version. Switching to latest would move untested.

7. Why does Calder's policy require each fallback to come from another provider family?
   - A. Rules in SAP AI Core forbid two models from one provider
   - B. A capacity problem at one provider won't hit both models
   - C. Models from one provider can't share a resource group
   - D. SAP prices a second model from one provider higher

   Answer: B. SAP notes a `429` can come from provider capacity, not only from your quota. A fallback on another provider's infrastructure keeps the use case running when one provider is saturated.

## Sources

- [Model Availability by Region (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-availability-by-region-3794e87.md): read 2026-11-29 (repository last changed 2026-11-05); Yes, Yes* (available but may be accessed from a cross-regional location, for load balancing and failover) and No per model version and region; access types SAP-hosted, SAP-managed (SAP's tenant-isolated hyperscaler infrastructure) and remote; 'latest' moves you on deprecation and behavior can change; tables maintained on a best-effort basis, the discovery endpoint is authoritative; SAP Note 3437766 for pricing, retirement and rate limits. US10/EU10 values used here: gpt-5.4 Yes/Yes, gpt-5.4-nano Yes/No, gpt-4.1 Yes/Yes, text-embedding-3-small Yes/Yes*, anthropic--claude-4.5-sonnet Yes/Yes, gemini-3.8-flash Yes/Yes, mistralai--mistral-small 2603 Yes*/Yes, nvidia--llama-3.2-nv-embedqa-1b Yes/Yes, sonar Yes/Yes*
- [Feature Availability by Region (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/feature-availability-by-region-d8e5363.md): read 2026-11-29; features such as LLM orchestration, prompt registry, document grounding, LLM batch service, evaluation and prompt optimization listed Yes or No per region, best-effort; batch service No in every Asia Pacific region listed
- [Model Lifecycle (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-lifecycle-313fe25.md): read 2026-11-29; model versions have deprecation dates; a deployment that specifies a version stops working on that version's deprecation date; auto upgrade with modelVersion latest, manual upgrade by patching a deployment with a new configuration; latest is the default when no version is given
- [Model Restriction (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/model-restriction-4d499ee.md): read 2026-11-29; when creating a deployment for orchestration, restrict models with an allow or deny list to implement internal standards; parameter bindings modelFilterList (modelName, optional modelVersions; no versions means all) and modelFilterListType allow or deny; the text says parametersBindings, the sample uses parameterBindings
- [Supported Models (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/supported-models-509e588.md): read 2026-11-29; SAP Note 3437766 for token conversion rates, rate limits and deprecation dates; discovery endpoint GET $AI_API_URL/v2/lm/scenarios/foundation-models/models with AI-Resource-Group header; fields accessType, allowedScenarios, executableId, model, provider, versions[] with capabilities, contextLength, cost, deprecated, isLatest, name, retirementDate, streamingSupported; Azure OpenAI models through a private instance not publicly available
- [Rate Limit Management (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/generativeAI/rate-limit-management-6cbc230.md): read 2026-11-29; requests per minute per model per tenant, shared by all resource groups by default, all versions of a model share one limit; optional resource group limits; 429 can also mean provider capacity; GET /v2/admin/quota/model and POST /v2/admin/quota/requests (approval process); advice to isolate workloads in separate resource groups and use model fallbacks
- [What's New for SAP AI Core (SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/what-s-new-for-sap-ai-core-b7f76ad.md): read 2026-11-29; 2026-11-03: decommissioning of the deprecated orchestration V1 workflow API extended from 31 October to 31 December 2026; 2026-10-22: gpt-6.1-sol, gpt-6-astra, gpt-6-luna supported; 2026-09-29: Gemini 3.8 Flash; new-model entries point to SAP Note 3437766
- [Service Plans (SAP AI Core documentation, SAP-docs on GitHub)](https://github.com/SAP-docs/sap-artificial-intelligence/blob/main/docs/sap-ai-core/service-plans-c7244c6.md): read 2026-11-29; extended plan for production workloads with generative AI hub access, priced per resource plus model or token usage; no downgrade from extended to standard; up to 50 resource groups per tenant; supported regions in SAP Discovery Center
- [Responsible AI (sap.com)](https://www.sap.com/products/artificial-intelligence/ai-ethics.html): read 2026-11-29, no page date; SAP does not share customer data with third-party LLM providers for training their models; data sent to third-party hosted foundation models is processed only and not stored or retained by the provider; SAP may use customer data to improve its products where the agreement allows, with an opt-out in SAP for Me for new features; ISO/IEC 42001 covers Joule, SAP AI Core and SAP AI Launchpad
- [Data Residency and Digital Sovereignty for AI (SAP Learning lesson)](https://learning.sap.com/courses/building-confidence-in-ai-with-sap/data-residency-and-digital-sovereignty-for-ai): read 2026-11-29, no page date; residency depends on scenario design; generative AI processing may occur on SAP-managed infrastructure or approved external model providers; regional options subject to availability; EU AI Cloud keeps customer data within the European environment
