For the complete documentation index, see llms.txt. This page is also available as Markdown.

Batches

The Batch API lets you submit asynchronous, high-volume workloads at a 50% discount off standard retail rates. Instead of executing requests sequentially and waiting synchronously for each response, you upload a JSONL file of requests, create a batch with a 24-hour completion window, and download the results once processing completes.

The DOS.AI Batch API is 100% OpenAI-compatible, so you can use existing OpenAI SDKs or HTTP clients without modifying your code structure.


Why Use the Batch API?

  • 50% Cost Savings: All batch requests are charged at exactly 50% of the standard retail token price.

  • Unified Provider Marketplace:

    • Provider dos (dos): Processed during spare GPU capacity troughs.

    • Provider alibaba (DeepSeek & Qwen): Scheduled during provider off-peak windows (00:00 – 10:00 GMT+8), giving you reliable, low-cost processing for frontier open-weights models.

  • Independent Limits: Batch volume does not consume your real-time interactive rate limits.

  • Resilient & Fault-Tolerant: Individual request failures (e.g. invalid formatting or context length exceedance) are recorded per line in the output file without failing the rest of the batch.


Supported Models

Model ID
Provider
Description
Discount

dos (or dos-ai)

DOS

DOS.AI's flagship model

-50%

deepseek-v4-pro

Alibaba Cloud

Frontier reasoning and coding model

-50%

deepseek-v4.1-flash

Alibaba Cloud

Ultra-fast, cost-effective general intelligence

-50%

deepseek-v4

Alibaba Cloud

Flagship DeepSeek V4 foundation model

-50%

deepseek-chat

Alibaba Cloud

Standard DeepSeek conversational model

-50%

qwen3.8-27b

Alibaba Cloud

Qwen 3.8 27B high-efficiency instruct model

-50%

qwen3.8-max

Alibaba Cloud

Qwen 3.8 flagship frontier model

-50%

qwen3.8-72b

Alibaba Cloud

Qwen 3.8 dense open-weights model

-50%


Endpoints

Endpoint
Method
Description

https://api.dos.ai/v1/files

POST

Upload a JSONL input file (purpose="batch").

https://api.dos.ai/v1/batches

POST

Create a batch job referencing the uploaded file.

https://api.dos.ai/v1/batches/{batch_id}

GET

Retrieve the status and request counts of a batch.

https://api.dos.ai/v1/files/{file_id}/content

GET

Download the results JSONL content.

https://api.dos.ai/v1/batches/{batch_id}/cancel

POST

Cancel an in-flight or validating batch job.


Step-by-Step Walkthrough

1. Prepare Your Input JSONL File

Each line in the file must be a JSON object containing custom_id, method, url, and body:

Save this file as batch_input.jsonl.

2. Upload the File (POST /v1/files)

Upload your JSONL file with purpose="batch":

Response (200 OK):

3. Create the Batch (POST /v1/batches)

Submit the batch with your uploaded file_id and the /v1/chat/completions endpoint:

Response (200 OK):

4. Check Batch Status (GET /v1/batches/{batch_id})

Poll the batch status periodically (e.g. every 30 to 60 seconds):

Lifecycle states:

  • validating: Input file is being checked.

  • in_progress: Requests are currently being processed.

  • completed: All requests have been processed.

  • failed: The batch encountered a fatal file or quota error.

  • cancelled: The batch was cancelled by the user.

When status reaches completed, the response includes output_file_id:

5. Download Results (GET /v1/files/{file_id}/content)

Download the raw JSONL output containing completions for each custom_id:

Each line in batch_output.jsonl contains:


Python SDK Example

You can use the official openai Python SDK by setting base_url="https://api.dos.ai/v1":


Cancelling a Batch (POST /v1/batches/{batch_id}/cancel)

To cancel a running or validating batch:

Requests that have already completed before cancellation will remain recorded in the output file and billed; remaining requests are skipped immediately and will not consume tokens.

Last updated