> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Create Batch

POST https://api.meshapi.ai/v1/batches
Content-Type: application/json

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.

Reference: https://developers.meshapi.ai/api-reference/mesh-api/batch/create-batch

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/batches:
    post:
      operationId: create-batch
      summary: Create Batch
      description: >-
        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.
      tags:
        - batch
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Batch job created
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBatchRequest'
servers:
  - url: https://api.meshapi.ai
    description: Production Server
components:
  schemas:
    BatchRequestItem:
      type: object
      properties:
        custom_id:
          type: string
        method:
          type: string
          default: POST
        url:
          type: string
          default: /v1/chat/completions
        body:
          type: object
          additionalProperties:
            description: Any type
      required:
        - custom_id
        - body
      title: BatchRequestItem
    CreateBatchRequest:
      type: object
      properties:
        requests:
          type: array
          items:
            $ref: '#/components/schemas/BatchRequestItem'
        completion_window:
          type: string
          default: 24h
        metadata:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
      required:
        - requests
      title: CreateBatchRequest
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## Examples

### Successful batch creation response



**Request**

```json
{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}
```

**Response**

```json
{
  "id": "batch_9f8b7c6d5e4a3b2c1d0e9f8a7b6c5d4e",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "input_file_id": "file-7XyZ9AbCdEfGhIjKlMnOpQr",
  "completion_window": "48h",
  "status": "validating",
  "created_at": 1712345678,
  "expires_at": 1712432078,
  "request_counts": {
    "total": 2,
    "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": "weekly-customer-feedback-analysis"
  }
}
```

**SDK Code**

```python Successful batch creation response
import requests

url = "https://api.meshapi.ai/v1/batches"

payload = {
    "requests": [
        {
            "custom_id": "item-101",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Analyze customer feedback and summarize key points."
                    }
                ],
                "max_tokens": 300,
                "temperature": 0.3
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        },
        {
            "custom_id": "item-102",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Generate a report on product feature requests from the feedback."
                    }
                ],
                "temperature": 0.5
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        }
    ],
    "completion_window": "48h",
    "metadata": { "job_name": "weekly-customer-feedback-analysis" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Successful batch creation response
const url = 'https://api.meshapi.ai/v1/batches';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"requests":[{"custom_id":"item-101","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Analyze customer feedback and summarize key points."}],"max_tokens":300,"temperature":0.3},"method":"POST","url":"/v1/chat/completions"},{"custom_id":"item-102","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Generate a report on product feature requests from the feedback."}],"temperature":0.5},"method":"POST","url":"/v1/chat/completions"}],"completion_window":"48h","metadata":{"job_name":"weekly-customer-feedback-analysis"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Successful batch creation 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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Successful batch creation response
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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Successful batch creation response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}")
  .asString();
```

```php Successful batch creation response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/batches', [
  'body' => '{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Successful batch creation response
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/batches");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"requests\": [\n    {\n      \"custom_id\": \"item-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Successful batch creation response
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "requests": [
    [
      "custom_id": "item-101",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          ]
        ],
        "max_tokens": 300,
        "temperature": 0.3
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ],
    [
      "custom_id": "item-102",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          ]
        ],
        "temperature": 0.5
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ]
  ],
  "completion_window": "48h",
  "metadata": ["job_name": "weekly-customer-feedback-analysis"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/batches")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Batch_create_batch_example



**Request**

```json
{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}
```

**Response**

```json
{
  "id": "batch_9f8b7c6d5e4a3b2c1d0e9f8a7b6c5d4e",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "input_file_id": "file-7XyZ9AbCdEfGhIjKlMnOpQr",
  "completion_window": "48h",
  "status": "validating",
  "created_at": 1712345678,
  "expires_at": 1712432078,
  "request_counts": {
    "total": 2,
    "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": "weekly-customer-feedback-analysis"
  }
}
```

**SDK Code**

```python Batch_create_batch_example
import requests

url = "https://api.meshapi.ai/v1/batches"

payload = {
    "requests": [
        {
            "custom_id": "item-101",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Analyze customer feedback and summarize key points."
                    }
                ],
                "max_tokens": 300,
                "temperature": 0.3
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        },
        {
            "custom_id": "item-102",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Generate a report on product feature requests from the feedback."
                    }
                ],
                "temperature": 0.5
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        }
    ],
    "completion_window": "48h",
    "metadata": { "job_name": "weekly-customer-feedback-analysis" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Batch_create_batch_example
const url = 'https://api.meshapi.ai/v1/batches';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"requests":[{"custom_id":"item-101","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Analyze customer feedback and summarize key points."}],"max_tokens":300,"temperature":0.3},"method":"POST","url":"/v1/chat/completions"},{"custom_id":"item-102","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Generate a report on product feature requests from the feedback."}],"temperature":0.5},"method":"POST","url":"/v1/chat/completions"}],"completion_window":"48h","metadata":{"job_name":"weekly-customer-feedback-analysis"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Batch_create_batch_example
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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Batch_create_batch_example
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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Batch_create_batch_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}")
  .asString();
