Skip to main content

OpenaiBatchAPI: A Python Library that supports OpenAI Batch API

Project description

OpenaiBatchAPI: A Python Library that support OpenAI Batch API

OpenAI Batch API

Installation

You can install this package from PyPI using pip:

$ pip install OpenaiBatchAPI

Example

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
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

OpenaiBatchAPI-1.0.2-py2.py3-none-any.whl (4.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file OpenaiBatchAPI-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for OpenaiBatchAPI-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b0f97a808e16cfb1f182a085416e44644694bcff8a6510025989590a9a3877ec
MD5 b2ca8243489ee424a803147ac216da3d
BLAKE2b-256 9eb91a9e5905498cf4a52a79bfef9cadf77f6463eb0f3fed64c1eba510263baf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page