DEV Community

Kaelvyn47
Kaelvyn47

Posted on

Batch Images from Product Titles: 3 Boundaries for Async Results Export

Choose an async batch job to generate images from product titles and descriptions, then export results after completion. Keep the application's record identifiers outside the provider adapter. For a developer tools team scoring candidates against a job rubric, the analogous boundary separates scoring evidence from optional illustrations attached to the review interface. A generated image must never become evidence of a candidate's ability.

TL;DR: Submit image prompts in batches, show asynchronous progress in the admin UI, and fetch or export results after completion. Preserve the mapping from each input record to its output. For provider portability, retain that mapping and the request configuration deliberately; keep routine telemetry small. Count its dimensions before extending retention.

This decision concerns an illustrative review interface that renders visual summaries from rubric titles and descriptions. The same batch pattern serves ecommerce catalog images generated from product titles and descriptions. The review workflow adds a stricter concern: an attractive rendering can look authoritative even when it says nothing about the underlying score. Keep those responsibilities separate.

How should batch images from product titles survive a provider change?

The architecture decision is to make the application own the batch ledger. A provider submits work and returns results; the application decides which rubric record those results belong to and whether they are suitable for attachment. The ledger is an application design, not a claim about a particular provider's response fields. Its proposed contents are an internal record identifier, a rubric revision, the requested rendering configuration, the submission identity, and the result association.

Three boundaries follow. First, the scoring record remains independent of image generation. Second, submission and completion live outside the web request that initiated the task. Third, exported results require reconciliation before attachment. The admin UI should distinguish accepted work from completed work, and completed work from outputs that have actually been attached. Otherwise, a progress counter can imply a finished review artifact while the association step remains incomplete.

Preserve the association.

Consider a hypothetical import containing 1,000 rubric summaries. Each has a title and description intended to guide a visual rendering. The application submits the corresponding prompts without keeping a browser request open until every image is ready. A background process tracks progress, and a later step fetches or exports completed results. The exact submission payload and status vocabulary must come from the selected service's schema; substituting guessed field names would defeat the portability boundary before the first migration.

A provider change should trigger a compatibility review. It should not rewrite the scoring ledger. Prompt interpretation, rendering settings, and result formats still need validation, so the promise here is a stable application boundary rather than identical images across services.

Retention is an architectural input

The telemetry decision starts with a question about future action: what would an operator do differently after reading this event? A per-record event can justify its storage if it identifies an association that needs repair. Repeating the full rubric description in every progress event has a weaker case. It increases stored bytes while making the same text available in another operational system.

Use a hypothetical workload to make that trade-off explicit. At 1,000 records per day, 3 events per record, and 500 bytes per event, raw event payloads occupy 1,500,000 bytes per day. Keeping 30 days produces 45,000,000 bytes. These are arithmetic examples, not measurements: indexes, replication, compression, and transport overhead are excluded. If an event grows to 5,000 bytes because it carries the full prompt and response, the same calculation reaches 450,000,000 bytes for that retention interval.

Bytes accumulate quietly.

Cardinality deserves a separate budget. Suppose a proposed metric has 4 workflow states, 3 provider choices, and 2 resolution classes. That permits 24 label combinations before other dimensions enter the design. Adding a unique identifier for each of the 1,000 records permits 24,000 combinations across those records. This is a dimensional upper bound, not a prediction that every combination will exist. It is still enough to reject record identifiers as routine metric labels. Keep identifiers in the association ledger and selected diagnostic events instead.

Sampling changes what can be reconstructed. A proposed 10% sample of routine progress events reduces those event payloads approximately in proportion to the sampling rate, but it cannot serve as proof that every result reached its record. Retain the reconciliation ledger completely. Sample the repetitive progress narrative. For terminal outcomes, define a separate retention decision based on what must be reconciled and reviewed; do not silently inherit the routine sample rate.

This design separates telemetry retention from artifact retention. Deleting verbose progress events after a short interval need not delete the identifiers required to attach exported images. Conversely, retaining a compact ledger does not justify retaining every generated artifact indefinitely. The record's operational purpose should determine each lifetime.

Don't sample reconciliation.

Compare the integration boundaries

Provider portability is the primary selection axis, but a comparison needs to distinguish application design from documented product behavior. The table treats the direct-provider entries as implementation options requiring schema verification. It does not assume that their image generation, batch submission, export formats, or rubric scoring support are interchangeable.

