Drex

Submit a batch

- Every task is validated and routed at submit: an invalid or too-long task refuses the whole batch with 422, naming it. - The account's available funds must cover the batch's worst-case cost (402 otherwise), but nothing is held: each task reserves its own funds when it runs, and one the account can no longer pay for ends errored with code insufficient_credit, free. - Batches take text only, not images. - Accounts with zero retention cannot submit batches (422, code zero_retention_unsupported).

POST
/v1/batches
  • Every task is validated and routed at submit: an invalid or too-long task refuses the whole batch with 422, naming it.
  • The account's available funds must cover the batch's worst-case cost (402 otherwise), but nothing is held: each task reserves its own funds when it runs, and one the account can no longer pay for ends errored with code insufficient_credit, free.
  • Batches take text only, not images.
  • Accounts with zero retention cannot submit batches (422, code zero_retention_unsupported).

Authorization

bearerAuth
AuthorizationBearer <token>

Your API key, sent as Authorization: Bearer nace_sk_...

  • Where: the dashboard's API Keys page. It is shown once, when you create it.
  • Format: nace_sk_ followed by 43 URL-safe characters (A-Z, a-z, 0-9, _ and -).
  • Limit: an account can hold at most 3 active keys.
  • Wrong or missing key: returns 401 authentication_error.

In: header

Header Parameters

Idempotency-Keystring

A retried key with the same body returns the same batch (200); with another body, 409.

Lengthlength <= 200

Request Body

application/json

modelstring

As in POST /v1/systemone; every task runs on it. Defaults to the default model.

tasksarray<BatchTask>required
Items1 <= items <= 1000
Show child attributes
metadataobject

Up to 16 KB of your own, returned with the batch.

Show child attributes

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/batches" \  -H "Content-Type: application/json" \  -d '{    "model": "drex-v2.0",    "tasks": [      {        "custom_id": "ticket-1",        "state": "My payout failed twice and payroll is tomorrow.",        "questions": {          "urgent": {            "type": "noul",            "instructions": "Does the customer need help today?"          }        }      },      {        "custom_id": "ticket-2",        "state": "How do I change the logo on my invoices?",        "questions": {          "urgent": {            "type": "noul",            "instructions": "Does the customer need help today?"          }        }      }    ]  }'
{  "id": "string",  "object": "batch",  "status": "in_progress",  "model": "string",  "price_factor": 0,  "task_counts": {    "total": 0,    "queued": 0,    "running": 0,    "succeeded": 0,    "errored": 0,    "expired": 0,    "cancelled": 0  },  "cost_usd": 0,  "metadata": {},  "created_at": "2019-08-24T14:15:22Z",  "expires_at": "2019-08-24T14:15:22Z",  "ended_at": "2019-08-24T14:15:22Z",  "cancel_requested_at": "2019-08-24T14:15:22Z",  "results_available": true}