Async Batch Upload
Queue a large classification batch at /v1/reflex/asynchronous_batches/upload
curl --request POST \
--url https://api.morphllm.com/v1/reflex/asynchronous_batches/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"id": "row-1",
"model": [
"guardrail",
"jailbreak"
],
"text": "text to classify"
},
{
"id": "row-2",
"model": [
"stuck-in-a-loop"
],
"text": "let me try that again. let me try that again."
}
]
}
'import requests
url = "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload"
payload = { "requests": [
{
"id": "row-1",
"model": ["guardrail", "jailbreak"],
"text": "text to classify"
},
{
"id": "row-2",
"model": ["stuck-in-a-loop"],
"text": "let me try that again. let me try that again."
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requests: [
{id: 'row-1', model: ['guardrail', 'jailbreak'], text: 'text to classify'},
{
id: 'row-2',
model: ['stuck-in-a-loop'],
text: 'let me try that again. let me try that again.'
}
]
})
};
fetch('https://api.morphllm.com/v1/reflex/asynchronous_batches/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requests' => [
[
'id' => 'row-1',
'model' => [
'guardrail',
'jailbreak'
],
'text' => 'text to classify'
],
[
'id' => 'row-2',
'model' => [
'stuck-in-a-loop'
],
'text' => 'let me try that again. let me try that again.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.morphllm.com/v1/reflex/asynchronous_batches/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.morphllm.com/v1/reflex/asynchronous_batches/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "rbatch-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"object": "reflex.batch",
"status": "in_progress",
"request_counts": {
"total": 2,
"completed": 1,
"failed": 0
},
"created_at": 1780000000
}{
"id": "rbatch-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"object": "reflex.batch",
"status": "queued",
"request_counts": {
"total": 2,
"completed": 0,
"failed": 0
},
"created_at": 1780000000
}{
"error": {
"code": "invalid_request_error",
"message": "The request body is missing the `model` field."
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid API key provided."
}
}{
"error": {
"code": "rate_limited",
"message": "Too many requests. Retry in 12 seconds."
}
}{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side."
}
}Overview
Queues a batch for asynchronous classification and returns a batch id immediately. PollGET /v1/reflex/asynchronous_batches/{batch_id} for progress and fetch rows from the results endpoint when it completes. Async pricing is half the realtime rate.Authorizations
Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.
Headers
Replaying the same key returns the existing batch instead of creating a duplicate. Client-generated key that identifies this upload attempt.
"a7c1f0e2-3b44-4c9a-9f10-2f5c8d6b1e33"
Body
Up to 10,000 rows to classify offline.
Rows queued for offline classification at the batch rate.
Up to 10,000 rows.
Show child attributes
Show child attributes
[
{
"id": "row-1",
"model": ["guardrail", "jailbreak"],
"text": "text to classify"
},
{
"id": "row-2",
"model": ["stuck-in-a-loop"],
"text": "let me try that again. let me try that again."
}
]
Response
Existing batch returned for a replayed Idempotency-Key.
Async batch status. status moves queued → in_progress → completed.
Identifier for the queued batch.
"rbatch-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
Object type, always reflex.batch.
"reflex.batch"
Where the batch is in the queue.
queued, in_progress, completed "queued"
Progress counters, advancing as the worker drains the queue.
Show child attributes
Show child attributes
{ "total": 2, "completed": 0, "failed": 0 }
Unix timestamp (seconds).
1780000000
curl --request POST \
--url https://api.morphllm.com/v1/reflex/asynchronous_batches/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"id": "row-1",
"model": [
"guardrail",
"jailbreak"
],
"text": "text to classify"
},
{
"id": "row-2",
"model": [
"stuck-in-a-loop"
],
"text": "let me try that again. let me try that again."
}
]
}
'import requests
url = "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload"
payload = { "requests": [
{
"id": "row-1",
"model": ["guardrail", "jailbreak"],
"text": "text to classify"
},
{
"id": "row-2",
"model": ["stuck-in-a-loop"],
"text": "let me try that again. let me try that again."
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requests: [
{id: 'row-1', model: ['guardrail', 'jailbreak'], text: 'text to classify'},
{
id: 'row-2',
model: ['stuck-in-a-loop'],
text: 'let me try that again. let me try that again.'
}
]
})
};
fetch('https://api.morphllm.com/v1/reflex/asynchronous_batches/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requests' => [
[
'id' => 'row-1',
'model' => [
'guardrail',
'jailbreak'
],
'text' => 'text to classify'
],
[
'id' => 'row-2',
'model' => [
'stuck-in-a-loop'
],
'text' => 'let me try that again. let me try that again.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.morphllm.com/v1/reflex/asynchronous_batches/upload"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.morphllm.com/v1/reflex/asynchronous_batches/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.morphllm.com/v1/reflex/asynchronous_batches/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requests\": [\n {\n \"id\": \"row-1\",\n \"model\": [\n \"guardrail\",\n \"jailbreak\"\n ],\n \"text\": \"text to classify\"\n },\n {\n \"id\": \"row-2\",\n \"model\": [\n \"stuck-in-a-loop\"\n ],\n \"text\": \"let me try that again. let me try that again.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "rbatch-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"object": "reflex.batch",
"status": "in_progress",
"request_counts": {
"total": 2,
"completed": 1,
"failed": 0
},
"created_at": 1780000000
}{
"id": "rbatch-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"object": "reflex.batch",
"status": "queued",
"request_counts": {
"total": 2,
"completed": 0,
"failed": 0
},
"created_at": 1780000000
}{
"error": {
"code": "invalid_request_error",
"message": "The request body is missing the `model` field."
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid API key provided."
}
}{
"error": {
"code": "rate_limited",
"message": "Too many requests. Retry in 12 seconds."
}
}{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side."
}
}