Sensitive data and managed AI

Lab: Managed inference, ZDR and PII redaction. PLO: PLO3 / PLO1. Points: 7.

Overview

The unit's AI captions and tags touch client media. A photo leaves the laptop, a transcript is pasted into a prompt, and a managed inference service returns a sentence. Somewhere in that trip a trust boundary is crossed — and the provider's responsibility does not cover what the unit chose to send.

The one big idea for this session: the model name is not the data policy — the endpoint is. One model id can be served by dozens of providers, each with its own retention and training terms. A governance rule therefore has to name the policy the serving provider endpoint must satisfy, not the brand the unit likes. The customer owns the prompt, the metadata, the data class and the retention decision, even when the model runs on someone else's hardware.

The scenario moment is the first AI pass over the catalogue: 100 synthetic caption requests and 20 photos are ready to send, and the question is not "which model is best" but "which endpoints may see this, and what must be removed first".

Lesson

What the service sees

A captioning call carries more than an image. It carries the prompt text, the image or its bytes, the file's metadata, the account identity and the model id. OpenRouter is a router: it accepts an OpenAI-compatible request with one API key and forwards it to one of the provider endpoints that serve that model. The endpoint — not the model brand — is the processor that sees the prompt and decides what it retains.

OpenRouter says it does not store prompts by default, but the provider behind the endpoint has its own policy, and those policies vary. The request can narrow the choice. A provider object can pin the endpoint (only), forbid silent substitution (allow_fallbacks: false), require zero data retention (zdr: true) and reject endpoints that may train on the data (data_collection: "deny"). Request-level settings combine with the account's privacy settings and can tighten them, never loosen them. "We only call an API" names the transport, not the boundary.

Data classes are contextual

A data class is public, internal, personal or sensitive. The class belongs to the asset and to the context: a colour-bar still is internal on its own, but the same file with GPS in its EXIF and a caption naming a student is sensitive.

PII is the identifier layer: a name, an email, a phone number, a student ID, a precise location. PDPA's sensitive categories go further — health, biometrics, political or religious belief, sexual behaviour, criminal record and the rest of s.26. The register uses the four classes; the law uses its own list, and the mapping is a judgement the unit has to write down.

Redaction and metadata stripping

Redaction removes or replaces identifiers before the data leaves the controlled environment: names from a supplied list, emails, phone numbers and student IDs by pattern. It is a control, not an anonymisation guarantee — a combination of otherwise benign details can re-identify a person, and a model can invent an identifier that was never there.

Metadata is the part students forget. A photo can carry GPS, device model, capture time and a thumbnail. Stripping EXIF removes those fields; the pixels are unchanged. The pipeline must strip before upload, and the evidence is the metadata diff, not a promise.

Retention, provider and model

A provider endpoint is one provider's route to one model. On 2026-11-13 the catalogue listed 48 endpoints for deepseek/deepseek-v4.1-flash-1017 and 7 for google/gemini-4-hydrogen. The ZDR preview, GET /api/v1/endpoints/zdr, listed 1,099 endpoints across the whole catalogue with zero-retention terms.

The counts are the lesson. Joining each model's endpoint list to the ZDR list on the endpoint tag leaves:

Model All endpoints ZDR-eligible Excluded from ZDR What it teaches
deepseek/deepseek-v4.1-flash-1017 48 42, all safety_retention: false StreamLake, GMICloud, AtlasCloud, Alibaba, Baidu, DeepSeek (first-party) The maker's own endpoint is not the safe one; "open weights" means many providers, each a separate policy.
google/gemini-4-hydrogen 7 4, all Vertex, all safety_retention: true all three Google AI Studio endpoints "ZDR" still has a safety-retention carve-out; strict ZDR-only removes the model entirely.

Two terms separate the rows. Zero data retention (ZDR) means the provider agrees to keep nothing after the request is served. safety_retention: true is a carve-out: the provider may still retain the request for safety review. So a ZDR row is not automatically a no-retention row. The rule has to say which of the two it accepts, for which data class.

The account setting ZDR only is stricter than a per-request zdr: true: it removes every endpoint with a safety-retention carve-out from the eligible set. That is why the same Gemini call succeeds under the default settings and fails closed under ZDR-only, while the DeepSeek call keeps working. The request cannot switch the account setting off; it can only add requirements.