```

```php Batch_create_batch_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/batches', [
  'body' => '{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Batch_create_batch_example
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/batches");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"requests\": [\n    {\n      \"custom_id\": \"item-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Batch_create_batch_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "requests": [
    [
      "custom_id": "item-101",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          ]
        ],
        "max_tokens": 300,
        "temperature": 0.3
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ],
    [
      "custom_id": "item-102",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          ]
        ],
        "temperature": 0.5
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ]
  ],
  "completion_window": "48h",
  "metadata": ["job_name": "weekly-customer-feedback-analysis"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/batches")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example request



**Request**

```json
{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}
```

**Response**

```json
{
  "id": "batch_9f8b7c6d5e4a3b2c1d0e9f8a7b6c5d4e",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "input_file_id": "file-7XyZ9AbCdEfGhIjKlMnOpQr",
  "completion_window": "48h",
  "status": "validating",
  "created_at": 1712345678,
  "expires_at": 1712432078,
  "request_counts": {
    "total": 2,
    "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": "weekly-customer-feedback-analysis"
  }
}
```

**SDK Code**

```python Example request
import requests

url = "https://api.meshapi.ai/v1/batches"

payload = {
    "requests": [
        {
            "custom_id": "item-101",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Analyze customer feedback and summarize key points."
                    }
                ],
                "max_tokens": 300,
                "temperature": 0.3
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        },
        {
            "custom_id": "item-102",
            "body": {
                "model": "openai/gpt-4o-mini",
                "messages": [
                    {
                        "role": "user",
                        "content": "Generate a report on product feature requests from the feedback."
                    }
                ],
                "temperature": 0.5
            },
            "method": "POST",
            "url": "/v1/chat/completions"
        }
    ],
    "completion_window": "48h",
    "metadata": { "job_name": "weekly-customer-feedback-analysis" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Example request
const url = 'https://api.meshapi.ai/v1/batches';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"requests":[{"custom_id":"item-101","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Analyze customer feedback and summarize key points."}],"max_tokens":300,"temperature":0.3},"method":"POST","url":"/v1/chat/completions"},{"custom_id":"item-102","body":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Generate a report on product feature requests from the feedback."}],"temperature":0.5},"method":"POST","url":"/v1/chat/completions"}],"completion_window":"48h","metadata":{"job_name":"weekly-customer-feedback-analysis"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example request
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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Example request
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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Example request
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}")
  .asString();
```

```php Example request
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/batches', [
  'body' => '{
  "requests": [
    {
      "custom_id": "item-101",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          }
        ],
        "max_tokens": 300,
        "temperature": 0.3
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    },
    {
      "custom_id": "item-102",
      "body": {
        "model": "openai/gpt-4o-mini",
        "messages": [
          {
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          }
        ],
        "temperature": 0.5
      },
      "method": "POST",
      "url": "/v1/chat/completions"
    }
  ],
  "completion_window": "48h",
  "metadata": {
    "job_name": "weekly-customer-feedback-analysis"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Example request
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/batches");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"requests\": [\n    {\n      \"custom_id\": \"item-101\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Analyze customer feedback and summarize key points.\"\n          }\n        ],\n        \"max_tokens\": 300,\n        \"temperature\": 0.3\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    },\n    {\n      \"custom_id\": \"item-102\",\n      \"body\": {\n        \"model\": \"openai/gpt-4o-mini\",\n        \"messages\": [\n          {\n            \"role\": \"user\",\n            \"content\": \"Generate a report on product feature requests from the feedback.\"\n          }\n        ],\n        \"temperature\": 0.5\n      },\n      \"method\": \"POST\",\n      \"url\": \"/v1/chat/completions\"\n    }\n  ],\n  \"completion_window\": \"48h\",\n  \"metadata\": {\n    \"job_name\": \"weekly-customer-feedback-analysis\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "requests": [
    [
      "custom_id": "item-101",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Analyze customer feedback and summarize key points."
          ]
        ],
        "max_tokens": 300,
        "temperature": 0.3
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ],
    [
      "custom_id": "item-102",
      "body": [
        "model": "openai/gpt-4o-mini",
        "messages": [
          [
            "role": "user",
            "content": "Generate a report on product feature requests from the feedback."
          ]
        ],
        "temperature": 0.5
      ],
      "method": "POST",
      "url": "/v1/chat/completions"
    ]
  ],
  "completion_window": "48h",
  "metadata": ["job_name": "weekly-customer-feedback-analysis"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/batches")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```