3 ms·
Copied from OpenAI's Jeff Harris on Twitter: 1) Upload your batch file curl https://api.openai.com/v1/files https://api.openai.com/v1/files -H "Authorization
by tedsanders 3y ago
Copied from OpenAI's Jeff Harris on Twitter:
1) Upload your batch file
curl https://api.openai.com/v1/files https://api.openai.com/v1/files
-H "Authorization: Bearer $OPENAI_API_KEY"
-F purpose="batch"
-F file="@batch_example.jsonl"
2) Create the batch job
curl --request POST
--url https://api.openai.com/v1/batches https://api.openai.com/v1/batches
--header "Authorization: Bearer $OPENAI_API_KEY"
--header 'Content-Type: application/json'
--data '{
"input_file_id": "file-DYJImtYAQ2y3j25b5F27Eefp",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'
3) Check the status of your job
curl https://api.openai.com/v1/batches/batch_f5Hh3MXaM0NNuTGOmutlSEmq https://api.openai.com/v1/batches/batch_f5Hh3MXaM0NNuTGOmutl...
-H "Authorization: Bearer $OPENAI_API_KEY"
4) Download the completed file!
curl https://api.openai.com/v1/files/file-Og2t4LcJOCqOFq6rmp22Uzke/content https://api.openai.com/v1/files/file-Og2t4LcJOCqOFq6rmp22Uzk...
-H "Authorization: Bearer $OPENAI_API_KEY" > batch_output.jsonl
- 999900000999 3y agoCool, not really looking to do this just yet, but it's definitely on my radar the next time I have a project. Would love an option to look up all my open jobs. I imagine doing this in a ci/cd pipeline or GitHub action. But I don't want to have to store state.
- barbazoo 3y agoPresumably that would be a curl --request GET --url https://api.openai.com/v1/batches https://api.openai.com/v1/batches but that doesn't seem to exist yet: https://platform.openai.com/docs/api-reference/batch https://platform.openai.com/docs/api-reference/batch
- 999900000999 3y agoBut it looks like you can upload files and list them. I'd just upload a file with the name Timestamp_batchID, and get the list of files later.
- silvacarl 3y agothis is crazy cool, will try it out shortly. i need to batch anaylze 100K whisper transcriptions. 8-)