Where the data goes

ZDR minimises retention; it does not create an in-region route. OpenRouter's in-region routing is offered in the EU and the US on Business and Enterprise plans; there is no in-region option in Asia, and the student plan has none at all. Processing therefore happens outside Thailand.

A cross-border transfer under PDPA s.28 needs a lawful basis and appropriate safeguards. This course does not rely on s.28 for real media: it sends only synthetic data, and says so in the rule. That is a design choice, not a legal opinion, and it is exactly the kind of residual risk the register must carry.

The governance rule

A workable rule has six parts and an incident path:

Part Question it answers Example
What may be sent Which data classes are allowed into the pipeline? Public and internal directly; synthetic sensitive only after parts 2 and 3; real personal or sensitive never
What must be removed Which identifiers and metadata are stripped? Names, emails, phones, student IDs; EXIF GPS, device and time
Which provider and model Which endpoint policy must hold? A model id from the ZDR list, with zdr: true, data_collection: "deny", no fallbacks; no training; safety retention only for synthetic data
Where it may go Which region and transfer basis apply? No in-region route in Asia; processing outside Thailand; s.28 not relied on for real media
How long it may stay What retention is acceptable? Zero days for personal, sensitive and synthetic data; safety retention only for synthetic
Who reviews Who checks the output and the exception? Sample 10% of captions; the data owner approves any exception in writing; keep the endpoint snapshot and key usage with the audit

Part 3 is what the old "model access" lesson becomes. "Use the best model" is not a rule; "use an endpoint from the ZDR list, reject training, and accept safety retention only for synthetic data" is.

The incident path is separate: stop the call, delete the output, rotate any exposed credential, tell the instructor, and add a register row. The register is where the rule meets reality.

PDPA and GDPR as questions, not recitals

PDPA is the binding frame for the cohort's own data: s.26 sensitive categories, s.19 explicit consent, s.28 conditions for a cross-border transfer, and ss.23/37 retention and erasure. Administrative fines reach THB 5M for sensitive-data breaches, and the data-subject access-request notification took effect on 14 September 2026.

GDPR is the comparison and the extraterritorial benchmark: Article 9 special categories, data-subject rights, controller/processor agreements and the Article 3(2) scope rule. ISO/IEC 27001 and SOC 2 are assurance artifacts — the way a provider proves its half of the boundary. The EU AI Act gets one slide: direction of travel, not a compliance exercise.

The useful habit is to turn each framework into a question: which article applies, what evidence would show compliance, and who owns the answer? A citation without a control is decoration.

The register

S7 seeded five rows for storage, identity and delivery; S8 adds five for inference and compliance. The ten rows are one register. Each row names the asset or process, the data class, the threat, likelihood and impact, the existing control, the residual risk with a clause of reasoning, the treatment and the owner.

Row Asset Threat Control
R06 Caption prompt at a third-party endpoint The endpoint retains or trains on the prompt Redaction; ZDR allow-list; zdr + data_collection: deny + no fallbacks
R07 Photo pixels in the request The image carries EXIF or a device/place link Strip EXIF before the call; diff as evidence
R08 Model id and serving endpoint The first-party endpoint is excluded and policies drift Snapshot the endpoint list; pin providers explicitly; re-check each offering
R09 Generated caption The output echoes or invents an identifier Sample review; no raw prompt stored
R10 Cross-border processing No in-region routing in Asia; data leaves Thailand Synthetic only; ZDR; s.28 not relied on

The two highest residual risks need a short written justification. That is where the responsibility claim becomes an argument: why this residual is acceptable, what would change it, and who accepts it. A register with ten rows and no reasoning is a spreadsheet, not a governance decision.

Check yourself

  1. What does the serving endpoint see when the unit sends a photo and a caption prompt, and which of those things is the customer's decision?
  2. Why is redaction not anonymisation? Give one example where redacted data can still identify someone.
  3. Your preferred model has 48 endpoints. Six are excluded from ZDR and one of them is the maker's own. Which endpoint would your rule allow, and what would you do if every allowed endpoint disappeared under ZDR-only?
