Run a batch

POST /api/v1/batch — run up to 100 Ostra Decision tasks in one request, mixed tasks allowed, at half the price.

POSThttps://ostra.testrelic.ai/api/v1/batch

Runs up to 100 Ostra Decision tasks in one request, mixed tasks allowed, at half the price.

Each item is answered independently: one bad item fails on its own and the rest still answer. Results come back in input order, with your custom_id. Items run 8 at a time with a 25-second deadline for the whole batch; items that don’t start in time fail with upstream_timeout and are refunded.

Auth
Authorization: Bearer $OSTRA_API_KEY. Needs a Full-access key.
Rate limit
Counts against your workspace's requests per minute.
Cost
Each item costs half its /predict price (rounded up to the nano-dollar). Failed and cached items are free. If the balance can’t cover the whole batch, the whole batch is refused with 402.
curl https://ostra.testrelic.ai/api/v1/batch \
  -H "Authorization: Bearer $OSTRA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "ostra-lite",
    "items": [
      {
        "custom_id": "checkout-applies-coupon",
        "task": "triage",
        "input": {
          "test_id": "checkout.spec.ts > applies coupon",
          "run_id": "gha-18241",
          "context": {
            "framework": "playwright",
            "capture_level": "full",
            "error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n  waiting for locator('\''#apply-coupon'\'')",
            "action": "click",
            "locator": {
              "strategy": "css"
            },
            "diff": {
              "files_changed": 3,
              "lines_added": 41,
              "lines_removed": 12,
              "touches_test_file": false,
              "touches_selector_file": false,
              "locator_values_removed": false
            },
            "dom": {
              "locator_found": true
            },
            "memory": {
              "runs_50": 40,
              "flake_rate_50": 0.15,
              "failed_count_50": 6,
              "signature_repeat_count": 5
            }
          }
        }
      },
      {
        "custom_id": "orders-lists-orders",
        "task": "triage",
        "input": {
          "test_id": "orders.api.spec.ts > lists orders",
          "context": {
            "framework": "jest",
            "error_message": "Error: Request failed with status code 503 (Service Unavailable) GET /api/orders",
            "action": "api_call"
          }
        }
      },
      {
        "custom_id": "coupon-locators",
        "task": "selector_survival",
        "input": {
          "locators": [
            {
              "locator_id": "checkout.apply-coupon",
              "strategy": "css",
              "dom_locator_found": true,
              "history": [
                {
                  "release": "2026.10.1",
                  "resolve_rate": 1
                },
                {
                  "release": "2026.10.2",
                  "resolve_rate": 0.92
                },
                {
                  "release": "2026.11.1",
                  "resolve_rate": 0.71
                }
              ]
            },
            {
              "locator_id": "nav.account-menu",
              "strategy": "role",
              "dom_locator_found": true,
              "history": [
                {
                  "release": "2026.10.2",
                  "resolve_rate": 1
                },
                {
                  "release": "2026.11.1",
                  "resolve_rate": 1
                }
              ]
            }
          ]
        }
      }
    ]
  }'
