string
required
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Submit and retrieve large volumes of extract, summarize, and classify requests asynchronously.
"model" to "extract", "summarize", or "classify" to select the operation. Each item is processed independently — a failure on one item does not affect others.
Documents (document / document_mime_type) are not supported in batch requests. Pass pre-extracted text in the text field.
POST /v1/batches| Header | Value |
|---|---|
content-type | application/jsonl (recommended) or application/json |
x-api-key | Your API key |
"POST"."/v1/chat/completions".model is the discriminator — set it to "extract", "summarize", or "classify". Remaining fields depend on the model."model": "extract"type values in the response.{
"company": "Name of the company",
"revenue": "Revenue figure including currency and period"
}
"model": "summarize""Use bullet points.", "Focus on financial figures only.")."model": "classify"name (string) — the label namerubric (string) — a yes/no question describing what this label means[
{"name": "Positive", "rubric": "Does this text express satisfaction or approval?"},
{"name": "Negative", "rubric": "Does this text express dissatisfaction or complaints?"}
]
400. Split larger workloads across multiple batches.
"validating".
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": null,
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1782819284,
"request_counts": { "total": 3, "completed": 0, "failed": 0 },
"metadata": null
}
GET /v1/batches/{batch_id}status is "completed" or "failed". Returns the same OpenAI-compatible Batch object.
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"status": "completed",
"output_file_id": "batch_abc123_output",
"error_file_id": null,
"created_at": 1782819284,
"request_counts": { "total": 3, "completed": 3, "failed": 0 },
"metadata": null
}
status is one of validating, in_progress, completed, or failed. An unknown batch ID returns 404.
GET /v1/batches/{batch_id}/outputcustom_id you provided in the input.null if the item failed.status_code — HTTP status of the individual itembody — ChatCompletion-shaped object. The domain result is JSON-serialized in choices[0].message.content.null on success.import json
for line in output_text.strip().splitlines():
item = json.loads(line)
content = json.loads(item["response"]["body"]["choices"][0]["message"]["content"])
# content is now the domain response dict (summary, entities, top_label, etc.)
| Status | Meaning |
|---|---|
400 Bad Request | A JSONL line has an invalid model value or malformed JSON, or the batch exceeds 50 requests. |
401 Unauthorized | Missing or invalid x-api-key. |
404 Not Found | The batch ID does not exist, or its output is not yet available. |
502 Bad Gateway | The batch backend request failed. |
curl -X POST https://api.scaledown.xyz/v1/batches \
-H "content-type: application/jsonl" \
-H "x-api-key: <your-api-key>" \
--data-binary @- <<'EOF'
{"custom_id":"sum-1","method":"POST","url":"/v1/chat/completions","body":{"model":"summarize","text":"Artificial intelligence is the simulation of human intelligence processes by machines...","instructions":"Use bullet points."}}
{"custom_id":"ext-1","method":"POST","url":"/v1/chat/completions","body":{"model":"extract","text":"Apple Inc. reported Q1 revenue of $94.8B. CEO Tim Cook made the announcement on Feb 1st.","entities":{"company":"Name of the company","revenue":"Revenue figure","ceo":"Name of the CEO"}}}
{"custom_id":"cls-1","method":"POST","url":"/v1/chat/completions","body":{"model":"classify","text":"This product is fantastic — fast shipping and great quality!","labels":[{"name":"Positive","rubric":"Does this text express satisfaction, praise, or approval?"},{"name":"Negative","rubric":"Does this text express dissatisfaction, complaints, or criticism?"}]}}
EOF
import json
import requests
lines = [
{
"custom_id": "sum-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "summarize",
"text": "Artificial intelligence is the simulation of human intelligence...",
"instructions": "Use bullet points.",
},
},
{
"custom_id": "ext-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "extract",
"text": "Apple Inc. reported Q1 revenue of $94.8B. CEO Tim Cook made the announcement on Feb 1st.",
"entities": {
"company": "Name of the company",
"revenue": "Revenue figure",
"ceo": "Name of the CEO",
},
},
},
{
"custom_id": "cls-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "classify",
"text": "This product is fantastic — fast shipping and great quality!",
"labels": [
{"name": "Positive", "rubric": "Does this text express satisfaction, praise, or approval?"},
{"name": "Negative", "rubric": "Does this text express dissatisfaction, complaints, or criticism?"},
],
},
},
]
body = "\n".join(json.dumps(line) for line in lines).encode()
response = requests.post(
"https://api.scaledown.xyz/v1/batches",
headers={
"content-type": "application/jsonl",
"x-api-key": "<your-api-key>",
},
data=body,
)
batch_id = response.json()["id"]
print(f"Batch submitted: {batch_id}")
const lines = [
{
custom_id: "sum-1",
method: "POST",
url: "/v1/chat/completions",
body: {
model: "summarize",
text: "Artificial intelligence is the simulation of human intelligence...",
instructions: "Use bullet points.",
},
},
{
custom_id: "ext-1",
method: "POST",
url: "/v1/chat/completions",
body: {
model: "extract",
text: "Apple Inc. reported Q1 revenue of $94.8B. CEO Tim Cook made the announcement on Feb 1st.",
entities: {
company: "Name of the company",
revenue: "Revenue figure",
ceo: "Name of the CEO",
},
},
},
{
custom_id: "cls-1",
method: "POST",
url: "/v1/chat/completions",
body: {
model: "classify",
text: "This product is fantastic — fast shipping and great quality!",
labels: [
{ name: "Positive", rubric: "Does this text express satisfaction, praise, or approval?" },
{ name: "Negative", rubric: "Does this text express dissatisfaction, complaints, or criticism?" },
],
},
},
];
const body = lines.map((l) => JSON.stringify(l)).join("\n");
const response = await fetch("https://api.scaledown.xyz/v1/batches", {
method: "POST",
headers: {
"content-type": "application/jsonl",
"x-api-key": "<your-api-key>",
},
body,
});
const { id: batch_id } = await response.json();
console.log(`Batch submitted: ${batch_id}`);
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1782819284,
"request_counts": { "total": 3, "completed": 0, "failed": 0 },
"metadata": null
}
import time
import requests
headers = {"x-api-key": "<your-api-key>"}
while True:
status = requests.get(
f"https://api.scaledown.xyz/v1/batches/{batch_id}",
headers=headers,
).json()
if status["status"] in ("completed", "failed"):
break
time.sleep(5)
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
while (true) {
const res = await fetch(`https://api.scaledown.xyz/v1/batches/${batchId}`, {
headers: { "x-api-key": "<your-api-key>" },
});
const status = await res.json();
if (status.status === "completed" || status.status === "failed") break;
await sleep(5000);
}
import json
import requests
response = requests.get(
f"https://api.scaledown.xyz/v1/batches/{batch_id}/output",
headers={"x-api-key": "<your-api-key>"},
)
for line in response.text.strip().splitlines():
item = json.loads(line)
model = item["response"]["body"]["model"]
content = json.loads(item["response"]["body"]["choices"][0]["message"]["content"])
if model == "summarize":
print(f"[{item['custom_id']}] Summary: {content['summary']}")
elif model == "extract":
for entity in content["entities"]:
print(f"[{item['custom_id']}] {entity['type']}: {entity['value']}")
elif model == "classify":
print(f"[{item['custom_id']}] Top label: {content['top_label']} — {content['reasoning']}")
const outputRes = await fetch(
`https://api.scaledown.xyz/v1/batches/${batchId}/output`,
{ headers: { "x-api-key": "<your-api-key>" } }
);
const text = await outputRes.text();
for (const line of text.trim().split("\n")) {
const item = JSON.parse(line);
const body = item.response.body;
const content = JSON.parse(body.choices[0].message.content);
if (body.model === "summarize") {
console.log(`[${item.custom_id}] Summary:`, content.summary);
} else if (body.model === "extract") {
for (const entity of content.entities) {
console.log(`[${item.custom_id}] ${entity.type}: ${entity.value}`);
}
} else if (body.model === "classify") {
console.log(`[${item.custom_id}] Top label: ${content.top_label} — ${content.reasoning}`);
}
}
{"custom_id":"sum-1","response":{"status_code":200,"body":{"model":"summarize","choices":[{"message":{"content":"{\"summary\":\"• AI simulates human cognitive processes in machines.\\n• Key research areas include learning, reasoning, and perception.\",\"input_chars\":420,\"output_chars\":112}"}}]}},"error":null}
{"custom_id":"ext-1","response":{"status_code":200,"body":{"model":"extract","choices":[{"message":{"content":"{\"entities\":[{\"type\":\"company\",\"value\":\"Apple Inc.\",\"score\":0.98},{\"type\":\"revenue\",\"value\":\"$94.8B\",\"score\":0.97},{\"type\":\"ceo\",\"value\":\"Tim Cook\",\"score\":0.99}]}"}}]}},"error":null}
{"custom_id":"cls-1","response":{"status_code":200,"body":{"model":"classify","choices":[{"message":{"content":"{\"top_label\":\"Positive\",\"scores\":{\"Positive\":0.97,\"Negative\":0.03},\"reasoning\":\"The text praises fast shipping and product quality explicitly.\"}"}}]}},"error":null}