สรุปภาษาไทย คำบรรยายและแท็ก AI ของหน่วยสัมผัสสื่อของลูกค้า ภาพหนึ่งออกจากแล็ปท็อป ข้อความถูกวางในพรอมต์ และบริการอนุมานแบบจัดการส่งประโยคกลับมา ระหว่างทางมีการข้ามขอบเขตความไว้วางใจ และความรับผิดชอบของผู้ให้บริการไม่ครอบคลุมสิ่งที่หน่วยเลือกส่ง แนวคิดหลักคือชื่อโมเดลไม่ใช่ข้อกำหนดข้อมูล แต่เป็น endpoint ของผู้ให้บริการที่ให้บริการโมเดลนั้น โมเดลเดียวมีหลาย endpoint และแต่ละแห่งมีนโยบายการเก็บรักษาและการฝึกโมเดลต่างกัน OpenRouter เป็นเราเตอร์ที่ส่งคำขอไปยัง endpoint ตามนโยบายที่ร้องขอ บนแดชบอร์ดวันที่ 13 พฤศจิกายน 2569 โมเดล DeepSeek มี 48 endpoint และ 42 แห่งอยู่ในรายการ ZDR ส่วน Gemini มี 7 endpoint และมีเพียง 4 แห่งที่อยู่ใน ZDR โดยทั้งหมดมี safety retention ซึ่งหมายความว่ายังเก็บข้อมูลเพื่อการตรวจสอบความปลอดภัยได้ การปิดข้อมูลลดความเสี่ยงแต่ไม่ใช่การทำให้ไม่ระบุตัวตน การลบ EXIF ต้องทำก่อนอัปโหลด ไม่มีเส้นทางในภูมิภาคเอเชียสำหรับโหมดของนักศึกษาจึงต้องใช้ข้อมูลสังเคราะห์เท่านั้น และทะเบียนความเสี่ยงคือที่ที่กฎพบความเป็นจริง
中文总结 媒体单元的字幕和 AI 标签会接触到客户媒体。一张图片离开笔记本电脑,文本被放进 prompt(提示词),托管推理服务返回一句话。途中跨越了信任边界,而提供商的责任并不覆盖媒体单元选择发送的内容。核心概念是:模型名称不是数据规格,而是提供该模型的提供商端点。同一个模型有多个端点,每个端点的保留和训练政策都不同。OpenRouter 是一个路由器,按请求的政策把请求送到端点。在 2026 年 11 月 13 日的仪表板上,DeepSeek 模型有 48 个端点,其中 42 个在 ZDR 列表中;Gemini 有 7 个端点,只有 4 个在 ZDR 中。它们全都有安全保留(safety retention),这意味着数据仍可能为了安全审查而被保存。关闭数据收集降低风险,但不是匿名化。删除 EXIF 必须在上传之前完成。学生模式在亚洲区域没有可用路径,因此只能使用合成数据。风险登记册就是规则与现实相遇的地方。

The inference boundary

A transcript and a photo pass through a redaction and EXIF-stripping gate; the redacted prompt and image cross a dashed boundary to OpenRouter, which routes to three endpoint tiers: zero data retention, safety retention, and retention and training; the clean call returns through a zero-retention endpoint, while the first-party endpoint and the safety-retention tier are refused or excluded.
Figure 8.1 — The inference boundary: the customer owns the prompt, the metadata and the policy requirement; OpenRouter routes to the endpoint that meets it. The model is not the policy — the endpoint is.

Reading the figure. The left side is the unit's side: a transcript and a photo, a gate that redacts identifiers and strips EXIF, and a rule panel. The dashed line is the trust boundary. On the provider side, OpenRouter routes the request to one of three endpoint tiers. The ZDR tier keeps nothing and has no safety-retention carve-out. The Safety Retention tier meets ZDR but may keep the request for safety review. The Retention and Training tier is excluded by the rule. The maker's first-party DeepSeek endpoint is in that last tier, which is why pinning the model's own provider is the deliberate failure. The rule names the tier it accepts; OpenRouter then chooses an endpoint inside it, and allow_fallbacks: false prevents a silent move to another tier.

