by tedsanders · 2y ago · 0 comments
1) Upload your batch file
curl 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 --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_f5Hh3MXaM0NNuTGOmutl... -H "Authorization: Bearer $OPENAI_API_KEY"
4) Download the completed file!
curl https://api.openai.com/v1/files/file-Og2t4LcJOCqOFq6rmp22Uzk... -H "Authorization: Bearer $OPENAI_API_KEY" > batch_output.jsonl
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.
curl --request GET --url https://api.openai.com/v1/batches
but that doesn't seem to exist yet: https://platform.openai.com/docs/api-reference/batch
I'd just upload a file with the name Timestamp_batchID, and get the list of files later.
i need to batch anaylze 100K whisper transcriptions. 8-)