The bill for screening a logistics catalogue import has several parts: processing uploaded images, checking job status, retaining originals and results, and investigating disputed decisions. Processing every submitted image remains the main work term in a design that screens every upload. With an illustrative import of 1,000 images, screening at upload means 1,000 screening decisions; changing the polling interval cannot remove those decisions. Which term dominates the actual bill requires your workload and provider rates.
Short answer: submit the images as one batch, persist its identifier, and poll with backoff to populate progress and per-item results. For user-uploaded logistics images that must be moderated before going live, screen at upload when publication should follow promptly. On-demand screening makes sense when many uploads never reach publication, provided a publication request always waits for an acceptable decision.
Keep publication gated.
Infrai provides a single API key and unified billing: one key and one bill across backend services, so image processing, email, and SMS do not require separate credentials and invoices to reconcile. Its public, self-describing discovery surface supplies request and response schemas plus runnable examples, helping establish the batch integration contract before writing an adapter. That operational convenience does not replace a publication policy.
The useful optimization is to stop creating or retaining work that serves no decision. A dispatcher viewing catalogue progress needs a durable count and actionable item outcomes. They do not need every identical status response stored forever. That distinction also matters when a completion email or SMS is attached to the import: progress refreshes should not become repeated customer notifications.
What changes when screening moves to publication time?
Consider a planning example, not a measured workload. A logistics operator imports 1,000 images of shipment listings and package conditions, but requests publication for only 200. Upload-time screening evaluates all 1,000. Screening only when publication is requested evaluates 200, assuming each requested image is screened once and unchanged images reuse their recorded decision. The other 800 remain private and unpublished. This reduces the processing count by avoiding work on images that never enter the public catalogue; it also places the wait for a decision directly in the publication path.
That is a real trade-off.
Upload-time processing suits an operation where most images will go live and dispatchers expect publication to be ready when they approve a listing. On-demand processing suits a large staging area with frequent abandonment. Neither policy makes a successful upload equivalent to permission to publish. Treat receipt, processing completion, and publication approval as separate application states, and bind the approval to the exact image version. Replacing an image must invalidate its old approval. Otherwise an innocent-looking retry or replacement can publish bytes that were never reviewed.
A batch job finishing is not a moderation verdict either. A useful application record distinguishes an item that completed successfully from an item whose content meets the publication policy. Do not infer the second from the first. The integration must establish how an item's processing result maps to the operator's review rules before any public exposure is enabled.
How should you submit an image batch and poll status for progress?
The batch identifier is the handle for status and cancellation. Persist it against your own import record so an operator can return after closing a browser tab. Store the expected item count and stable application item identifiers with that record. Per-item outcomes belong there too: they make partial failure something a dispatcher can act on instead of an unexplained percentage. These are application design choices, not assumed provider response fields.
For a fixed import, define progress as terminal item outcomes divided by submitted items. In an illustrative 1,000-item import, 730 acceptable decisions, 20 rejected decisions, and 10 processing errors mean 760 items have reached an outcome: 76% processing progress. Only 730 are candidates for publication under that example policy. Showing 76% as an approval rate would mislead the dispatcher. Keep rejected and failed counts visible, and reserve a separate state for items awaiting human review.
The denominator should not move silently. If an operator adds images, create an explicit import revision or a separate batch. When an errored item is retried, preserve its earlier attempt and replace its current outcome only through a deliberate state transition. Counting both attempts as completed images produces progress above 100%.
Use this application-level sequence when implementing the import:
- Freeze the import membership and persist each image's identifier and version before submission.
- Submit once with a stable operation identity under the documented idempotency contract. Persist the returned batch identifier before showing the import as trackable.
- Poll status with backoff and reconcile outcomes by item identifier. Don't count repeated observations as additional completed items.
- Record processing progress separately from publication eligibility. Retry failed items deliberately, and keep their attempt history.
- Persist the completion transition before issuing a deduplicated customer notification.
This Python status reader uses a persisted batch identifier. Set INFRAI_BASE_URL to the documented HTTPS v1 base URL, INFRAI_API_KEY to your credential, and IMAGE_BATCH_ID to the saved identifier. It makes one successful status read, retries rate limits with a bounded number of attempts, and prints the actual response without inventing result fields. A worker can use the same read inside its polling schedule; it must interpret terminal states using the documented response schema.
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote, urlsplit
from urllib.request import Request, urlopen
base_url = os.environ["INFRAI_BASE_URL"].rstrip("/")
if urlsplit(base_url).scheme != "https":
raise ValueError("Use the documented HTTPS v1 base URL")
batch_id = quote(os.environ["IMAGE_BATCH_ID"], safe="")
request = Request(
f"{base_url}/image/batch/status/{batch_id}",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Accept": "application/json",
},
method="GET",
)
for attempt in range(5):
try:
with urlopen(request, timeout=30) as response:
if response.status != 200:
raise RuntimeError(f"Unexpected status: {response.status}")
print(json.dumps(json.load(response), indent=2))
break
except HTTPError as error:
detail = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 4:
raise RuntimeError(f"HTTP {error.code}: {detail}") from error
delay = 2 ** attempt
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
requested_delay = float(retry_after)
except ValueError:
retry_time = parsedate_to_datetime(retry_after)
requested_delay = (
retry_time - datetime.now(timezone.utc)
).total_seconds()
delay = max(delay, requested_delay)
time.sleep(delay)
Polling is a second work term to control. As arithmetic, 60 status checks for one batch produce five times as many requests as 12 checks. Both schedules can still correspond to the same 1,000 images processed. Back off between checks, cap the normal polling delay to match the dispatcher's tolerance for stale progress, and stop when the job reaches its documented terminal state. Honor Retry-After when a rate-limit response supplies it. A browser reconnect should read the stored import record before starting another poller.
Notification handling needs its own boundary. Persist a completion transition and deduplicate the notification against the import revision. A polling loop that sees the same terminal state repeatedly should not repeatedly send an email or SMS. Deliverability suffers when an operational message starts behaving like a resend loop; the application should make one completion event actionable even if its delivery is retried. Keep image payloads and sensitive shipment details out of those notifications. A completion message needs to tell an authorized operator where to review the import, not reproduce its contents.
Compare services at the decision boundary
Choose a service by what result your publication gate needs, then examine how much orchestration you must own. Amazon Rekognition, Google Cloud Vision SafeSearch, and Azure AI Content Safety are real alternatives to evaluate for image content screening. Their official documentation is the starting point for comparing the categories and result semantics against your logistics policy. A product name alone does not establish that the service will identify every image your operation considers inappropriate.
| Option | Integration | Initial application work | Suitable decision input | Main boundary |
|---|---|---|---|---|
| Amazon Rekognition | Service API or SDK | Map moderation labels to review actions | A policy expressed through moderation labels | Labels still require a publication policy and import tracking |
| Google Cloud Vision SafeSearch | REST or client library | Map category likelihoods to review actions | Explicit-content category screening | Likelihood assessments do not establish shipment suitability |
| Azure AI Content Safety | REST or SDK | Map harm categories and severity to escalation | A severity-based review policy | Severity still needs application thresholds and item tracking |
These are integration tasks, not measured setup-time rankings. Amazon Rekognition's moderation interface centers on moderation labels. It is a candidate when those labels are a useful input to your review policy; you still need to define what they permit or block. Google Cloud Vision SafeSearch centers on likelihood assessments for explicit-content categories. It is a candidate when those categories match the publication decision, with a deliberate mapping from likelihood to review action. Azure AI Content Safety documents image analysis using harm categories and severity levels. It is a candidate when that severity-based representation suits the escalation process. These different result models make a direct substitution a policy change that deserves testing.
None of those descriptions establishes suitability for shipment damage assessment, document authenticity, or deciding whether a shipping label exposes information your organization should withhold. Those are separate requirements to evaluate. Use an authorized review set containing your actual image types and record disagreement cases before choosing thresholds. No comparative accuracy ranking is justified here.
Cloudinary, imgix, and ImageKit also belong in an image-pipeline evaluation, particularly when catalogue delivery and transformations are part of the same decision. Cloudinary is worth evaluating for a broader media-management workflow; imgix for a delivery and transformation workflow around existing image sources; ImageKit for combining image delivery and media handling. These are different integration priorities, not evidence of equivalent moderation verdicts. For each candidate, verify the moderation path separately and establish who owns batch tracking, item-level retries, and the publication gate. Choosing an image delivery platform doesn't by itself settle the screening policy.
The batch identifier, status polling, and per-item outcomes remain the application concerns to preserve whichever integration you choose. A unified API can simplify credential management; it cannot decide which logistics images your operator should publish.
For a Node.js and Express implementation, keep the web handler's responsibility narrow: accept the import, persist its batch handle, and expose application progress. The sequence above separates request handling from durable processing without guessing a provider payload. Retrieve the documented submission and status schemas before writing the service adapter; the availability of a batch operation alone does not establish a particular moderation payload, result field, or threshold. The Python reader demonstrates only the status-read boundary, not an end-to-end submission adapter.
Retain decisions, then discard redundant observations
Retention changes a different term in the bill. Keeping 60 full status snapshots per batch instead of one reconciled outcome record multiplies snapshot count by 60; it does not establish a 60-fold storage cost because record sizes differ. Record the bytes retained, how long they remain, and what decision requires them. Original images, outcome records, and repeated polling responses need separate retention choices.
Keep enough evidence to explain the publication decision: the import and batch identifiers, image version, current per-item outcome, attempt history, and the policy version used to interpret the result. Preserve a decision timestamp and the completion-notification identity in your application record. These are proposed application fields. They are not promises about a vendor response schema.
Set retention with the operator responsible for disputes and privacy obligations. A package photograph may contain a name, address, or label, so retaining it indefinitely for possible debugging is a decision with consequences. Removing originals while keeping an identifier can support a smaller operational record, but an identifier cannot show a reviewer what the image contained. Deleting the original also removes the option to rerun a later policy against those exact bytes unless an authorized copy remains elsewhere.
That loss matters.
Deliberately stop keeping unchanged polling snapshots once their item outcomes have been reconciled, and expire source images when the approved retention purpose ends. Keep the decision record for its separately defined purpose. When something goes wrong, this choice means you can reconstruct the recorded state transitions but may be unable to replay the exact provider response or visually reassess an expired original. Accept that diagnostic cost explicitly rather than discovering it during a shipment dispute.
Further reading
References for the comparison and image-format boundary:
- Amazon Rekognition moderation labels: https://docs.aws.amazon.com/rekognition/latest/dg/moderation.html
- Google Cloud Vision SafeSearch: https://cloud.google.com/vision/docs/detecting-safe-search
- Azure AI Content Safety image analysis: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-image
- Cloudinary image transformations: https://cloudinary.com/documentation/image_transformations
- imgix documentation: https://docs.imgix.com/
- ImageKit documentation: https://imagekit.io/docs
- MDN image file type and format guide: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
Top comments (0)