Subject: Error: 'OpenAI' Object Has No Attribute 'batches'

When Creating Batch Jobs I’m encountering an error while attempting to create batch jobs using the OpenAI API. The code snippet below produces an AttributeError:

batch_input_file_id = batch_input_file.id

client.batches.create(
input_file_id=batch_input_file_id,
endpoint=“/v1/chat/completions”,
completion_window=“24h”,
metadata={
“description”: “nightly eval job”
}
)

The error message states: AttributeError: 'OpenAI' object has no attribute 'batches' .

What is the recommended approach for creating batch jobs in the current version of the OpenAI API?

The openai SDK module validates input. Not allowing you to send what it doesn’t know.

So you need to install a quite new version of software to try a feature released two weeks ago.

Or instead make your requests yourself with a https package so that using AI models isn’t a co-mingled locked-in mess.

2 Likes

Try %pip install --upgrade openai --quiet to install the new SDK