# Models batch create

`POST /models/v1/batches` · Rivier · models

Many completions, embeddings or speech requests of one kind, run in the background under the project's limits. The same idempotency key answers the batch it started, so a retry never starts a second one. models.batch.completed reaches the project's webhooks when it ends.

- Scope: models:write
- Graphql: Mutation.modelsBatchCreate
- Sdk: models.batch.create
- Cli: models batch create
- Events: models.batch.completed

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "chat",
        "embeddings",
        "speech"
      ]
    },
    "requests": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "Your id for the request; the result carries it"
          },
          "body": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "required": [
          "id",
          "body"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 500
    },
    "idempotencyKey": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "The same key answers the batch it started, so a retry never starts a second one"
    },
    "purpose": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{0,39}$"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "kind",
    "requests",
    "idempotencyKey"
  ],
  "additionalProperties": false
}
```

## Responses

- `202`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/models/v1/batches' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "kind": "chat",
  "requests": [
    {
      "id": "string",
      "body": {}
    }
  ],
  "idempotencyKey": "string"
}'
```
