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.

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

Body

requests array Required
A list of individual request objects.
curl https://llm.siraya.ai/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.ai/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']}")

Example Response

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