curl --request POST \
--url https://api.meshapi.ai/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"custom_id": "item-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Summarize the following text: Small sample text..."
}
],
"max_tokens": 200,
"temperature": 0.2
}
},
{
"custom_id": "item-2",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Translate to French: Hello world"
}
]
}
}
],
"completion_window": "24h",
"metadata": {
"job_name": "nightly-support-summaries"
}
}
'import requests
url = "https://api.meshapi.ai/v1/batches"
payload = {
"requests": [
{
"custom_id": "item-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Summarize the following text: Small sample text..."
}
],
"max_tokens": 200,
"temperature": 0.2
}
},
{
"custom_id": "item-2",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Translate to French: Hello world"
}
]
}
}
],
"completion_window": "24h",
"metadata": { "job_name": "nightly-support-summaries" }
}
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: [
{
custom_id: 'item-1',
method: 'POST',
url: '/v1/chat/completions',
body: JSON.stringify({
model: 'openai/gpt-5.4',
messages: [{role: 'user', content: 'Summarize the following text: Small sample text...'}],
max_tokens: 200,
temperature: 0.2
})
},
{
custom_id: 'item-2',
method: 'POST',
url: '/v1/chat/completions',
body: JSON.stringify({
model: 'openai/gpt-5.4',
messages: [{role: 'user', content: 'Translate to French: Hello world'}]
})
}
],
completion_window: '24h',
metadata: {job_name: 'nightly-support-summaries'}
})
};
fetch('https://api.meshapi.ai/v1/batches', 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.meshapi.ai/v1/batches",
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' => [
[
'custom_id' => 'item-1',
'method' => 'POST',
'url' => '/v1/chat/completions',
'body' => [
'model' => 'openai/gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Summarize the following text: Small sample text...'
]
],
'max_tokens' => 200,
'temperature' => 0.2
]
],
[
'custom_id' => 'item-2',
'method' => 'POST',
'url' => '/v1/chat/completions',
'body' => [
'model' => 'openai/gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Translate to French: Hello world'
]
]
]
]
],
'completion_window' => '24h',
'metadata' => [
'job_name' => 'nightly-support-summaries'
]
]),
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.meshapi.ai/v1/batches"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\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.meshapi.ai/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meshapi.ai/v1/batches")
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 \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_6a46708ba644819099dacb31e0339a86",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file-2LvNxHkyRFbSPcLEnEdHW9",
"completion_window": "24h",
"status": "validating",
"created_at": 1783001227,
"expires_at": 1783087627,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"metadata": {
"job_name": "my-batch-job"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Create Batch
Create a batch job.
Accepts requests inline — no separate file upload step required.
Model and provider are resolved from body.model across all requests;
all requests must target the same model.
Returns 429 (batch_limit_exceeded) if the owner already has 10 or more batches in a non-terminal state. Returns 501 (not_implemented) if the resolved provider doesn’t support batch.
curl --request POST \
--url https://api.meshapi.ai/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requests": [
{
"custom_id": "item-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Summarize the following text: Small sample text..."
}
],
"max_tokens": 200,
"temperature": 0.2
}
},
{
"custom_id": "item-2",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Translate to French: Hello world"
}
]
}
}
],
"completion_window": "24h",
"metadata": {
"job_name": "nightly-support-summaries"
}
}
'import requests
url = "https://api.meshapi.ai/v1/batches"
payload = {
"requests": [
{
"custom_id": "item-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Summarize the following text: Small sample text..."
}
],
"max_tokens": 200,
"temperature": 0.2
}
},
{
"custom_id": "item-2",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Translate to French: Hello world"
}
]
}
}
],
"completion_window": "24h",
"metadata": { "job_name": "nightly-support-summaries" }
}
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: [
{
custom_id: 'item-1',
method: 'POST',
url: '/v1/chat/completions',
body: JSON.stringify({
model: 'openai/gpt-5.4',
messages: [{role: 'user', content: 'Summarize the following text: Small sample text...'}],
max_tokens: 200,
temperature: 0.2
})
},
{
custom_id: 'item-2',
method: 'POST',
url: '/v1/chat/completions',
body: JSON.stringify({
model: 'openai/gpt-5.4',
messages: [{role: 'user', content: 'Translate to French: Hello world'}]
})
}
],
completion_window: '24h',
metadata: {job_name: 'nightly-support-summaries'}
})
};
fetch('https://api.meshapi.ai/v1/batches', 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.meshapi.ai/v1/batches",
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' => [
[
'custom_id' => 'item-1',
'method' => 'POST',
'url' => '/v1/chat/completions',
'body' => [
'model' => 'openai/gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Summarize the following text: Small sample text...'
]
],
'max_tokens' => 200,
'temperature' => 0.2
]
],
[
'custom_id' => 'item-2',
'method' => 'POST',
'url' => '/v1/chat/completions',
'body' => [
'model' => 'openai/gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Translate to French: Hello world'
]
]
]
]
],
'completion_window' => '24h',
'metadata' => [
'job_name' => 'nightly-support-summaries'
]
]),
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.meshapi.ai/v1/batches"
payload := strings.NewReader("{\n \"requests\": [\n {\n \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\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.meshapi.ai/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requests\": [\n {\n \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meshapi.ai/v1/batches")
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 \"custom_id\": \"item-1\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize the following text: Small sample text...\"\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.2\n }\n },\n {\n \"custom_id\": \"item-2\",\n \"method\": \"POST\",\n \"url\": \"/v1/chat/completions\",\n \"body\": {\n \"model\": \"openai/gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Translate to French: Hello world\"\n }\n ]\n }\n }\n ],\n \"completion_window\": \"24h\",\n \"metadata\": {\n \"job_name\": \"nightly-support-summaries\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_6a46708ba644819099dacb31e0339a86",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file-2LvNxHkyRFbSPcLEnEdHW9",
"completion_window": "24h",
"status": "validating",
"created_at": 1783001227,
"expires_at": 1783087627,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"metadata": {
"job_name": "my-batch-job"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Enter your MeshAPI key (rsk_...) — sent as Authorization: Bearer <key>.
Headers
Dated version of the API contract to pin this request to. Omit it and the request is served under 2026-08 — the oldest supported version, so an existing integration is never moved by a release. A malformed or unsupported value is rejected with 400 invalid_api_version rather than falling back silently. The version actually served is echoed as X-Mesh-Version on every response, including errors.
2026-08 Body
Response
Batch job created