Skip to content
Most AI tasks no longer need a frontier model Read launch post

Batches (OpenAI-compatible)

SIE Serverless serves OpenAI’s Files and Batches API. You upload a JSONL file with one request per line, create a batch from it, and download an output file with one response per line when the batch finishes. It suits scheduled work such as a nightly classification run: submit, do something else, collect the results later.

The OpenAI client libraries work unchanged; only the base URL and the API key differ. A batch costs the same per-model prices as real-time calls of the same size. There is no batch discount.

Endpoint in the fileModelRequests per batch
/v1/chat/completionsQwen/Qwen3.5-4Bup to 384
/v1/embeddingsBAAI/bge-m3up to 100,000
/v1/embeddingsSnowflake/snowflake-arctic-embed-l-v2.0up to 100,000

Batches run on dedicated batch capacity. Every line in a file must use the same endpoint and model. Creating a batch for a model the batch capacity doesn’t serve returns 400 with the code BATCH_MODEL_NOT_SERVED, or INVALID_REQUEST for a chat model served only through SIE Relay. Nothing runs or is charged. For other models, send real-time requests and cap your own concurrency as described in Rate limits.

Your API key needs the Batch jobs scope. The new-key dialog selects Inference only, so also select Batch jobs under Scopes when you create the key on the API keys page. Without it, every /v1/files and /v1/batches call returns 403 with the code INSUFFICIENT_SCOPE.

Each line is one request: a custom_id you choose, the method, the url (the endpoint) and the request body. The custom_id comes back on the matching output line, because output lines are not guaranteed to be in input order.

{"custom_id": "ticket-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "Qwen/Qwen3.5-4B", "messages": [{"role": "user", "content": "Classify as bug, question or request: The export button does nothing."}], "max_tokens": 16}}
{"custom_id": "ticket-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "Qwen/Qwen3.5-4B", "messages": [{"role": "user", "content": "Classify as bug, question or request: Can I invite a second admin?"}], "max_tokens": 16}}

An embeddings line has the same shape, with "url": "/v1/embeddings" and a body such as {"model": "BAAI/bge-m3", "input": "first document"}. Each line embeds one text: input is a string, or a list with one string.

A chat line’s body takes messages, max_tokens (or max_completion_tokens), temperature, top_p, top_k, stop, seed, frequency_penalty, presence_penalty, tools, tool_choice and parallel_tool_calls. Other fields, such as response_format, stream, n or logprobs, fail that line: it goes to the error file and the rest of the batch runs.

Some problems fail the whole file, and creating the batch returns 400 with the line number: a line that isn’t valid JSON, a missing or repeated custom_id, a method other than POST, a url that differs from the batch’s endpoint, or lines that use different models.

The file can be up to 64 MiB.

import os
import time
from openai import OpenAI
client = OpenAI(
base_url="https://api.superlinked.com/v1",
api_key=os.environ["SIE_API_KEY"],
)
upload = client.files.create(file=open("requests.jsonl", "rb"), purpose="batch")
batch = client.batches.create(
input_file_id=upload.id,
endpoint="/v1/chat/completions",
completion_window="24h",
)
while batch.status not in ("completed", "failed", "expired", "cancelled"):
time.sleep(30)
batch = client.batches.retrieve(batch.id)
if batch.output_file_id:
for line in client.files.content(batch.output_file_id).text.splitlines():
print(line)

completion_window accepts only 24h. A batch that hasn’t finished 24 hours after it was created ends as expired.

A batch on a model that isn’t loaded waits for the model first, so even a small batch can take a few minutes.

Each output line answers one input line:

{"id": "batch_req_…", "custom_id": "ticket-1", "response": {"status_code": 200, "request_id": "…", "body": {"id": "chatcmpl-…", "object": "chat.completion", "created": 1764057600, "model": "Qwen/Qwen3.5-4B", "choices": [{"index": 0, "message": {"role": "assistant", "content": "bug"}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 2, "total_tokens": 26}}}, "error": null}

An embeddings line’s body is the same list object /v1/embeddings returns, with one embedding.

Requests that failed are in a separate file, error_file_id. Each line keeps the custom_id, has "response": null and says why in error:

{"id": "batch_req_ticket-2", "custom_id": "ticket-2", "response": null, "error": {"code": "invalid_request", "message": "…"}}

invalid_request means the line itself was refused, for example for an unsupported field. not_processed means the batch ended before the line ran. Any other code, such as inference_error, comes from running the request on the model.

A batch can complete with some lines in each file; error_file_id is null when every request succeeded.

statusMeaning
in_progressRequests are running. request_counts shows how many have finished.
finalizingEvery request has finished and the output files are being written.
completedAt least one request succeeded. The output file, and the error file if any request failed, are ready.
failedNo request succeeded. The error file says why for each line.
expiredIt didn’t finish within 24 hours, or it stopped because your organization’s credit ran out.
cancelling, cancelledYou cancelled it with POST /v1/batches/{id}/cancel.

The input file is checked when you create the batch, so a new batch starts at in_progress; SIE Serverless never reports validating.

An expired or cancelled batch has no output file, even for requests that finished before it stopped, and those requests are still charged. To keep partial results, split large work into several smaller batches.

Input fileJSONL, up to 64 MiB, uploaded with purpose="batch"
Requests per batch384 for chat completions, 100,000 for embeddings
Completion window24h only
File retentionInput and output files are deleted 30 days after upload. Delete them sooner with DELETE /v1/files/{id}.
Rate limitsEvery /v1/files and /v1/batches call counts against the batch jobs limits in Rate limits, 2 requests per second per key, so poll every few seconds, not in a tight loop. A refused call gets 429 with Retry-After; wait that long and send it again.

GET /v1/files and GET /v1/batches list your organization’s files and batches.

Each request in a batch is charged at the same per-model price as the equivalent real-time call; see pricing. If your credit balance can’t cover the batch, creating it returns 402 with the code INSUFFICIENT_CREDITS and nothing runs.

For encode work over items you send in the request body, the jobs API is the SIE-native alternative.

Talk to us

Tell us about your use case and we'll get back to you shortly.