Step Data class What crosses Customer control Provider control
Transcript Personal Text after redaction Name, email, phone and student-ID removal None before OpenRouter forwards it
Photo Sensitive Pixels after EXIF strip GPS, device and time removed Storage and model hosting at the endpoint
Prompt Internal Redacted prompt Prompt construction, no raw identifiers Endpoint policy: ZDR, safety retention, training, retention
Request — Model id and provider controls ZDR allow-list, zdr, data_collection, no fallbacks Routing and the serving endpoint's terms
Response Internal Generated caption Review sample, no raw prompt stored Model output, usage limits
Retention Sensitive Stored request or none Endpoint tier and account ZDR-only setting Retention period and human review

Prerequisite: The OpenRouter account and API key created in Session 6, and the course synthetic-media pack; never substitute real personal media. Set it up in Session 0: Accounts, Safe data.

Lab — Managed inference, ZDR and PII redaction

Time: 120 minutes — 10 setup, 10 snapshot and predict, 10 redaction, 5 EXIF, 10 calls A+B, 10 call C, 15 call D and the ZDR-only toggle, 5 rule, 15 register, 20 evidence, 10 teardown. Core 80, evidence 20, setup 10, teardown 10.

Prerequisite: the OpenRouter account and API key created in S6, the S7 register rows R01–R05, Python 3.14 with Pillow 11.3.0, curl, and jq. The shared synthetic pack is at ../../assets/synthetic-media/ — 20 EXIF-tagged photos and 100 transcripts with fabricated contact details. Do not substitute your own photos or transcripts.

You need to know: a managed inference call crosses a trust boundary. OpenRouter is a router: one model id is served by many provider endpoints, and each endpoint has its own data policy. A model's brand does not tell you what the serving endpoint retains. The ZDR list (GET /api/v1/endpoints/zdr) names the endpoints that meet zero-data-retention terms, and each row carries safety_retention. Your governance rule must name the policy the endpoint must satisfy, not just the model you like.

Safe-data acknowledgement: I have read the lab safe-data policy. I will use only the course-supplied synthetic media and will not upload real personal media to any cloud service.

Task

Predict which endpoints satisfy the governance rule, redact the 100 transcripts and strip EXIF from the 20 photos, then make four calls: a deliberate failure, the control that refuses it, a clean governed call, and a retention contrast that fails closed under ZDR-only. Finish by writing the six-part rule and the ten-row risk register.

Before you start — the panel checklist

These steps are panel-only; there is no CLI for them. Do them in the OpenRouter dashboard first.

  1. Settings → Credits: confirm the balance, turn auto top-up off, and top up to $10 if S6 left less. The purchase fee is 5.5% with a $0.80 minimum, so about $10.55 is charged. The top-up is reimbursed under the course account policy and stays yours for the capstone.
  2. Keys → Create key: name it course-s8-<your-id>. The key is shown once. Copy it, then close the dialog.
  3. Settings → Privacy: leave the training toggles at their course defaults for calls A–D. Two separate toggles control paid-model and free-model training. Do not change them yet; Step 6 changes ZDR deliberately so you can observe the effect.
  4. Settings → Privacy → ZDR: confirm the per-model-group ZDR control is visible. You will set ZDR only in Step 6.

The account and key are the ones S6 created. Do not create a second account.

Steps

1. Store the key and confirm the account

Write the key to a local .env file that is never committed. umask 077 makes the file private at creation; chmod 600 states the rule explicitly. Sourcing the file puts the key in the shell's environment without printing it.

umask 077
printf 'OPENROUTER_API_KEY=%s\n' '<paste-the-key-here>' > .env
chmod 600 .env
set -a; . ./.env; set +a

Create the results directory for this run's evidence.

export RESULTS=results
mkdir -p "$RESULTS"

Read the key's state into the evidence directory: usage, any limit, the remaining balance, whether the account is treated as free-tier, and the free-model daily allowance.

curl -sS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$RESULTS/key-before.json"
jq '{usage, limit, limit_remaining, is_free_tier, free_model_daily_requests}' "$RESULTS/key-before.json"

What to look for: usage is what has been spent, limit_remaining is the balance, and is_free_tier should be false after the top-up. Record this JSON as evidence item 2. Never photograph or paste the key itself.

2. Snapshot the catalogue — the prediction input

