So I have started using the Batch API recently and was wondering how we can grab the metadata associated with a created batch?
I have tried looking through:
client.files.list()
client.files.retrieve()
But neither seem to store this data?
So I have started using the Batch API recently and was wondering how we can grab the metadata associated with a created batch?
I have tried looking through:
client.files.list()
client.files.retrieve()
But neither seem to store this data?
There will be a file ID with polling the batch status.
client.batches.retrieve("batch_id_number")
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/completions",
"errors": null,
"input_file_id": "file-abc123",
"completion_window": "24h",
"status": "completed",
"output_file_id": "file-cvaTdG",
"error_file_id": "file-HOWS94",
...
You can then download the results file with the retrieve and retrieve content method.
The files endpoint has not a lot of useful metadata. The status is for fine-tuning job files uploaded.
myfile = "file-EhkRwdQ38WXPaPKsQNw4bexb"
from openai import OpenAI
client = OpenAI()
response = client.files.retrieve(myfile)
print(response.model_dump())
{'id': 'file-EhkRwdQ38WXPaPKsQNw4bexb', 'bytes': 3328, 'created_at': 1714155228, 'filename': '/mnt/data/randoms.txt', 'object': 'file', 'purpose': 'assistants_output', 'status': 'processed', 'status_details': None}