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

# 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.



## OpenAPI

````yaml /api/openapi.json post /v1/batches
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/batches:
    post:
      tags:
        - 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.
      operationId: create_batch
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            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.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBatchRequest'
            examples:
              default:
                summary: Example request
                value:
                  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
      responses:
        '200':
          description: Batch job created
          content:
            application/json:
              schema: {}
              examples:
                default:
                  summary: Successful batch creation response
                  value:
                    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
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    CreateBatchRequest:
      properties:
        requests:
          items:
            $ref: '#/components/schemas/BatchRequestItem'
          type: array
          minItems: 1
          title: Requests
        completion_window:
          type: string
          title: Completion Window
          default: 24h
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
      type: object
      required:
        - requests
      title: CreateBatchRequest
      example:
        completion_window: 24h
        metadata:
          job_name: my-batch-job
        requests:
          - body:
              max_tokens: 200
              messages:
                - content: 'Summarize: Small sample text...'
                  role: user
              model: openai/gpt-4o-mini
              temperature: 0.2
            custom_id: item-1
            method: POST
            url: /v1/chat/completions
          - body:
              messages:
                - content: 'Translate to French: Hello world'
                  role: user
              model: openai/gpt-4o-mini
            custom_id: item-2
            method: POST
            url: /v1/chat/completions
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BatchRequestItem:
      properties:
        custom_id:
          type: string
          title: Custom Id
        method:
          type: string
          title: Method
          default: POST
        url:
          type: string
          title: Url
          default: /v1/chat/completions
        body:
          additionalProperties: true
          type: object
          title: Body
      type: object
      required:
        - custom_id
        - body
      title: BatchRequestItem
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````