← Blog

OpenAI Batch Completion Window Policy for Production Jobs

Parminder Singh
Parminder Singh··6 min read
Summarize with AI

An OpenAI Batch completion window policy should accept the currently supported 24h value, calculate an earlier application deadline, and keep provider expiry separate from the business cutoff. This guide defines admission checks, retained timestamps, expiry handling, and tests for production Batch jobs.

Platform & Architectureai-securityllm-securityarchitecturedevsecopspolicy-enforcementaudit
OpenAI Batch Completion Window Policy for Production Jobs

OpenAI currently accepts only 24h for the Batch API completion_window. That provider setting does not promise that a result will arrive before an internal or customer deadline.

A production policy needs two clocks: OpenAI's documented processing window and an earlier application cutoff that leaves time for retrieval and validation before results are applied.

I would reject a batch at admission when those clocks do not fit. Hope is not a scheduling policy. An overnight job should not start unless the business deadline can survive.

TL;DR

  • Send the literal 24h completion_window because that is the only value OpenAI currently supports.
  • Calculate a separate local deadline that leaves time for result retrieval, validation, and downstream work.
  • Persist created_at and expires_at alongside status timestamps and the business cutoff without treating them as interchangeable.
  • Define explicit branches for every terminal state before submitting production work, including completion, failure, cancellation, and expiry.

The provider window and the business deadline are different clocks

OpenAI's current Batch API guide describes a 24-hour turnaround. Its status reference says an expired batch was not completed within that 24-hour window.

The Create batch reference is narrower at the request boundary: completion_window currently supports only the literal value 24h.

Those statements define provider behavior. They do not say that a batch submitted at 18:00 will satisfy a finance export due at 07:00 the next morning, nor do they reserve time for your worker to download files, verify every custom_id, validate response schemas, and commit approved results.

Set an application cutoff first. Then subtract the worst-case time required for retrieval and reconciliation, plus an operational buffer. The latest permitted submission time follows from that calculation.

This is a recommended local policy, not an OpenAI requirement.

For example, a team may need reconciled rows by 09:00 and reserve two hours to download and validate them before controlled writes. Its internal result-ready cutoff becomes 07:00.

The request body may contain 24h. That alone cannot prove the job will meet the cutoff.

The OpenAI Batch custom ID correlation guide covers the manifest needed to account for every submitted row after the provider finishes processing.

Admission policy should fail before upload

Apply the window decision while the JSONL file is still local.

The admission record should name the intended submission time and provider completion-window value. It should also retain the business deadline, result-processing allowance, and calculated latest start time.

Reject any supplied value other than 24h under the current API contract. Do not silently replace 12h, 48h, or a missing value.

A corrected request can enter a new admission check with a new decision record.

Next, reject work whose latest start time has passed. This prevents an upload from creating a provider-side artifact for a job your scheduler already knows cannot meet its local objective, while giving operators a precise reason such as business_window_insufficient instead of a vague late-job alert.

Keep the file checks separate from the schedule check. Endpoint equality and one-model validation need their own findings.

Record request-body validation separately from line count and file size. The Batch endpoint match validation guide explains that preflight boundary.

One blunt rule helps here: urgency never expands the provider contract.

A job that needs results in 40 minutes belongs on a synchronous path or a different approved workflow. Changing a local label from overnight to urgent does not change what 24h means.

Record timestamps without inventing precision

The Batch object exposes created_at, expires_at, and optional timestamps for transitions including in_progress_at, finalizing_at, completed_at, failed_at, expired_at, cancelling_at, and cancelled_at.

Retain the values OpenAI returns under their original field names.

Do not derive a promised completion instant from a dashboard observation or from the time your queue worker began preparing the file. Use the provider fields for the provider lifecycle and your own timestamps for local events.

Useful local fields include the admission and upload times. Add the create-request time, latest acceptable result, first successful retrieval, reconciliation finish, and downstream commit as separately named fields.

Record clock source and timezone for local deadlines.

Human labels such as "end of day" or "overnight" do not belong in an executable policy. Convert the approved schedule to an unambiguous timestamp before admission, while preserving the business timezone as context.

