OhMyGPT
Batches

Create batch

POST
/v1/batches

Run the requests in an uploaded file asynchronously at the model's batch price, within 24 hours. Every line must use the same model. Creating the batch checks each line, then reserves the most the batch can cost from the balance. When the batch finishes it is charged once, for the requests that completed. Failed and cancelled requests are not charged. Without Idempotency-Key, each request creates a new batch, which is how the official OpenAI SDK calls it.

Authorization

ApiKeyAuth
headerAuthorization<token>

Header Parameters

Idempotency-Key?string

Retrying with the same key returns the batch it first created instead of creating another.

Lengthlength <= 255

Request Body

application/json
  1. body
completion_window*"24h"
Value in"24h"
endpoint*string

The endpoint every line of the file calls. Each line's url must match it.

Value in"/v1/chat/completions""/v1/responses""/v1/embeddings"
input_file_id*string

The id of a file uploaded with purpose set to batch.

metadata?

Up to 16 string pairs, returned on the batch. Keys are at most 64 characters.

Propertiesproperties <= 16

Response Body

The created batch, or the batch this Idempotency-Key created before

application/json
  1. response
completed_at?integer

Unix seconds.

completion_window*string
created_at*integer

Unix seconds.

endpoint*string
error_file_id?string

Read it with GET /v1/files/{file_id}/content.

errors?

Present when the batch could not start. Nothing is charged for such a batch.

expires_at?integer

Unix seconds. Set once the provider accepts the batch.

failed_at?integer

Unix seconds.

id*string
input_file_id*string
metadata*
object*"batch"
Value in"batch"
output_file_id?string

Read it with GET /v1/files/{file_id}/content.

request_counts*

completed, failed, and cancelled stay 0 until the batch is settled.

status*string

finalizing covers the provider's own finalizing step and the time OhMyGPT takes to settle the batch after the provider finishes. Results and final counts appear after it.

Value in"validating""in_progress""finalizing""completed""failed""expired""cancelling""cancelled"
Example Request
curl -X POST 'https://api.ohmygpt.com/v1/batches' \  -H 'Content-Type: application/json' \  -d '{  "completion_window": "24h",  "endpoint": "/v1/chat/completions",  "input_file_id": "string"}'
Example Response
{  "completed_at": 0,  "completion_window": "string",  "created_at": 0,  "endpoint": "string",  "error_file_id": "string",  "errors": {    "data": [      {        "code": "string",        "message": "string"      }    ],    "object": "list"  },  "expires_at": 0,  "failed_at": 0,  "id": "string",  "input_file_id": "string",  "metadata": {    "property1": "string",    "property2": "string"  },  "object": "batch",  "output_file_id": "string",  "request_counts": {    "cancelled": 0,    "completed": 0,    "failed": 0,    "total": 0  },  "status": "validating"}

Was this page helpful?

Still stuck? Live chat · [email protected] · Telegram group