Batch API chat completion with Uploaded Files

I sent a batch request but the response says it cant do operations on uploaded files. I looked at the storage to view the batch response, batch request and the file uploaded. Everything checks out, the files are uploaded, the file id match but there is the response for the 2 batch prompt concerning 2 different files:

{"id": "batch_req_679989873a108190b6acb6aa255ff44f", "custom_id": "request-1", "response": {"status_code": 200, "request_id": "202b55e62546f97d58636f4347c8fe9c", "body": {"id": "chatcmpl-AurTRsD95NAPCrKNAqs549cMk7mav", "object": "chat.completion", "created": 1738115285, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "I'm sorry, I don't have access to external documents or systems to directly analyze specific files, including the one you've referenced with ID: file-6JjfdvLNJygZKpDnKRQwM6. However, I can assist you by explaining how you might manually extract the required metadata and format it into JSON if you can provide the content or details of the file. Alternatively, you can describe the document or provide snippets, and I can guide you on how to categorize it according to the rules provided.", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 2128, "completion_tokens": 107, "total_tokens": 2235, "prompt_tokens_details": {"cached_tokens": 0, "audio_tokens": 0}, "completion_tokens_details": {"reasoning_tokens": 0, "audio_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}}, "service_tier": "default", "system_fingerprint": "fp_50cad350e4"}}, "error": null}
{"id": "batch_req_679989874d348190a71203023414696b", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "821bc13a918b4a88cf2e93cf8384ee62", "body": {"id": "chatcmpl-AurUR7ciXnVqq34Jd4NJ7iys0O3cf", "object": "chat.completion", "created": 1738115347, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "I'm sorry, but I am not able to access specific files or perform actions on uploaded content directly. However, I can help guide you on how to analyze the document based on the metadata requirements and mappings you've provided. If you share the relevant information extracted from the document, I can assist you in formulating the JSON output as per your guidelines.", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 2128, "completion_tokens": 70, "total_tokens": 2198, "prompt_tokens_details": {"cached_tokens": 0, "audio_tokens": 0}, "completion_tokens_details": {"reasoning_tokens": 0, "audio_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}}, "service_tier": "default", "system_fingerprint": "fp_4691090a87"}}, "error": null}

Has anyone figured out how to get batch requested to work with uploaded files?

Hey there,

Thanks for reaching out! We understand you’re encountering an issue where your batch requests are not able to perform operations on uploaded files, despite the files being successfully uploaded and the file IDs matching.

1.Batch API Does Not Support File Access:

  • The Batch API does not currently support operations on uploaded files. Unlike standard API requests, batch jobs cannot retrieve or analyze files directly.
  • Even though the file_id is referenced in the request, the model cannot fetch or use the file in batch mode.
  1. Why is this happening?
  • The model isn’t able to “see” the uploaded file when using batch processing. This is a known limitation, as batch requests only process raw prompt data.
  • The response you received (e.g., “I don’t have access to external documents…”) is the expected behavior when attempting to use files in a batch job.

Workarounds & Recommendations:

Option 1: Use the Chat Completions API Instead

If file processing is required, use the Chat Completions API directly rather than batch processing.

json{"model": "gpt-4o","messages": [{ "role": "system", "content": "Process the uploaded file." },{ "role": "user", "content": "Analyze this file.", "file_ids": ["file-6JjfdvLNJygZKpDnKRQwM6"] }]}

This approach allows the model to access and process uploaded files as expected.

Option 2: Extract File Content & Pass as Input

If using batch processing is necessary, extract the file content separately and include it directly in the prompt.

Example workflow:

  • Extract relevant text from the uploaded file.
  • Include the extracted content inside the batch request as part of the prompt.

Our engineering team is aware of this limitation and is actively working to improve functionality. In the meantime, if you have any specific constraints or additional details about your use case, we’d be happy to help explore alternative solutions.

Let us know how we can assist further!

Best,

Rehema | openAI

Okay, thank you. Is there going to a an update in the future to allow this?

Hello,

We understand the importance of this feature and are working towards enhancing the Batch API to support file operations. However, we do not have a specific timeline for when this update will be available. Please stay tuned for updates on our API documentation and announcements.

Best,

Rehema | OpenAI