> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Buat Batch

> Membuat pekerjaan batch yang kompatibel dengan OpenAI dari file input yang diunggah.

## Ikhtisar

Endpoint ini adalah bagian dari API Batch yang kompatibel dengan OpenAI dari TokenLab. Pekerjaan batch menggunakan file JSONL yang diunggah, berjalan secara asinkron, dan dapat mengembalikan file output/error di kemudian hari.

## Catatan

* File input batch harus menggunakan `purpose=batch`.
* `completion_window` saat ini adalah `24h`.
* Urutan output tidak dijamin; selalu cocokkan berdasarkan `custom_id`.
* Streaming tidak didukung di dalam item batch.
* Endpoint item batch yang saat ini didukung adalah `/v1/chat/completions` dan `/v1/embeddings`; pekerjaan batch `/v1/responses` ditolak sampai executor batch Responses native tersedia.

## Contoh

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tokenlab.sh/v1/batches" \
    -H "Authorization: Bearer sk-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "input_file_id": "file_abc123",
      "endpoint": "/v1/chat/completions",
      "completion_window": "24h"
    }'
  ```
</RequestExample>

## Permintaan / Respons

Gunakan panel OpenAPI interaktif di atas untuk skema yang tepat.

## Tips Operasional

* Gunakan `custom_id` untuk rekonsiliasi downstream yang idempotent.
* Harapkan `output_file_id` dan `error_file_id` hanya setelah pekerja menyelesaikan batch.
* Harga batch mungkin berbeda dari harga sinkron karena aturan diskon `isBatchRequest=true` berlaku.

## Contoh respons

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "batch_abc123",
    "object": "batch",
    "endpoint": "/v1/chat/completions",
    "input_file_id": "file_abc123",
    "completion_window": "24h",
    "status": "validating",
    "output_file_id": null,
    "error_file_id": null,
    "created_at": 1706000000
  }
  ```
</ResponseExample>

## Field penting

<ResponseField name="id" type="string">Identifier untuk panggilan lanjutan dan support.</ResponseField>
<ResponseField name="status" type="string">Status lifecycle saat ini untuk resource ini.</ResponseField>
<ResponseField name="output_file_id" type="string|null">Identifier file yang dipakai API terkait.</ResponseField>
