# Create a batch

Launch stage: Beta

`POST /api/2.0/ai-functions/batches`

Creates a batch that runs an AI function on every request in a JSONL file on a Unity Catalog volume. The batch runs asynchronously. To follow its progress, get the batch.

API scopes: ai-functions

## Request body

The batch to create.
- `endpoint` (string, required)
  The AI function, for example `ai_parse_document`.
- `input_ref` (string, required)
  Unity Catalog volume path of the JSONL input file. Each line is one request, in the form `{"custom_id": ..., "body": ...}`. The file can hold up to 50,000 requests and be up to 200 MiB.
- `params` (object, optional)
  Parameters of the function other than its input, applied to every request in the batch, for example
   `schema` for `ai_extract`. Put function options, such as `version`, in a nested `options` object. For
   the parameters of each function, see [AI Functions](https://docs.databricks.com/large-language-models/ai-functions).
- `output_ref` (string, required)
  Unity Catalog volume path to write the JSONL output file to. If the path is a directory, the file is `<path>/<name>_output.jsonl`.

## Returns

Returns the Batch object.

## Response

```json
{
  "name": "string",
  "endpoint": "string",
  "input_ref": "string",
  "params": {},
  "output_ref": "string",
  "status": "PENDING",
  "create_time": "string",
  "request_counts": {
    "total": 0,
    "succeeded": 0,
    "failed": 0
  },
  "percent_complete": 0
}
```

