The batch file
The input file is JSONL: one JSON object on each line, as in OpenAI's Batch API.
An input line
{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-oss-20b", "messages": [{"role": "user", "content": "Say hello."}], "max_tokens": 100}}custom_id- A text of your own that is not empty. It must be different on every line.
method- Always
POST. url- Always
/v1/chat/completions. body- A chat completion request. It needs
modeland amessageslist. Every line in a file uses the same model.max_tokensormax_completion_tokens, if you send it, is a whole number above 0.
An output line
The output file has one line for each request that worked. The error file has one line for each request that failed. Both files have the same fields, and exactly one of response and error is set. Use custom_id to match a result to your request.
{"id": "batch_req_…", "custom_id": "request-1", "response": {"status_code": 200, "request_id": "req_…", "body": {"id": "chatcmpl-…", "object": "chat.completion", "choices": [{"index": 0, "message": {"role": "assistant", "content": "Hello!"}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 9, "completion_tokens": 3, "total_tokens": 12}}}, "error": null}id- The ID of the result, starting
batch_req_. custom_id- The value from your input line.
response- Set when the request worked:
status_code,request_idandbody, which is the chat completion. error- Set when the request failed: a
codeand amessage. The codes are on the Errors page.