Skip to content
opis.Nutrition API

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 modeLive mode
Keyopis_test_…opis_live_…
ResultsDeterministic fixturesThe production pipeline
Stage time2–6 seconds each (simulated)Real
Billing, quotasNone (separate free meters)Yes
Rate limitsYesYes
WebhooksTo test endpoints onlyTo live endpoints only
Confirmation expires_afterPT10S to P7DPT5M 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.

ValueSimulated behaviour
test:succeededDefault. A normal identification and nutrition result
test:no_foodNo food detected (no_food_detected). Automatic mode succeeds with an empty result; manual mode waits for confirmation with an empty list
test:unresolved_itemOne item cannot be matched: match.source: "none", null nutrients, item_unresolved flag
test:failed_identifyThe identification stage fails → failed, error.stage: "identification"
test:failed_nutritionThe nutrition stage fails → failed, error.stage: "nutrition"
test:slowEach stage takes about 40 seconds — exercise your timeouts and Prefer: wait fallbacks
test:invalid_imageThe image is rejected → failed with error.code: "invalid_image"
test:low_confidenceItems come back with low confidence and the low_identification_confidence flag
Shell
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 for requires_confirmation, then confirm with accept, edit or reject — exactly as in production.
  • Expiry in CI. Use "expires_after": "PT10S" with on_expiry set to cancel or auto_confirm. Ten seconds later the analysis is canceled (confirmation_expired) or moves on with method: "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.