> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valarhq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a batch

> Submit a batch of requests for asynchronous processing.



## OpenAPI

````yaml POST /batches
openapi: 3.1.0
info:
  title: Valar API
  version: '2026-02-18'
  description: >-
    Valar exposes Responses and Chat Completions endpoints that match the OpenAI
    shape. This reference documents the fields Valar supports today.
servers:
  - url: https://api.valarhq.ai/v1
security:
  - BearerAuth: []
tags:
  - name: Models API
    description: Discover which models you can call.
  - name: Responses API
    description: Responses endpoints that follow the OpenAI interface.
  - name: Chat Completions API
    description: Chat Completions endpoints that follow the OpenAI interface.
  - name: Batches API
    description: Submit request batches and track their progress.
paths:
  /batches:
    post:
      tags:
        - Batches API
      summary: Create a batch
      description: Send a group of requests for Valar to process in the background.
      operationId: createBatch
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBatchRequest'
            example:
              endpoint: /v1/responses
              label: my-batch-job
              requests:
                - custom_id: my-first-request
                  params:
                    model: zai-org/GLM-5.2-FP8
                    max_output_tokens: 1024
                    input:
                      - role: user
                        content: Hello, world!
                - custom_id: my-second-request
                  params:
                    model: zai-org/GLM-5.2-FP8
                    max_output_tokens: 1024
                    input:
                      - role: user
                        content: Hello again!
      responses:
        '200':
          description: The batch was created.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - request_counts
                  - created_at
                properties:
                  id:
                    type: string
                    description: The batch's unique ID.
                  request_counts:
                    type: integer
                    description: How many requests the batch contains.
                  created_at:
                    type: integer
                    description: When the batch was created, as a Unix timestamp.
                  label:
                    type: string
                    description: The label you gave the batch, when one was set.
              example:
                id: batch_abc123
                request_counts: 2
                created_at: 1741564800
                label: my-batch-job
        '400':
          description: The request was malformed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: We could not authenticate the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Something went wrong on Valar's side.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        maxLength: 255
      description: >-
        Lets you retry safely. Valar records a reservation under the combination
        of organization, API key, and Idempotency-Key, so sending the same value
        again hands back the stored response rather than running inference a
        second time. Values can be up to 255 characters. See [Idempotent
        Requests](/idempotency) for the complete rules.
  schemas:
    CreateBatchRequest:
      type: object
      required:
        - endpoint
        - requests
      properties:
        endpoint:
          type: string
          enum:
            - /v1/responses
          description: >-
            Which API endpoint every request in the batch targets. Right now
            /v1/responses is the only valid choice.
        requests:
          type: array
          minItems: 1
          maxItems: 100000
          description: >-
            The requests that make up the batch, from 1 up to 100,000 of them.
            The combined request body has to stay under 256 MB.
          items:
            $ref: '#/components/schemas/BatchRequestItem'
        label:
          type: string
          pattern: ^[a-zA-Z0-9_-]+$
          maxLength: 128
          description: >-
            An optional name for the batch. Use letters and digits, optionally
            with hyphens and underscores, up to 128 characters.
      additionalProperties: false
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
      additionalProperties: false
    BatchRequestItem:
      type: object
      required:
        - custom_id
        - params
      properties:
        custom_id:
          type: string
          pattern: ^[a-z0-9][a-z0-9_-]*$
          minLength: 1
          maxLength: 64
          description: >-
            Your own identifier for this request, unique within the batch. Use
            lowercase letters and digits, optionally with hyphens and
            underscores, between 1 and 64 characters.
        params:
          type: object
          description: >-
            The parameters for this request, using the same fields you would
            send in a Responses API request body.
          additionalProperties: true
      additionalProperties: false
    ErrorObject:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
        param:
          oneOf:
            - type: string
            - type: 'null'
        code:
          oneOf:
            - type: string
            - type: integer
            - type: 'null'
      additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````