Hi forum, I’m following the batch api documentation to process my translation tasks. It’s all good until I was trying to retrieve the processing results. When I run the code “file_response = client.files.content(batch_input_file_id)”, I didn’t retrieve the results but my input instead.
May I know if anyone got into the same trouble?
Hi there and welcome to the Forum!
It looks like you are using the input file ID and not the output file ID in your request. That would explain the issue.
You can obtain the output ID by listing your submitted batches:
from openai import OpenAI
client = OpenAI()
client.batches.list()
{
"object": "list",
"data": [
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-abc123",
"completion_window": "24h",
"status": "completed",
"output_file_id": "file-cvaTdG",
"error_file_id": "file-HOWS94",
"created_at": 1711471533,
"in_progress_at": 1711471538,
"expires_at": 1711557933,
"finalizing_at": 1711493133,
"completed_at": 1711493163,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": {
"total": 100,
"completed": 95,
"failed": 5
},
"metadata": {
"customer_id": "user_123456789",
"batch_description": "Nightly job",
}
},
{ ... },
],
"first_id": "batch_abc123",
"last_id": "batch_abc456",
"has_more": true
}
2 Likes