The endpoint list for the DeepSeek model. It returns every provider endpoint, with provider_name, tag, prices and status.

export SNAPSHOT_DIR=data
mkdir -p "$SNAPSHOT_DIR"
curl -sS https://openrouter.ai/api/v1/models/deepseek/deepseek-v4.1-flash-1017/endpoints -o "$SNAPSHOT_DIR/endpoints-deepseek.json"

The same list for the Gemini model.

curl -sS https://openrouter.ai/api/v1/models/google/gemini-4-hydrogen/endpoints -o "$SNAPSHOT_DIR/endpoints-gemini.json"

The ZDR preview: every endpoint in the catalogue that meets zero-retention terms, each with safety_retention.

curl -sS https://openrouter.ai/api/v1/endpoints/zdr -o "$SNAPSHOT_DIR/endpoints-zdr.json"

Your account's current model settings, before the ZDR-only toggle. It is account evidence, not a model list.

curl -sS https://openrouter.ai/api/v1/models/user -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$SNAPSHOT_DIR/models-user-before.json"

Tell the notebook where the fresh snapshots are and what date to stamp on them. The shipped copies in data/ are a dated fallback for offline work.

export S8_SNAPSHOT_DIR="$SNAPSHOT_DIR"
export S8_SNAPSHOT_DATE="$(date -u +%F)"

What to look for on 2026-11-13: 48 DeepSeek endpoints and 7 Gemini endpoints; the ZDR catalogue holds 1,099 endpoints across all models. Joining the model lists to the ZDR list by tag leaves 42 of 48 DeepSeek endpoints and 4 of 7 Gemini endpoints. DeepSeek's own first-party endpoint (tag: deepseek) is not in the ZDR list. Every Gemini ZDR endpoint is a Google Vertex endpoint with safety_retention: true, and all three Google AI Studio endpoints are excluded. These counts drift; the date travels with the evidence. The shipped data/endpoints-zdr.json keeps only the rows for these two models and records the full catalogue total, so the file stays small and does not publish other providers' endpoint names.

3. Redact and strip — make the controls executable

Run the supplied helper over the whole pack. It redacts every transcript, strips EXIF from every photo, and writes a report whose before/after counts are the evidence.

export RESULTS=results
python3 redact.py --pack ../../assets/synthetic-media --out "$RESULTS/redaction"

The project environment pins the same Pillow version in requirements-local.txt; the runner uses this equivalent so the version is reproducible.

uv run --with-requirements requirements-local.txt python redact.py --pack ../../assets/synthetic-media --out "$RESULTS/redaction"

What to look for: transcripts 100, pii_rows_before 100, pii_rows_after 0, photos 20, gps_before 20, gps_after 0, exif_tags_before 100, exif_tags_after 0. The report also carries one before/after transcript line. The redacted transcripts and stripped photos are working files; the report and the diff are the evidence. If a count is different, stop and fix the control before calling.

4. Predict, then apply the rule

Open notebook.ipynb in JupyterLab and run the cells in order. Step 1 joins the snapshots and prints the prediction table: provider, tag, prompt price per million tokens, whether the endpoint is ZDR, and its safety_retention flag. Step 4 turns the six-part rule into a function and checks the cases, including the maker's own endpoint and the Gemini carve-out.

What to look for: 48/42 for DeepSeek, 7/4 for Gemini, deepseek absent from the ZDR set, and every Gemini ZDR row safety_retention: true. The notebook asserts these, so a drifted snapshot fails loudly instead of quietly changing the lesson.

5. Make the four calls

The calls are made from the notebook, not the shell. The runner command below executes the same notebook headlessly; a learner using Jupyter runs the cells instead. Set the live flag only after the snapshots and the redaction exist.

test -n "${OPENROUTER_API_KEY:-}"
export OPENROUTER_LIVE=1
python3 run_notebook.py notebook.ipynb

The runner uses the pinned project environment and sends the artifact to results/.

S8_OUT="$RESULTS" uv run --with-requirements requirements-local.txt python run_notebook.py notebook.ipynb

The four calls the notebook makes are described here so you can read the request before you run it. A — the deliberate failure. The raw synthetic line is sent to DeepSeek's own endpoint, with no policy filter. The identifier is fabricated, but the provider sees it.

