Skip to content

Create New Batch

Submit a collection of requests for asynchronous processing. All usage in the batch will be billed at 50% of the standard model rate.

Endpoint

POST https://llm.siraya.pro/v1/batches

Request Body

The request body should contain an array of request objects.

Parameters

Field Type Required Description
requests array Yes A list of individual request objects.

Individual Request Object

Field Type Description
custom_id string A unique identifier for the request within the batch.
params object The standard parameters for a Chat Completions request (model, messages, etc.).

Example Request

curl https://llm.siraya.pro/v1/batches \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  -d '{
    "requests": [
      {
        "custom_id": "request-1",
        "params": {
          "model": "gpt-4o",
          "messages": [{"role": "user", "content": "Hello world!"}]
        }
      },
      {
        "custom_id": "request-2",
        "params": {
          "model": "claude-3-5-sonnet",
          "messages": [{"role": "user", "content": "How are you?"}]
        }
      }
    ]
  }'
import requests

url = "https://llm.siraya.pro/v1/batches"
headers = {"Authorization": "Bearer <API_KEY>"}
data = {
    "requests": [
        {
            "custom_id": "job-1",
            "params": {"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}
        }
    ]
}

response = requests.post(url, headers=headers, json=data)
batch_info = response.json()
print(f"Created batch: {batch_info['id']}")

Response

Returns a batch object with a unique identifier and its initial status.

{
  "id": "batch_abc123",
  "object": "batch",
  "status": "pending",
  "created_at": 1700000000
}