Test mode & magic inputs
Every organization gets test mode from day one, before activation. Requests made with a test key
(opis_test_…) run the complete workflow — statuses, confirmation gate, expiry timers, webhooks,
usage — but stages are executed by a simulator that returns deterministic fixtures. Nothing reaches
the live engine or any AI provider.
| Test mode | Live mode | |
|---|---|---|
| Key | opis_test_… | opis_live_… |
| Results | Deterministic fixtures | The production pipeline |
| Stage time | 2–6 seconds each (simulated) | Real |
| Billing, quotas | None (separate free meters) | Yes |
| Rate limits | Yes | Yes |
| Webhooks | To test endpoints only | To live endpoints only |
Confirmation expires_after | PT10S to P7D | PT5M to P7D |
Test and live data are fully separate: a test key gets 404 for live resources and vice versa.
Magic inputs
Put a magic value in the meal analysis's description (or external_id) to choose a scenario. Any
other value behaves like test:succeeded.
| Value | Simulated behaviour |
|---|---|
test:succeeded | Default. A normal identification and nutrition result |
test:no_food | No food detected (no_food_detected). Automatic mode succeeds with an empty result; manual mode waits for confirmation with an empty list |
test:unresolved_item | One item cannot be matched: match.source: "none", null nutrients, item_unresolved flag |
test:failed_identify | The identification stage fails → failed, error.stage: "identification" |
test:failed_nutrition | The nutrition stage fails → failed, error.stage: "nutrition" |
test:slow | Each stage takes about 40 seconds — exercise your timeouts and Prefer: wait fallbacks |
test:invalid_image | The image is rejected → failed with error.code: "invalid_image" |
test:low_confidence | Items come back with low confidence and the low_identification_confidence flag |
curl https://platform.opis.health/v1/meal-analyses \
-H "Authorization: Bearer $OPIS_TEST_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"images": [{ "file_id": "file_01j9…" }],
"description": "test:failed_nutrition",
"confirmation": { "mode": "manual", "expires_after": "PT10S", "on_expiry": "auto_confirm" }
}'Test mode still validates your requests exactly like live mode — a bad body is still a 422, an image
still has to be a real JPEG, PNG or WebP — so a green test suite means your requests are well formed.
Testing confirmation and expiry
- Manual flow. Create with
"confirmation": { "mode": "manual" }, wait forrequires_confirmation, then confirm withaccept,editorreject— exactly as in production. - Expiry in CI. Use
"expires_after": "PT10S"withon_expiryset tocancelorauto_confirm. Ten seconds later the analysis iscanceled(confirmation_expired) or moves on withmethod: "auto_on_expiry". - From the console. The Analyses view lists test analyses waiting for confirmation with their deadlines, and offers Accept / Edit / Reject buttons so you can drive the flow by hand.
Going live
Create a live key in the same project once your organization is activated. Nothing else changes: endpoints, payloads, webhooks and error codes are identical. Remember to register live webhook endpoints too.