{
  "model": "deepseek/deepseek-v4.1-flash-1017",
  "messages": [{"role": "user", "content": "Summarise this synthetic caption request: Anan S. (anan.s@example.test, +66 000 000 001, student S0000001) approved the campus library clip."}],
  "max_tokens": 1200,
  "temperature": 0.2,
  "provider": {"only": ["deepseek"], "allow_fallbacks": false}
}

B — the control. The same request and the same pinned endpoint, with the policy enforced. DeepSeek's first-party endpoint is not in the ZDR list, so OpenRouter refuses before anything reaches a provider. The expected result is a 4xx with a "no endpoints match your data policy" message; on 2026-11-13 it was 404 No endpoints found matching your data policy (Zero data retention). Configure: https://openrouter.ai/settings/privacy. Record the exact status and body as evidence, and do not treat the refusal as an outage.

"provider": {"only": ["deepseek"], "zdr": true, "data_collection": "deny", "allow_fallbacks": false}

C — the clean governed call. The redacted text and the EXIF-stripped image, no provider pinned, policy enforced. The serving provider must be one of the 42 ZDR rows. Record provider, usage and the output.

{
  "model": "deepseek/deepseek-v4.1-flash-1017",
  "messages": [{"role": "user", "content": [
    {"type": "text", "text": "Describe this redacted caption request in one sentence. Do not include names, places or identifiers."},
    {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,<photo-01.stripped.jpg>"}}
  ]}],
  "max_tokens": 1200,
  "temperature": 0.2,
  "provider": {"zdr": true, "data_collection": "deny", "allow_fallbacks": false}
}

D — the retention contrast. The same clean payload on Gemini. Under the default settings, zdr: true routes to Vertex, whose ZDR still carries safety_retention: true, and the call succeeds. Record the serving provider and the flag.

"model": "google/gemini-4-hydrogen"

What to look for: A returns 200 and the provider sees the raw line; record whether the identifier appears in the output — a reasoning model may paraphrase or omit it, and the point is that it was sent. B returns 4xx with no provider; C returns 200 from a provider in the ZDR set; D returns 200 from Google with safety_retention: true. A reasoning model spends part of the token budget on hidden reasoning before its visible answer, so max_tokens is 1,200 rather than 100; a small budget can return an empty content with a finish_reason of length. The notebook writes every call, status, serving provider, usage and computed cost to inference_results.json. On this first live run the ZDR-only pair is still canned; Step 6 replaces it.

6. Flip the account to ZDR only and retry

Panel: Settings → Privacy → ZDR only for the Google model group and for "All other models". Refetch the account settings so the change is recorded.

curl -sS https://openrouter.ai/api/v1/models/user -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$SNAPSHOT_DIR/models-user-zdr-only.json"

Run the notebook again with the toggle marked. The ZDR-only pair is made live in this run; the four default calls are repeated too.

export OPENROUTER_ZDR_ONLY=1
python3 run_notebook.py notebook.ipynb

The runner's pinned-environment equivalent.

S8_OUT="$RESULTS" uv run --with-requirements requirements-local.txt python run_notebook.py notebook.ipynb

What to look for: D now fails closed with a 4xx, because every remaining Gemini ZDR endpoint carries safety retention and the account no longer allows it. On 2026-11-13 the refusal was the same 404 No endpoints found matching your data policy (Zero data retention) body as call B. C still succeeds, because all 42 DeepSeek ZDR endpoints are true ZDR (safety_retention: false). That pair is the retention part of the rule, observed rather than asserted. The retry reads the previous live artifact and keeps calls A–D, so the before/after pair survives in one file; it records zdr_only_source: live. If there is no previous live artifact, the notebook stops and tells you to run the default pass first.

7. Write the rule and complete the register

Revise data/governance-rule.json for your deployment. It has six parts — what may be sent, what must be removed, which endpoint and model, where it may go, how long it may stay, and who reviews — plus the incident path. The notebook evaluates the rule; it does not replace your judgement.

data/register.json carries the ten rows: R01–R05 from S7, R06–R10 for inference and compliance. Revise R06–R10 for what you observed, rerun the notebook to score the rows, and write 200 words justifying the two highest residual risks. Name what would change each judgement.

8. Verify the evidence

Run the verifier over the results directory. It checks the artifact, the snapshot counts, the refusal statuses, the serving provider, the cost ceiling, the register vocabulary and the secret scan.

bash verify.sh "$RESULTS"

The runner states which mode it expects; a canned artifact cannot pass a live check.

EXPECTED_MODE=live bash verify.sh "$RESULTS"

What to look for: verify OK and the printed totals. A non-zero exit is a failed run, not a warning.

9. Teardown

Record the balance after the calls. Keep it with the evidence; it proves the lab stayed inside the ceiling.

curl -sS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$RESULTS/key-after.json"
jq '{usage, limit_remaining}' "$RESULTS/key-after.json"

Delete the working copies of the redacted data and the stripped images. The reports and the evidence stay; only the regenerable files go.

rm -f "$RESULTS/redacted-transcripts.jsonl"
rm -rf "$RESULTS/photos"

Remove the local secret if you are not keeping the key for the capstone. If you are keeping it, leave .env in place and say so in the teardown log.

unset OPENROUTER_API_KEY
rm -f .env

Panel: confirm auto top-up is still off, record the remaining balance, and either keep course-s8-<id> for the capstone or disable the key. There is no cloud resource to terminate; the $10 top-up remains as credit.

Evidence bundle — ten items

  1. Account, key custody and the $10 top-up with the 5.5% fee — redacted, never the secret.
  2. GET /api/v1/key before and after: balance, limit, remaining balance and free-tier status.
  3. The redaction before/after pair and the EXIF metadata diff.
  4. The endpoint prediction table: all versus ZDR versus excluded, with safety_retention.
  5. Call A: the raw prompt, the serving endpoint and whether the identifier was echoed.
  6. Call B: the refusal status and body.
  7. Call C: clean output, serving endpoint, usage and computed cost.
  8. Call D: the Vertex route and safety_retention; the ZDR-only fail-closed result.
  9. The six-part rule and the ten-row register with the 200-word residual-risk justification.
  10. inference_results.json, the marked trust-boundary map, the 150–250-word note and the teardown log.

The bundle is scored 3/2/1/0 by the standard lab rubric. A fallback that changes the submitted shape is a defect; a fallback that substitutes a path is labelled item by item.

Failure and recovery

Call A is the deliberate failure: a synthetic identifier reaches a provider because the pipeline did not redact. Call B is the control refusing before anything leaves. D under ZDR-only is the control failing closed. The recovery is never a better prompt alone: redact, strip, enforce the policy, then choose an allowed endpoint. A refusal is recorded as evidence, not treated as an outage.

Cost ceiling

The four calls and the ZDR-only retry are under $0.01. DeepSeek starts at $0.03 per million input tokens on its cheapest ZDR endpoint and Gemini at $1.50–$2.70 per million input tokens, with a small image and a short prompt. The lab ceiling is $0.10; the notebook computes the cost from usage multiplied by the serving endpoint's prices and asserts it. The $10 top-up plus the fee is account funding, reimbursed separately, and remains yours for the capstone.

Fallback

If the card top-up is blocked, the instructor demo key runs A–D and you keep the same evidence shape. If the API is blocked entirely, the dated snapshots and canned-inference.json carry the prediction, redaction, rule and register cells, and the four calls are marked not run rather than fabricated. The notebook's mode field says canned or live; never present a canned run as live.

Reference run

The agent-run reference sequence is run.sh; the learner still types the commands above. The runner is the verified record of the same steps, not a substitute for them. It provisions no cloud resource, so there is nothing to terminate.

The runner checks the pinned environment first.

uv run --with-requirements requirements-local.txt python --version
uv run --with-requirements requirements-local.txt python -c 'import PIL; print("Pillow", PIL.__version__)'

Run the offline path, then the live path with the key in the environment, then the ZDR-only retry after the panel toggle.

MODE=canned bash run.sh
MODE=live bash run.sh
REFRESH=1 MODE=live bash run.sh
MODE=live ZDR_ONLY=1 bash run.sh
EXPECTED_MODE=canned bash verify.sh "$RESULTS"

Notebook

Open the lab notebook. Step 1 predicts the endpoints, Steps 2–3 redact the pack and strip EXIF, Step 4 applies the six-part rule, Step 5 makes calls A–D, Step 6 prices them, Step 7 scores the register and Step 8 writes inference_results.json. The runner's verified command sequence is in COMMANDS.md; the learner types the commands in this brief, not the runner.

Downloads for this session

Each document name opens a rendered view you can read in the browser. The download link beside it gives you the raw Markdown working file: the copy you edit, run and submit. The page above and the lab steps carry the teaching.

lab.md download lab.md
The numbered lab brief: the steps, the commands and the evidence you submit.
refs.md download refs.md
The reference list behind this session's claims.
PLO.md download PLO.md
This session's scoring rows and descriptors.
download notebook.ipynb
The runnable notebook that produces the lab's numbers.

Research question

What governance rule should apply when a managed inference API sees sensitive media or its metadata?

Submit an 800–1,200 word answer with 5–8 sources at the next session. The rubric and the exemplar guidance show the expected shape.

References — Session 8

  1. Tramèr, F., Zhang, F., Juels, A., Reiter, M. K., & Ristenpart, T. (2016). Stealing machine learning models via prediction APIs. Proceedings of USENIX Security '16, 601–618. https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/tramer
  2. Shows that an inference API leaks information about the model and its training data, so "we only call an API" is not a privacy boundary. Model-extraction cost for large media models and the effectiveness of provider-side rate limits are still open. No essential figure.
  3. Shokri, R., Stronati, M., Song, C., & Shmatikov, V. (2017). Membership inference attacks against machine learning models. 2017 IEEE Symposium on Security and Privacy (SP), 3–18. https://doi.org/10.1109/SP.2017.41
  4. A concrete test of whether a model memorised a sensitive item — the risk the governance discussion is about. Membership privacy for fine-tuned media models and diffusion models is still poorly understood. No essential figure; draw a data-flow diagram instead.
  5. Al-Rubaie, M., & Chang, J. M. (2019). Privacy-preserving machine learning: Threats and solutions. IEEE Security & Privacy, 17(2), 49–58. https://doi.org/10.1109/MSEC.2018.2888775
  6. A readable map of threats and defences that lets students place a managed service in the landscape. Practical privacy for media pipelines — faces, voices and location metadata — is under-served by generic ML privacy work. The threat/solution matrix can be rebuilt as a table.

Teaching note. Narrate Tramèr et al. (2016) for 5–8 minutes, assign the abstract of Shokri et al. (2017) as reading, and close by restating the open problem as the weekly question. Figures are third-party; redraw by default.

PLO — Session 8: Sensitive data and managed AI

CLO: By the end of this session, the student can trace sensitive media and metadata across an OpenRouter inference boundary, write a governance rule for what may be sent to an endpoint, and defend the residual risk in a ten-row register.

PLO Role Research answer Lab evidence Points Evidence Rubric
PLO3 primary 4 3 7 An 800–1,200-word governance-rule answer with 5–8 sources; the redaction and EXIF diffs, the endpoint prediction, the four calls, the marked trust-boundary map, the rule and the ten-row register with justification Research 4/3/2/1; Lab 3/2/1/0
PLO1 secondary 0 0 0 Lecture context only; not scored —
Total 4 3 7

Total: 7 points

Four-level descriptors

Research (4/3/2/1). 4 = a rule that names what may be sent, what is removed, where it may go, retention and review; applied to the captioning pipeline with the endpoint and retention choice justified; maps the rule to PDPA/GDPR and one register row; weighs the counterargument that retention and provider terms can change. 3 = a sound rule with most parts and an application, one part thin. 2 = describes the risks without writing a rule or applying it. 1 = a summary with fewer than five sources. 0 = nothing submitted or misconduct.

Lab (3/2/1/0). 3 = all identifiers are redacted, all EXIF is stripped and the diff shown, the rule is applied and the four calls are recorded with model, endpoint and retention, the map is marked, the ten-row register is valid and the top risks are justified, and teardown and cost are respected. 2 = mostly complete, one check thin. 1 = partial redaction/stripping, an incomplete register or no teardown. 0 = nothing submitted, real personal data, or no teardown.

The full course arithmetic is in production/baseline.md; this file is the weekly instance.