> For the complete documentation index, see [llms.txt](https://docs.parasail.io/parasail-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.parasail.io/parasail-docs/api-reference/batch-api.md).

# Batch API

Parasail's batch API is a direct drop-in replacement for OpenAI's batch API. The same documentation, guides, and client libraries apply.

## Base URL

```
https://api.parasail.io/v1
```

## Client setup

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.parasail.io/v1",
    api_key="<PARASAIL_API_KEY>",
)
```

## Key differences from OpenAI

* Use the Parasail URL instead of OpenAI's.
* Use your Parasail API key ([create one here](https://www.saas.parasail.io/keys)).
* Use an open source model from Hugging Face instead of ChatGPT.
* Up to **50,000 requests** and **1000 MB** per input file (vs OpenAI's 250 MB).

## OpenAI API reference

* [OpenAI Batch API reference](https://platform.openai.com/docs/api-reference/batch)
* [OpenAI Files API reference](https://platform.openai.com/docs/api-reference/files)

## Batch helper library

Parasail provides a Python batch helper library that simplifies batch submission and monitoring:

```bash
pip install openai-batch
```

See the [openai-batch GitHub repository](https://github.com/parasail-ai/openai-batch) and [batch full guide](/parasail-docs/products/quickstart.md) for details.

## Batch file format

The batch input file is a JSONL file where each line is a request. The format is 100% compatible with OpenAI. See [Batch file format](/parasail-docs/products/quickstart/file-format.md).

## Batch priority

Batches have a default priority of `0`. Set a higher priority by passing the `PARASAIL_PRIORITY` metadata key when creating the batch.

```python
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"})
```

Use priority sparingly for urgent jobs. Standard jobs should omit this metadata and use the default priority.
