Batch Priority

Prioritize certain batch jobs over others using the metadata field.

You can mark some batch jobs as higher priority than others. Priority is specified as an integer passed via the metadata field when creating a batch.

How It Works

  • Batches have a default priority of 0.

  • Set a higher number for higher priority. For example, a batch with priority 1 will be processed before a batch with priority 0.

  • Priority is passed as a metadata key-value pair: "PARASAIL_PRIORITY": "1".

Usage

Add the PARASAIL_PRIORITY key to the metadata field when creating a batch:

from openai_batch import Batch

with Batch() as batch:
    for i in range(100):
        batch.add_to_batch(
            model="NousResearch/DeepHermes-3-Mistral-24B-Preview",
            messages=[{"role": "user", "content": f"Prompt #{i}"}]
        )
    batch.submit(metadata={"PARASAIL_PRIORITY": "1"})

Notes

  • The metadata field follows the same format as the OpenAI Batch APIarrow-up-right. Up to 16 key-value pairs can be attached to a batch.

  • Priority values are integers. Higher numbers mean higher priority.

  • Batches without PARASAIL_PRIORITY set default to 0.

Last updated