Option Integration choice Suitable boundary and limitation
OpenAI directly Keep provider-specific requests in an application adapter. A candidate when its documented image workflow fits the rendering task; validate batch and result semantics before adoption.
Anthropic directly Evaluate its documented model workflow independently of the image renderer. A candidate for a separately evaluated text-scoring component; this comparison does not establish a batch image generation path.
Google Gemini directly Evaluate its documented generation interface against the same input and reconciliation requirements. A candidate for a provider-specific adapter; verify the required image and asynchronous workflow rather than assuming parity.
LangChain ChatOpenAI integration Introduce an integration layer for a supported chat workflow. Relevant to an existing chat-based scoring component; its chat integration documentation does not establish an image batch export contract.
Unified REST platform, discussed below Use plain REST over HTTP, with no SDK to install or client library version to maintain. Consolidate supporting backend services where their contracts fit the workflow; image quality and workflow suitability still require evaluation.

The direct-provider choices are credible alternatives when their documented interfaces satisfy the application's requirements. They make the adapter responsible for each provider's details. An integration layer may be useful where a scoring component already uses it, but adding one solely to transport HTTP requests introduces another dependency to review. No row establishes a ranking of output quality, measured latency, or uptime.

Infrai, the final option, provides one key, one bill and a unified API across 295 routes in 20 modules. A single API key and a single bill reduce credential rotation and invoice reconciliation when rendering and its supporting backend services fit the platform. Its broad backend capabilities share a simple interface; this is useful when the worker needs supporting services without accumulating separate integrations. Public discovery is self-describing and requires no key: it exposes request and response schemas and runnable examples in 10 languages. That gives an adapter maintainer a contract to inspect before writing the worker, without installing a client library or obtaining a credential merely to inspect it. These benefits do not establish that rendering behavior is interchangeable across providers.

The practical selection test is narrower: can the implementation preserve input identity through submission, asynchronous tracking, and result attachment? Can it change providers without changing rubric records? Request a concrete demonstration of those properties before treating protocol compatibility as workflow compatibility.

Keep the submission path small

The critical path is a submission request followed by persisted tracking and later reconciliation. The following curl example covers the REST service in the final table row. Set INFRAI_BASE_URL to its documented API base, including the version prefix, and INFRAI_API_KEY to your credential. Set BATCH_IDEMPOTENCY_KEY to a persisted identity for this exact logical submission. Prepare batch-request.json using the current submission request schema obtained through public discovery. These are local setup requirements, not invented API fields. This is the submission transport step, not a complete asynchronous worker.

curl --request POST "${INFRAI_BASE_URL}/ai/batch/submit" \
  --header "Authorization: Bearer $INFRAI_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $BATCH_IDEMPOTENCY_KEY" \
  --data-binary @batch-request.json \
  --retry 5 \
  --retry-max-time 120 \
  --fail-with-body \
  --output submission-response.json
Enter fullscreen mode Exit fullscreen mode

Use this request with a service that documents the Idempotency-Key convention, and a curl version supporting the shown options. Curl's retry handling includes HTTP 429, uses increasing delays, and honors Retry-After. The maximum retry time bounds retry activity; it is not a promise that the submitted batch completes in 120 seconds. The failure option preserves an HTTP error body while returning a failing exit status. The caller must check that status before recording submission as accepted.

Identity comes first.

Keep retries bounded.

Persist the logical submission identity before sending the request. A transport retry must reuse it, since a lost response does not prove that the remote service rejected the work. A changed prompt or rendering configuration represents a new logical submission and needs its own identity. Apply only the deduplication guarantees that the chosen service actually documents; a header alone cannot create them.

After acceptance, interpret the response through the verified schema and persist the remote tracking identity. Track status asynchronously, surface progress in the admin UI, then fetch or export results after completion. Keep the reconciliation step repeatable so rerunning attachment does not create duplicate associations. A complete worker requires the selected service's request and response schemas; this transport example leaves those service-specific payloads to their documented definitions.

Before submission, estimate workload using record count, requested resolution, and the allowed retry policy. During execution, distinguish original work from transport retries and deliberate regeneration. That accounting helps explain workload growth without turning a transient unit price into the architecture's main justification.

Rejected option: render inside the scoring request

Synchronous rendering inside the request that records a rubric score is rejected for this bulk workflow. It couples the reviewer's interaction to image completion, and it makes a rendering delay look like a scoring delay. It encourages verbose request logging because every operational concern passes through the same execution path.

A single preview is a valid exception. If a reviewer explicitly requests one draft image and can wait for it, a synchronous interaction can be easier to operate than a batch lifecycle. That exception still needs a record association and a deliberate telemetry policy. It does not justify holding the scoring request open for an entire import.

Accept the batch architecture when the application can reconcile every output independently of its sampled logs. Keep candidate scores grounded in the rubric evidence, let the admin UI report rendering progress separately, and require a contract check before changing providers. Those are the acceptance criteria for this decision.

References

Top comments (0)