Start several runs
const url = 'https://api.nuveki.ai/api/v0/runs/batch';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"runs":[{"agent":"data.analyst","input":"Classify ticket SUP-1042 as billing, bug or question: …","metadata":{"ticket":"SUP-1042"},"idempotencyKey":"classify-SUP-1042"},{"agent":"data.analyst","input":"Classify ticket SUP-1043 as billing, bug or question: …","metadata":{"ticket":"SUP-1043"},"idempotencyKey":"classify-SUP-1043"},{"agent":"data.analyst","input":"Classify ticket SUP-1044 as billing, bug or question: …","metadata":{"ticket":"SUP-1044"},"idempotencyKey":"classify-SUP-1044"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.nuveki.ai/api/v0/runs/batch \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "runs": [ { "agent": "data.analyst", "input": "Classify ticket SUP-1042 as billing, bug or question: …", "metadata": { "ticket": "SUP-1042" }, "idempotencyKey": "classify-SUP-1042" }, { "agent": "data.analyst", "input": "Classify ticket SUP-1043 as billing, bug or question: …", "metadata": { "ticket": "SUP-1043" }, "idempotencyKey": "classify-SUP-1043" }, { "agent": "data.analyst", "input": "Classify ticket SUP-1044 as billing, bug or question: …", "metadata": { "ticket": "SUP-1044" }, "idempotencyKey": "classify-SUP-1044" } ] }'Up to 20 runs in one call, each the body POST /api/v0/runs takes. A key that works in no project, or in an archived one, has its batch refused whole (KEY_PROJECT_MISSING, PROJECT_ARCHIVED): nothing of it is recorded, a resend is refused the same way, and the runs an earlier send recorded stay readable. Otherwise every run is recorded and answered at once (queued), carrying the batch’s id; they then start in order, as many at a time as the key may have in progress (runs continuing one conversation one after another), each billed and limited as a single run. Every run starts within 10 minutes of the batch or ends refused with RUN_NOT_STARTED: a run held back by the key’s places or run rate waits for them inside that time, while a limit that will not lift in it (a spend cap, the budget, a revoked key) ends that run and every run after it. A run the budget refuses as over its per-minute budget on its own (exceedsPerMinuteLimit) ends alone, and the others still start. Its runs count as requests: a key may send 120 runs a minute in batches, and an address 600, past which a batch is refused RATE_LIMITED. A batch is refused KEY_QUEUE_FULL when the server it reaches already holds what it may of batch runs waiting or running — 100 of the key’s, or 32 MiB of its organization’s requests — or as many batched requests as it can. Read the runs with GET /api/v0/runs?batchId=.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The runs, each the body POST /api/v0/runs takes, without wait: 1 to 20. Give each an idempotencyKey to resend the batch safely.
object
The agent to answer, by username. Not with team. Leave out both to let the run choose among what this key may run.
The team to answer, by username: its agents this key may run take the request together. Not with agent.
What to ask, with any material the agent needs.
Continue a conversation an earlier run of this key opened, with its history: the conversationId that run returned.
Pictures for the agent to look at, as base64 data URLs of a JPEG, PNG, WebP or GIF.
Files for the agent to read, stored with the run and handed to the agent as a chat attachment is: text as text, anything else (PDF, Word, Excel, PowerPoint, OpenDocument) as base64 data, typed by its name. The platform checks the input — the request — not the material it is handed. An agent that cannot read a file it is handed is refused before the run is admitted.
object
The file name the agent sees: a letter or digit in it, no path, no space at either end or dot at the end, no control or invisible formatting characters. With data, its extension decides the type, which must be one the platform reads (PDF, Word, Excel, PowerPoint, OpenDocument, an image, a text format…).
The file as text. Exactly one of text and data.
The file as base64, for a file that is not text: a PDF, a spreadsheet, a slide deck. Exactly one of text and data.
Your own labels for the run’s conversation, kept with it and never read as an instruction.
object
route: an @mention in the input routes to an agent or team this key may run, as in a chat. ignore: the input is plain text. A run with output or tools: 'none' is one agent’s turn, so its mentions are always ignored, and route beside either is refused.
Your own unique value for this request, so a retry cannot start a second run: a repeat with the same value is answered with the first run, while this key keeps it. Reusing a value for a different request is refused (422). A run that was refused, failed, interrupted or abandoned by a caller that hung up frees its value, so the retry runs; an answered run, or one you cancelled, keeps it. On REST you may send the Idempotency-Key header instead.
none: the agent is offered no tools and no fixer runs after it, so it answers from the input alone — for a program that hands it everything it needs and wants nothing in the input to steer a call. Needs agent.
Ask the agent for one JSON document matching a schema instead of prose. The run answers it as output.json, or says in output.violation why the reply was not one. Needs agent.
object
The shape’s name, snake_case, up to 64 characters: providers name the schema with it.
A JSON Schema (draft-07) the whole answer must match, at most 32,000 characters serialized. Its descriptions are read by the agent as part of the platform’s instruction and are not security-checked: it is the program’s own configuration, so never build it from your users’ text — that goes in input. No pattern or patternProperties: a regular expression would run on the server, so say a format in the description instead. A schema whose check of an answer runs too long is answered as invalid_schema.
object
Examples
Classify three tickets
{ "runs": [ { "agent": "data.analyst", "input": "Classify ticket SUP-1042 as billing, bug or question: …", "metadata": { "ticket": "SUP-1042" }, "idempotencyKey": "classify-SUP-1042" }, { "agent": "data.analyst", "input": "Classify ticket SUP-1043 as billing, bug or question: …", "metadata": { "ticket": "SUP-1043" }, "idempotencyKey": "classify-SUP-1043" }, { "agent": "data.analyst", "input": "Classify ticket SUP-1044 as billing, bug or question: …", "metadata": { "ticket": "SUP-1044" }, "idempotencyKey": "classify-SUP-1044" } ]}Responses
Section titled “Responses”The batch is recorded: one item per request, in order. Read its runs at Location.
object
The batch’s id: every run it recorded carries it as batchId. List them with GET /api/v0/runs?batchId=.
object
object
The run’s id: read it with GET /api/v0/runs/{id}, cancel it with POST /api/v0/runs/{id}/cancel.
queued and running until it ends. completed: an agent answered. no_answer: the agent wrote nothing, and notice says why. blocked: the platform’s security check declined the input before any agent ran. refused: a limit or a rule refused it before it started; failed: it stopped after it started; cancelled: it was cancelled, or its caller hung up. Those three carry error.
object
auto: neither was named, and the run chose among what this key may run.
The agent or team named; absent for auto.
Every agent that took part in the run, the answering one included.
object
object
The answer, as the agent wrote it (Markdown). When status is no_answer, the platform’s note saying why, never the agent’s words; empty when blocked. A structured run’s reply as written, kept for a program that logs it.
The files the run’s answers made (a generated picture, a page, an export), oldest first, at most 20, never the run’s own inputs.
object
The file’s id: the one the answer’s own /api/files/proxy/<id> references name.
In bytes.
A signed download link for this key’s identity, good until expiresAt.
object
empty: no reply. not_json: the reply was not one JSON document (prose around it counts). schema: valid JSON in the wrong shape. invalid_schema: the schema could not be used to check the reply — it does not compile, or checking ran past its budget — so simplify it rather than ask again.
At most five of the validator’s errors.
object
What the run’s model, embedding and tool calls were billed, in US dollars to the micro-dollar, as booked so far: the same amount its organization is charged and the key’s spend caps count, so a run on a cheap model reads what it cost rather than 0. Calls an agent makes on its owner’s own endpoint (a custom model) are billed 0. Paid web retrieval is counted on the key’s daily usage only.
True when run is an earlier run its idempotencyKey named, not a new one.
Example
{ "object": "batch", "data": [ { "run": { "object": "run", "status": "queued", "target": { "kind": "agent" }, "output": { "files": [ { "mimeType": "image/png" } ], "violation": { "reason": "empty" } }, "notice": { "kind": "content_filter" }, "usage": { "costUsd": 0.001623 } } } ]}Headers
Section titled “Headers”unstable: /v0 may change without notice.
This request’s id: the X-Request-Id you sent, when it is at most 128 letters, digits and ._:-, otherwise one of ours. Every refusal carries it too; quote it to support.
Where to read the batch’s runs: /api/v0/runs?batchId={id}.
The request broke a rule (an unknown field or parameter is one): message lists each.
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}The key is missing, unknown, revoked or expired, or its organization has no admin left who could revoke it.
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}The key runs nothing, so no run of the batch is recorded. KEY_PROJECT_MISSING: the key works in no project, since its project was deleted or the key was taken out of it; an organization admin gives it one. PROJECT_ARCHIVED: the key’s project is archived, so nothing runs in it until it is unarchived. A resend of an earlier batch is refused the same way; the runs it recorded stay readable with GET /api/v0/runs. A run the key may not make is refused in its own item.
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}The body is over the server’s 25 MiB limit (26,214,400 bytes).
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}KEY_QUEUE_FULL: the server this batch reached already holds as many batch runs, waiting or running, as it holds for this key, or as many bytes of batched requests as it holds for this key’s organization, or as many as it can in all; send it once some have ended (retryAfter). Or code RATE_LIMITED: this key’s requests to this route came too fast (a bearer that is not an API key is counted by its address), or this address passed 600 requests a minute (a ceiling every key behind one address shares); a batch counts one request for each of its runs, up to 120 a minute for a key and 600 for an address.
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}Headers
Section titled “Headers”Seconds to wait before trying again; the same as retryAfter.
The server failed before it could answer (a database outage, say). message is always Internal server error, with no detail; try again.
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}ADMISSION_UNAVAILABLE: the key’s runs in progress cannot be counted right now, so none starts. Try again after retryAfter seconds (no Retry-After header).
A refusal may carry more fields than these: a refusal by the organization’s budget adds its plan and figures: tier; the daily, monthly and per-minute amounts used and allowed and the credit balance, in US dollars (dailyBudgetUsedUsd, dailyBudgetLimitUsd, …); and its reset times.
object
The HTTP status name, or — when the organization’s budget refused the run — its reason: DAILY_LIMIT_EXCEEDED, MONTHLY_LIMIT_EXCEEDED, RATE_LIMIT_EXCEEDED, INSUFFICIENT_CREDITS, MODEL_NOT_ALLOWED, BUDGET_BLOCKED; or model_unavailable when the agent’s model, on someone’s own endpoint, cannot run: its connection is turned off, the model was removed, or the connection’s owner left its organization.
A refusal a program can act on without reading message: a key, run or capacity limit, or RATE_LIMITED when requests from one address or to one route came too fast.
Seconds to wait before trying again. A 429 that carries it also sends it as the Retry-After header.
Seconds until the organization’s budget resets, on a refusal by that budget.
True when the run’s own estimated cost is above the organization’s per-minute budget: no wait lets it through, so retryAfterSeconds is absent, and code is RUN_OVER_PER_MINUTE_BUDGET. Send a smaller request.
The conversation of a run stopped after it started: what it wrote and paid for before it stopped.
The run this refusal answers, kept with it: read it with GET /api/v0/runs/{id}, and quote it to support.
Example
{ "code": "KEY_RATE_LIMIT_EXCEEDED"}