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

# Create Batch

> Create a new batch of API requests.



## OpenAPI

````yaml /openai-api-swagger.json post /v1/batches
openapi: 3.1.0
info:
  title: impala.ai OpenAI API v0.1.0
  description: >-
    An OpenAI API compatible server for impala.ai


    All timestamps are Unix epoch seconds, UTC. A null `*_at` field means the
    event did not occur for this run.


    All costs in USD.
  version: 0.1.0
servers: []
security: []
paths:
  /v1/batches:
    post:
      tags:
        - batches
      summary: Create Batch
      description: Create a new batch of API requests.
      operationId: create_batch_v1_batches_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBatchRequestModel'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchModel'
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseModel'
          description: Not Found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseModel'
          description: Unprocessable Content
components:
  schemas:
    CreateBatchRequestModel:
      properties:
        completion_window:
          type: string
          title: Completion Window
          description: >-
            The time frame within which the batch should be processed. Currently
            only `unlimited` is supported.
        endpoint:
          type: string
          title: Endpoint
          description: >-
            The endpoint to be used for all requests in the batch. Currently
            `v1/responses`, `v1/chat/completions`, `v1/embeddings`, and
            `v1/completions` are supported. Note that `v1/embeddings` batches
            are also restricted to a maximum of 50,000 embedding inputs across
            all requests in the batch.
        input_file_id:
          type: string
          title: Input File Id
          description: >-
            The ID of an uploaded file that contains requests for the new batch.
            See upload file for how to upload a file. Your input file must be
            formatted as a JSONL file, and must be uploaded with the purpose
            batch. The file can contain up to 50,000 requests, and can be up to
            200 MB in size.
        job_id:
          type: string
          title: Job Id
          description: >-
            ID of the Job definition this batch belongs to. Links the batch to a
            specific model, use case, and SLA.
        metadata:
          additionalProperties:
            type: string
          type: object
          title: Metadata
          description: >-
            Set of 16 key-value pairs that can be attached to an object. This
            can be useful for storing additional information about the object in
            a structured format, and querying for objects via API or the
            dashboard. Keys are strings with a maximum length of 64 characters.
            Values are strings with a maximum length of 512 characters.
        output_expires_after:
          anyOf:
            - $ref: '#/components/schemas/FileExpirationModel'
            - type: 'null'
          description: >-
            The expiration policy for the output and/or error file that are
            generated for a batch.
      type: object
      required:
        - completion_window
        - endpoint
        - input_file_id
        - job_id
      title: CreateBatchRequestModel
    BatchModel:
      properties:
        cancelled_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Cancelled At
          description: The Unix timestamp (in seconds) for when the batch was cancelled.
        cancelling_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Cancelling At
          description: >-
            The Unix timestamp (in seconds) for when the batch started
            cancelling.
        completed_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Completed At
          description: The Unix timestamp (in seconds) for when the batch was completed.
        completion_window:
          type: string
          title: Completion Window
          description: The time frame within which the batch should be processed.
        created_at:
          type: integer
          title: Created At
          description: The Unix timestamp (in seconds) for when the batch was created.
        endpoint:
          type: string
          title: Endpoint
          description: The OpenAI API endpoint used by the batch.
        error_file_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error File Id
          description: The ID of the file containing the outputs of requests with errors.
        errors:
          anyOf:
            - $ref: '#/components/schemas/BatchErrorsModel'
            - type: 'null'
          description: The errors encountered during batch processing.
        expired_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expired At
          description: The Unix timestamp (in seconds) for when the batch expired.
        expires_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expires At
          description: The Unix timestamp (in seconds) for when the batch will expire.
        failed_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Failed At
          description: The Unix timestamp (in seconds) for when the batch failed.
        finalizing_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Finalizing At
          description: >-
            The Unix timestamp (in seconds) for when the batch started
            finalizing.
        id:
          type: string
          title: Id
          description: The unique identifier for the batch.
        job_id:
          type: string
          title: Job Id
          description: ID of the Job definition this batch belongs to.
        in_progress_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: In Progress At
          description: >-
            The Unix timestamp (in seconds) for when the batch started
            processing.
        input_file_id:
          type: string
          title: Input File Id
          description: The ID of the input file for the batch.
        metadata:
          additionalProperties:
            type: string
          type: object
          title: Metadata
          description: >-
            Set of 16 key-value pairs that can be attached to an object. This
            can be useful for storing additional information about the object in
            a structured format, and querying for objects via API or the
            dashboard. Keys are strings with a maximum length of 64 characters.
            Values are strings with a maximum length of 512 characters.
        model:
          type: string
          title: Model
          description: The model used for this batch run.
          default: ''
        object:
          type: string
          const: batch
          title: Object
          description: The object type, which is always `batch`.
          default: batch
        output_file_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Output File Id
          description: >-
            The ID of the file containing the outputs of successfully executed
            requests.
        price_1m_tokens:
          type: number
          title: Price 1M Tokens
          description: Effective price in USD per 1,000,000 tokens.
          default: 0
        request_counts:
          $ref: '#/components/schemas/RequestCountsModel'
          description: The request counts for different statuses within the batch.
        status:
          $ref: '#/components/schemas/BatchStatus'
          description: The current status of the batch.
        processing_cost:
          type: number
          title: Processing Cost
          description: Total processing cost in USD.
          default: 0
        usage:
          $ref: '#/components/schemas/CompletionUsageModel'
          description: Usage statistics for the completion request.
      type: object
      required:
        - completion_window
        - created_at
        - endpoint
        - id
        - job_id
        - input_file_id
        - request_counts
        - status
      title: BatchModel
    ErrorResponseModel:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: The error details.
      type: object
      required:
        - error
      title: ErrorResponseModel
    FileExpirationModel:
      properties:
        anchor:
          type: string
          const: created_at
          title: Anchor
          description: >-
            Anchor timestamp after which the expiration policy applies.
            Supported anchors: `created_at`.
        seconds:
          type: integer
          maximum: 2592000
          minimum: 3600
          title: Seconds
          description: >-
            The number of seconds after the anchor time that the file will
            expire. Must be between 3600 (1 hour) and 2592000 (30 days).
      type: object
      required:
        - anchor
        - seconds
      title: FileExpirationModel
    BatchErrorsModel:
      properties:
        data:
          items:
            $ref: '#/components/schemas/BatchErrorModel'
          type: array
          title: Data
          description: A list of errors encountered during batch processing.
        object:
          type: string
          const: list
          title: Object
          description: The object type, which is always `list`.
          default: list
      type: object
      required:
        - data
      title: BatchErrorsModel
    RequestCountsModel:
      properties:
        completed:
          type: integer
          title: Completed
          description: Number of requests that have been completed successfully.
        failed:
          type: integer
          title: Failed
          description: Number of requests that have failed.
        total:
          type: integer
          title: Total
          description: Total number of requests in the batch.
      type: object
      required:
        - completed
        - failed
        - total
      title: RequestCountsModel
    BatchStatus:
      type: string
      enum:
        - validating
        - failed
        - in_progress
        - finalizing
        - completed
        - expired
        - cancelling
        - cancelled
      title: BatchStatus
    CompletionUsageModel:
      properties:
        prompt_tokens:
          type: number
          title: Prompt Tokens
          description: Number of tokens in the prompt (total input tokens processed).
          default: 0
        completion_tokens:
          type: number
          title: Completion Tokens
          description: Number of tokens in the generated completion.
          default: 0
        total_tokens:
          type: number
          title: Total Tokens
          description: Total number of tokens used in the request (prompt + completion).
          default: 0
      type: object
      title: CompletionUsageModel
      description: Token usage for the batch run (OpenAI / litellm convention).
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: A human-readable error message.
        type:
          type: string
          title: Type
          description: The type of error.
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
          description: The parameter that caused the error, if applicable.
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: An error code, if applicable.
      type: object
      required:
        - message
        - type
      title: ErrorDetail
    BatchErrorModel:
      properties:
        code:
          type: string
          title: Code
          description: An error code identifying the error type.
        line:
          anyOf:
            - type: integer
            - type: 'null'
          title: Line
          description: >-
            The line number of the input file where the error occurred, if
            applicable.
        message:
          type: string
          title: Message
          description: A human-readable message providing more details about the error.
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
          description: The name of the parameter that caused the error, if applicable.
      type: object
      required:
        - code
        - line
        - message
        - param
      title: BatchErrorModel

````