Headers
x-request-id
req_01JDXK4M7Q2N8R5T6V9W3Y1Z0A
ostra-ratelimit-requests-limit
600
ostra-ratelimit-requests-remaining
597
ostra-ratelimit-requests-reset
42
ostra-balance-remaining-usd
24.99999875
{
  "id": "req_01JDXK7Z8Y7X6W5V4U3T2S1R0Q",
  "model": "ostra-lite@v.beta.5",
  "billed": {
    "units": 4,
    "costNano": 750,
    "costUsd": "0.00000075"
  },
  "results": [
    {
      "custom_id": "checkout-applies-coupon",
      "ok": true,
      "task": "triage",
      "cached": false,
      "output": {
        "decision_id": "dec_5b0c9e2a7f3d4e18a6b2c9d0e1f4a7b3",
        "task": "triage",
        "decision": "flaky",
        "value": "flaky",
        "p": 0.83,
        "probabilities": {
          "flaky": 0.83,
          "product_bug": 0.06,
          "test_bug": 0.05,
          "environment": 0.04,
          "selector_drift": 0.02
        },
        "threshold": 0.6,
        "defer_reason": null,
        "decided_by": "model",
        "rule": null,
        "model": {
          "release": "v.beta.5",
          "version": "1.4.0",
          "content_hash": "sha256:3f9a1c07d2e4b8a6",
          "gate_passed": true
        },
        "test_id": "checkout.spec.ts > applies coupon",
        "run_id": "gha-18241",
        "error_class": "timeout",
        "error_class_source": "error_message"
      }
    },
    {
      "custom_id": "orders-lists-orders",
      "ok": true,
      "task": "triage",
      "cached": false,
      "output": {
        "decision_id": "dec_6f708192a3b4c5d6e7f8091a2b3c4d5e",
        "task": "triage",
        "decision": "environment",
        "value": "environment",
        "p": 0.74,
        "probabilities": {
          "flaky": 0.12,
          "product_bug": 0.08,
          "test_bug": 0.03,
          "environment": 0.74,
          "selector_drift": 0.03
        },
        "threshold": 0.6,
        "defer_reason": null,
        "decided_by": "model",
        "rule": null,
        "model": {
          "release": "v.beta.5",
          "version": "1.4.0",
          "content_hash": "sha256:3f9a1c07d2e4b8a6",
          "gate_passed": true
        },
        "test_id": "orders.api.spec.ts > lists orders",
        "run_id": null,
        "error_class": "network_error",
        "error_class_source": "error_message"
      }
    },
    {
      "custom_id": "coupon-locators",
      "ok": true,
      "task": "selector_survival",
      "cached": false,
      "output": {
        "decisions": [
          {
            "decision_id": "dec_4d5e6f708192a3b4c5d6e7f8091a2b3c",
            "task": "selector_survival",
            "decision": "breaks",
            "value": "breaks",
            "p": 0.78,
            "probabilities": {
              "survives": 0.22,
              "breaks": 0.78
            },
            "threshold": 0.6,
            "defer_reason": null,
            "decided_by": "model",
            "rule": null,
            "model": {
              "release": "v.beta.5",
              "version": "1.2.0",
              "content_hash": "sha256:5d21f0e9c4a7b3e8",
              "gate_passed": true
            },
            "locator_id": "checkout.apply-coupon"
          },
          {
            "decision_id": "dec_5e6f708192a3b4c5d6e7f8091a2b3c4d",
            "task": "selector_survival",
            "decision": "survives",
            "value": "survives",
            "p": 0.96,
            "probabilities": {
              "survives": 0.96,
              "breaks": 0.04
            },
            "threshold": 0.6,
            "defer_reason": null,
            "decided_by": "model",
            "rule": null,
            "model": {
              "release": "v.beta.5",
              "version": "1.2.0",
              "content_hash": "sha256:5d21f0e9c4a7b3e8",
              "gate_passed": true
            },
            "locator_id": "nav.account-menu"
          }
        ]
      }
    }
  ]
}

Request body

  • modelstringRequired

    Always ostra-lite.

    Valueostra-lite
  • itemsarray of objectsRequired

    The tasks to run. Each item counts as one request against your rate limit.

    1–100 items
    Show 3 child fields
    • custom_idstring

      Your id for the item, echoed in its result. Longer values are cut to 128 characters.

      0–128 chars
    • taskstringRequired

      Which task to run.

      One oftriagetest_impactselector_survival
    • inputobjectRequired

      The task’s input, as for /predict.

Response

  • idstring

    Request id.

  • modelstring

    The model and release that answered.

  • billedobject

    What this request cost. Cached answers cost 0.

    Show 3 child fields
    • unitsinteger

      Billable units: 1 per failure (triage), 1 per request (test impact), 1 per locator (selector survival). 0 for a cached answer.

    • costNanointeger

      Cost in nano-dollars (1 USD = 1,000,000,000).

    • costUsdstring

      Cost in USD as an exact decimal string, e.g. "0.0000005".

  • resultsarray of objects

    One result per item, in input order.

    Show 6 child fields
    • custom_idstring

      Your custom_id, when you sent one.

    • okboolean

      true when the item answered.

    • taskstring

      The item’s task.

    • cachedboolean

      When ok: the answer came from cache.

    • outputobject

      When ok: the task’s answer, as for /predict.

    • errorobject

      When not ok: { "type", "message" }.

      Show 2 child fields
      • typestring

        Error type, e.g. invalid_request or upstream_error.

      • messagestring

        What went wrong.

Response headers

  • x-request-idstring

    Id of this request (req_ + 26 characters). Quote it to support.

  • ostra-ratelimit-requests-limitinteger

    Your workspace’s requests-per-minute limit.

  • ostra-ratelimit-requests-remaininginteger

    Requests left in the current minute.

  • ostra-ratelimit-requests-resetinteger

    Seconds until the current minute ends and the count resets.

  • ostra-balance-remaining-usdstring

    Workspace credit balance after this request, in USD. Approximate under concurrent requests.

Errors

StatusTypeWhen
400invalid_requestitems is missing, empty, or longer than 100. Per-item problems come back inside results instead.
413payload_too_largeThe body is larger than 2 MB.
401authentication_errorThe API key is missing, malformed, unknown, revoked or expired.
403permission_errorThe caller’s IP isn’t in the key’s allowlist, or a read-only key called a route that needs full access.
402insufficient_balanceYour credit balance doesn’t cover the request. Nothing is charged.
402spend_limit_reachedThe workspace’s monthly spend limit (scope: "org") or this key’s monthly spend cap (scope: "key") is reached.
429rate_limit_exceededThe workspace’s requests-per-minute limit is reached. Wait Retry-After seconds.
503service_unavailableToo many requests are updating the workspace balance at once. Nothing was charged; retry after Retry-After (1 s).

Every error has the same envelope and a request_id. See Errors for messages and retry advice.

Was this page helpful?