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

# Create Batch

> Create a chat batch.

Send the JSONL file as the `file` part of a multipart form, or upload it first with
POST /v3/upload with `purpose` set to `batch` and send its `file_id` as `input_file_id`
in a JSON body, the shape the
OpenAI SDK's `batches.create` sends. Both are validated the same way.

The batch runs on the model's provider, OpenAI, Anthropic, Mistral, Amazon Bedrock or
Vertex AI, within 24 hours at the
model's batch rates. Batch `metadata` is kept by Eden AI and sent to OpenAI and Mistral. Poll
GET /v3/batches/{batch_id} until `status` is `completed`, `failed`, `expired` or
`cancelled`, then read the results from GET /v3/batches/{batch_id}/results.



## OpenAPI

````yaml https://api.edenai.run/v3/docs/openapi.json post /v3/batches
openapi: 3.1.0
info:
  title: Eden AI API V3
  version: 3.0.0
servers:
  - url: https://api.edenai.run
    description: Production server
security: []
paths:
  /v3/batches:
    post:
      tags:
        - Batches
      summary: Create Batch
      description: >-
        Create a chat batch.


        Send the JSONL file as the `file` part of a multipart form, or upload it
        first with

        POST /v3/upload with `purpose` set to `batch` and send its `file_id` as
        `input_file_id`

        in a JSON body, the shape the

        OpenAI SDK's `batches.create` sends. Both are validated the same way.


        The batch runs on the model's provider, OpenAI, Anthropic, Mistral,
        Amazon Bedrock or

        Vertex AI, within 24 hours at the

        model's batch rates. Batch `metadata` is kept by Eden AI and sent to
        OpenAI and Mistral. Poll

        GET /v3/batches/{batch_id} until `status` is `completed`, `failed`,
        `expired` or

        `cancelled`, then read the results from GET
        /v3/batches/{batch_id}/results.
      operationId: create_batch_v3_batches_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_create_batch_v3_batches_post'
          application/json:
            schema:
              additionalProperties: false
              description: >-
                The JSON create body of OpenAI's batch API
                (``client.batches.create``), naming a file

                uploaded through ``POST /v3/upload`` in place of the multipart
                file part. Any other field is

                a 422 naming it, ``output_expires_after`` included: results are
                kept as long as OpenAI

                keeps them for every batch here (`jobs.results_promised_until`).
              properties:
                input_file_id:
                  description: >-
                    The `file_id` `POST /v3/upload` returned for the JSONL file
                    of requests.
                  format: uuid
                  title: Input File Id
                  type: string
                endpoint:
                  default: /v1/chat/completions
                  description: >-
                    The endpoint every line calls. Only `/v1/chat/completions`
                    is accepted.
                  title: Endpoint
                  type: string
                completion_window:
                  default: 24h
                  description: Only `24h` is accepted.
                  title: Completion Window
                  type: string
                metadata:
                  anyOf:
                    - additionalProperties:
                        type: string
                      type: object
                    - type: 'null'
                  description: >-
                    Up to 14 string pairs attached to the batch, keys at most 64
                    characters and values at most 512. The keys `eden_batch_id`
                    and `eden_request_id` are reserved.
                  title: Metadata
                webhook_receiver:
                  anyOf:
                    - type: string
                    - type: 'null'
                  title: Webhook Receiver
                  description: URL notified once the batch has finished and settled.
              required:
                - input_file_id
              title: BatchCreateFromFile
              type: object
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchObject'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - AuthBearer: []
components:
  schemas:
    Body_create_batch_v3_batches_post:
      properties:
        file:
          anyOf:
            - type: string
              format: binary
            - type: 'null'
          title: File
          description: >-
            The requests, JSONL: at most 5000 lines and 100 MB. Each line is
            `{"custom_id", "method": "POST", "url": "/v1/chat/completions",
            "body"}`, `body` a chat completion body whose `model` is
            `openai/<model>`, `anthropic/<model>`, `mistral/<model>`,
            `amazon/<model>@eu` or `vertex/<model>@eu`, the same on every line.
            An Amazon Bedrock batch needs at least 100 lines (AWS's minimum per
            job) and its line takes `messages` of text, `max_tokens`,
            `temperature`, `top_p` and `stop` only. A Vertex AI line takes the
            same fields and a batch has no minimum. An Anthropic line states no
            `n`, `logprobs`, `response_format` or `cache_control`, and its
            `custom_id` is 1 to 64 letters, digits, hyphens or underscores. A
            Mistral line takes `messages` (`role` and text `content` only),
            `max_tokens`, `temperature`, `top_p`, `stop`, `n`,
            `presence_penalty`, `frequency_penalty` and `response_format`.
            Required in a multipart request; a JSON request names an uploaded
            file in `input_file_id` instead.
        metadata:
          anyOf:
            - type: string
            - type: 'null'
          title: Metadata
          description: >-
            A JSON object of up to 14 string pairs attached to the batch. The
            keys `eden_batch_id` and `eden_request_id` are reserved.
        webhook_receiver:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Receiver
          description: URL notified once the batch has finished and settled.
      type: object
      title: Body_create_batch_v3_batches_post
    BatchObject:
      properties:
        id:
          type: string
          title: Id
          description: The batch id.
        object:
          type: string
          const: batch
          title: Object
          description: Always `batch`.
          default: batch
        endpoint:
          type: string
          title: Endpoint
          description: The endpoint every request of the batch calls.
          default: /v1/chat/completions
        model:
          type: string
          title: Model
          description: >-
            The model id every line of the batch named, as written:
            `openai/<model>`, `anthropic/<model>`, `mistral/<model>`,
            `amazon/<model>@eu` or `vertex/<model>@eu`, or an alias of it.
        status:
          type: string
          enum:
            - validating
            - in_progress
            - finalizing
            - completed
            - failed
            - expired
            - cancelling
            - cancelled
          title: Status
          description: Where the batch is in its lifecycle.
        request_counts:
          $ref: '#/components/schemas/BatchRequestCounts'
          description: How many requests have finished, refreshed every few minutes.
        metadata:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Metadata
          description: The key/value pairs given at create.
        created_at:
          type: integer
          title: Created At
          description: When the batch was created, Unix seconds.
        finished_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Finished At
          description: When the batch finished and settled, Unix seconds.
        cost:
          anyOf:
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Cost
          description: >-
            What the batch billed, in US dollars, once it finished; null before.
            Each request that succeeded bills its tokens at the model's batch
            rates; a failed one, or one that never ran, bills zero. A request
            that succeeded with no token count bills an estimate at the same
            rates: its prompt tokens, the output its response shows and a
            reasoning allowance, the output never above the most the request
            could produce. A request the provider counts as completed with no
            result line bills the same estimate with no output shown. When the
            results cannot be read, every request that may have run bills that
            estimate.
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Why the batch failed, when it did.
        results_available:
          type: boolean
          title: Results Available
          description: >-
            Whether `GET /v3/batches/{batch_id}/results` is sure to serve this
            batch, read from the stored batch with no call to the provider: it
            has finished, was created at the provider, its recorded provider
            status is ended, and it was created less than 30 days ago, less one
            hour (29 days on Anthropic, which keeps results for 29 days:
            `jobs.results_promised_until`); past it this reads false, and the
            results route still tries and answers 410 once the results are gone.
            False while the batch runs, and for a batch that ended before the
            provider accepted it. A batch settled past its deadline before the
            provider ended it reads false, and the results route checks the
            provider live and can still serve it.
          default: false
      type: object
      required:
        - id
        - model
        - status
        - created_at
      title: BatchObject
      description: A chat batch.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BatchRequestCounts:
      properties:
        total:
          type: integer
          title: Total
          description: Requests in the batch.
          default: 0
        completed:
          type: integer
          title: Completed
          description: Requests that succeeded.
          default: 0
        failed:
          type: integer
          title: Failed
          description: Requests that failed.
          default: 0
      type: object
      title: BatchRequestCounts
      description: >-
        How many of the batch's requests have finished, as the provider last
        reported them.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    AuthBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.