Batch

Create Batch

Create a batch task. You need to first upload a JSONL file with purpose="batch" via the Files API, then use the returned file_id to create the task.

post/v1/batches

Request

  • Base URL: https://api.moonshot.ai
  • URL: https://api.moonshot.ai/v1/batches
  • Auth: HTTP bearer

Request body

input_file_idstring required

ID of the input file, must be a .jsonl file uploaded with purpose="batch"

endpoint'/v1/chat/completions' required

Request endpoint, currently only /v1/chat/completions is supported

completion_windowstring required

Time window for task processing, supports formats like 12h, 1d, 3d, minimum 12h, maximum 7d

metadataobject

Custom metadata, up to 16 key-value pairs, key max 64 chars, value max 512 chars

Response

The created batch task

idstring required

Unique identifier for the batch task

objectstring required

Object type, always batch

endpointstring required

Request endpoint

input_file_idstring required

Input file ID

completion_windowstring required

Processing time window

status'validating' | 'failed' | 'in_progress' | 'finalizing' | 'completed' | 'expired' | 'cancelling' | 'cancelled' required

Current status: validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled

output_file_idstring nullable

Output file ID for successful results

error_file_idstring nullable

Error file ID for failed results

created_atinteger required

Creation timestamp (Unix)

in_progress_atinteger nullable

Execution start timestamp (Unix)

expires_atinteger nullable

Expiration timestamp (Unix)

finalizing_atinteger nullable

Result preparation start timestamp (Unix)

completed_atinteger nullable

Completion timestamp (Unix)

failed_atinteger nullable

Validation failure timestamp (Unix)

cancelling_atinteger nullable

Cancellation request timestamp (Unix)

cancelled_atinteger nullable

Cancellation completion timestamp (Unix)

metadataobject nullable

Custom metadata

Example response

{
  "object": "batch"
}

Changes

No recorded changes to this operation across all 1 revision of this API.