Docs / API reference

Batch execution API

Updated 2026-11-22. Published by PentestLLM.

Hand the gateway an uploaded JSONL file and it works through the lines inside a 24-hour window, so a repeatable review over hundreds of inputs needs no client loop. The four routes live under https://api.pentestllm.ai/v1/batches; upload the input first on Batch files.

Routes

RouteStatuses
POST /v1/batches200, 400, 401, 404
GET /v1/batches200, 401
GET /v1/batches/{batch_id}200, 401, 404
POST /v1/batches/{batch_id}/cancel200, 401, 404, 409

All four go by the default security of the document, so the normal key your client already holds is enough to drive a batch. Whether a console session could stand in for it, the OpenAPI document does not say.

Create a batch

POST /v1/batches takes:

FieldTypeNotes
input_file_idstring, requiredA file uploaded with purpose batch.
endpointstring, required/v1/chat/completions, /v1/completions, /v1/embeddings, /v1/responses or /v1/moderations. Every line of the file must use it.
completion_windowstring, requiredOnly 24h.
metadataobjectUp to 16 string values, handed back on the batch.

It answers 200 with the batch. An unknown endpoint, a window other than 24h, or a line whose url differs from the endpoint is 400 invalid_request; an input file your organization does not have is 404 not_found.

How lines run

Each line goes through the same route a direct call would, under the key that created the batch, so its model allowlist, budget and limits apply line by line, with each charge held against the balance as it runs. Each line that runs is billed at the catalog rate less a 50% batch discount, and receipts and the usage log show the discounted charge. An organization’s lines run a few at a time. A batch on /v1/moderations depends on a moderation model being listed; see Embeddings, rerank and moderation.

The batch object

FieldMeaning
idbatch_ and 24 hex characters.
objectAlways batch.
endpointThe route every line runs on.
input_file_idThe uploaded file.
output_file_idSet at the end when any line answered 2xx, else null.
error_file_idSet at the end when any line failed or expired, else null.
completion_windowAlways 24h.
statusWhere the batch is in its lifecycle, below.
created_atAlso expires_at, plus in_progress_at, finalizing_at, completed_at, failed_at, expired_at, cancelling_at and cancelled_at once reached. Unix seconds.
request_countstotal, completed and failed lines.
errorsAn object or null.
metadataWhat you sent, or null.

status moves through validating, in_progress, finalizing and completed, or ends at failed, expired or, after a cancel, cancelling and then cancelled. The output file holds the lines that answered 2xx; the error file holds every other answer plus any line not reached before the window closed, marked batch_expired. That code appears inside the file, never as the HTTP status of a route. Read both files through the content route on Batch files.

List and read

GET /v1/batches answers object list, data, first_id, last_id and has_more, newest first. Its prose takes limit (20 by default, 100 at most) and after, a batch id to continue from, though neither is a declared parameter. GET /v1/batches/{batch_id} returns one batch, or 404 not_found when it is not your organization’s. A failed credential is 401 invalid_api_key on every route.

Cancel

POST /v1/batches/{batch_id}/cancel takes no body. Lines not yet started are dropped, answered ones stay in the output file, and the batch reads cancelling until its running lines finish, then cancelled. A batch that already finished answers 409 batch_not_cancellable.

Example

shell
1curl "https://api.pentestllm.ai/v1/batches?limit=20" \
2 -H "Authorization: Bearer sk-ptl-live-…"

Questions

Can one batch call more than one route?

No. A batch names a single endpoint, and a file with any line pointing somewhere else is rejected when you create the batch.

Does cancelling throw away finished lines?

No. Answers already produced stay in the output file, and lines that are running finish before the batch settles as cancelled.

What becomes of lines the window did not reach?

They land in the error file with the code batch_expired, so you can collect them and submit a new batch.

Join on TelegramHelp