Metadata-Version: 2.1
Name: OpenaiBatchAPI
Version: 1.0.2
Summary: OpenaiBatchAPI: A Python Library that supports OpenAI Batch API
Home-page: https://github.com/it-dainb/batch_api.git
Author: IT.DAINB
Author-email: it.dainb@gmail.com
License: Apache License 2.0
Keywords: openai batch_api batch api
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8, <=3.12
Description-Content-Type: text/markdown
Requires-Dist: uuid
Requires-Dist: orjsonl
Requires-Dist: openai
Requires-Dist: tqdm

# OpenaiBatchAPI: A Python Library that support OpenAI Batch API
[OpenAI Batch API](https://platform.openai.com/docs/guides/batch)

## Installation

You can install this package from PyPI using [pip](http://www.pip-installer.org):

```
$ pip install OpenaiBatchAPI
```

## Example

```python
from openai_batch_api import OpenaiBatchAPI

batch_client = OpenaiBatchAPI(api_key = "YOUR_KEY")

messages = []

# For custom ID 
for i in range(23):
    messages.append(
        {
            "id": f"calc_{i}",
            "content": [
                {
                    "role": "user",
                    "content": f"Calculate:  1 + {i} = "
                }
            ]
        }
    )

# For auto ID (ID will be the index of the message in the list)
for i in range(23):
    messages.append(
        {
            "role": "user",
            "content": f"Calculate:  1 + {i} = "
        }
    )


batchs = batch_client.batchs_completion(
    messages, 
    max_completion_tokens=32,
    model="gpt-4o-mini",
    temperature=0,
    seed=42
)