Polling time is observation time, not transition time.

If a worker sees completed at 06:12, the Batch object's completed_at remains the provider's completion field. The 06:12 poll belongs in a separate retrieval event.

This separation gives an incident reviewer a plain sequence rather than one overloaded finished_at value whose meaning changes across services.

Expiry needs a planned application outcome

A Batch that reaches expired needs a terminal provider disposition and an application decision.

OpenAI's guide documents batch_expired error records for requests that did not complete inside the window. Preserve those records and reconcile them against the immutable input manifest.

Do not convert every missing row into batch_expired.

Download the available output and error artifacts, then count identifiers against the provider request totals. Any rows that remain unexplained need investigation. The Batch error file reconciliation guide sets out that accounting pass.

Retry is a new submission decision. It needs a new batch ID and a current deadline calculation tied to the approved input artifact, plus protection against repeating downstream effects for rows that already succeeded.

An expired parent batch does not grant automatic permission to submit its remaining work again.

Cancellation deserves its own branch.

OpenAI documents cancelling and cancelled states and notes that cancellation can take up to 10 minutes. A local deadline breach may trigger a cancellation request, but partial results can still exist and still require reconciliation.

Output-file retention is another clock.

The Batch creation reference lets clients configure generated output and error file expiry from one hour to 30 days, measured from file creation. That retention policy does not extend the 24-hour processing window.

Set retrieval alerts early enough that successful results do not disappear before verification.

Test the policy at both sides of the cutoff

A useful release fixture uses a fixed clock.

Give the policy a business deadline, a result-processing allowance, and two proposed submission times. Place one time one second before the latest permitted start and the other one second after it.

The first candidate should pass schedule admission when its completion-window value is exactly 24h and its other preflight checks pass. The second should fail without uploading a file or creating a batch.

Repeat the test with 12h, 48h, an empty value, and different capitalization. Each should receive a named rejection rather than coercion.

Then replay representative Batch objects for completed, failed, expired, cancelling, and cancelled.

Confirm that the state handler preserves provider timestamps, writes a distinct local observation time, and chooses only the application actions approved for that state.

The last test should return completed_at before the provider expiry but after the business result cutoff. The policy should record provider completion and a missed local objective at the same time.

Calling that batch expired would be false. Calling the business schedule successful would also be false.

DeepInspect

DeepInspect can apply identity-aware policy when an application deliberately routes authenticated OpenAI file-upload and Batch-creation HTTP calls through its proxy. It can record the acting user or agent and route, along with the supplied classification, policy version, and allow or deny result for those exchanges.

The application owns the business deadline calculation and scheduler. It also owns polling, artifact retrieval, row reconciliation, retry decisions, and downstream writes.

DeepInspect does not make a provider batch finish within a shorter window. Direct OpenAI traffic that bypasses the routed path remains outside its visibility.

Join the DeepInspect decision ID to the local admission record so the submission authorization and schedule decision can be reviewed together.

Book a demo today.

Frequently asked questions

Can I set completion_window to less than 24 hours?

The current OpenAI Batch creation schema does not support a shorter value; it accepts only 24h.

If your application needs a shorter turnaround, use a route and capacity plan designed for that requirement. A local 2h label cannot narrow the provider's documented Batch window.

Does 24h guarantee my downstream job finishes within 24 hours?

The 24-hour setting applies only to Batch processing.

Your application still needs time to observe the state, retrieve artifacts, reconcile rows, validate results, and complete authorized downstream writes. Calculate a separate business cutoff and reserve time for those steps before admitting the batch.

Should an expired batch be retried automatically?

Not without a new policy decision.

First reconcile successful and failed rows, identify unresolved work, and check whether a new submission can still meet its deadline. The retry should receive a new batch ID and admission record.

Downstream idempotency controls must prevent already completed rows from producing a second effect.

Is expires_at the same as output file retention?

The expires_at field and output-file retention represent separate lifecycle clocks.

The Batch object uses expires_at for its processing lifecycle. Generated output and error files have a separate expiry policy, configurable through output_expires_after within the documented range.

Store those clocks in separately named fields. Alert on each for its own purpose.