Tasks
Run a task, and create, read, change, and delete a project’s tasks.
A task fixes a stored prompt, a model, and what one call may send. See Use tasks.
Running a task needs Call models. Reading tasks needs View usage and limits. Creating, changing, and deleting them is for people with Developer access or more, from the console; API keys cannot.
Run a task
/v1/projects/{project}/tasks/{task}/runs{
"input": "My order is late.",
"variables": { "customer": "Amina" },
"history": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Habari. How can I help?" }
]
}inputstringThe text to send, up to the task’s input size. Required when the task takes input, and refused when it takes none.
variablesobjectA value for each variable the task leaves open, each up to its size. A variable the task fixes is refused.
historyarrayEarlier messages of a conversation, oldest first, up to the task’s number and size. Each is
{ "role": "user" or "assistant", "content": "…" }.streambooleantruesends the answer as it is written. See Streaming a run.
The body can be up to 256 KB. Any other field is refused with validation_failed.
{
"data": {
"task": "support-reply",
"model": "openai/gpt-oss-120b",
"text": "Pole sana, Amina. Your order leaves the warehouse today.",
"stopReason": "end",
"usage": { "inputTokens": 212, "outputTokens": 19, "units": 6 }
}
}taskstringThe task that ran.
modelstringThe model that answered.
textstringThe answer. A reasoning model’s reasoning is left out.
jsonanyOnly for a task with JSON answers: the answer parsed as JSON, matching the task’s schema.
stopReasonstringendwhen the model finished,max_tokenswhen it reached the task’s limit, orrefusedwhen it would not answer.usageobjectinputTokens,outputTokens, andunits: what the run used.
The answer has the headers X-Request-Id, and X-Ai-Processed-In naming the country it ran in.
Streaming a run
With "stream": true, the answer is server-sent events, each a JSON object with a type:
data: {"type":"text","text":"Pole sana, "}
data: {"type":"text","text":"Amina."}
data: {"type":"done","stopReason":"end","usage":{"inputTokens":212,"outputTokens":19,"units":6}}textholds the next piece of the answer.donecomes last, withstopReason,usage, andjsonfor a task with JSON answers.errorholds anerrorproblem document when the run fails after it started, and ends the stream. For a task with JSON answers, it comes in place ofdonewhen the answer is not JSON that matches the schema.
A stream that ends without done or error was cut off. Comments starting with : keep the connection open; skip them.
List tasks
/v1/projects/{project}/tasksThe answer is a list of tasks, by name.
Read a task
/v1/projects/{project}/tasks/{task}{
"name": "support-reply",
"description": "Answers customers",
"prompt": { "name": "support-agent", "version": 3, "latestVersion": 4 },
"model": "openai/gpt-oss-120b",
"maxTokens": 400,
"temperature": null,
"topP": null,
"reasoningEffort": "low",
"json": false,
"schema": null,
"input": { "maxBytes": 2000 },
"variables": {
"brand": { "value": "Duka" },
"customer": { "maxBytes": 100 }
},
"history": { "messages": 10, "maxBytes": 8000 },
"enabled": true,
"worstCase": { "inputTokens": 12344, "outputTokens": 400, "units": 5623 },
"createdBy": "01m3c081d2wj4g63qcr53pa1yh",
"createdAt": "2026-09-29T08:00:00Z",
"updatedBy": "01m3c081d2wj4g63qcr53pa1yh",
"updatedAt": "2026-09-29T10:15:00Z"
}prompt.latestVersionintegerThe prompt’s newest version, so you can see when the task is behind it.
worstCaseobjectThe most one run can use, counting every byte a run may send as a token:
inputTokens,outputTokens, andunits. Real runs use far less input.
The other fields are as below.
Create a task
/v1/projects/{project}/tasksnamestring1 to 63 lowercase letters, digits, and hyphens, starting with a letter or digit. It cannot change later.
descriptionstringUp to 500 characters, for your team.
promptobject{ "name", "version" }: the stored prompt and the version to use.modelstringA model from the catalogue.
maxTokensintegerThe most tokens an answer may have, from 1 to the model’s maximum.
temperaturenumber0 to 2, or
nullfor the model’s default.topPnumber0 to 1, or
nullfor the model’s default.reasoningEffortstringlow,medium, orhigh, for a model that reasons. Empty for the default.jsonbooleantrueasks for a JSON object.schemaobjectA JSON schema for the answer, up to 16 KB. Needs
json.input.maxBytesintegerThe most bytes of input a run may send, from 0 (none) to 32,768.
variablesobjectOne entry for each of the prompt’s variables:
{ "value": "…" }to fix it, or{ "maxBytes": n }, from 1 to 32,768, to let a run send it. The prompt’s variables and these must match.history.messagesintegerThe most earlier messages a run may send, from 0 to 50. Needs input.
history.maxBytesintegerThe most bytes they may hold in all, up to 65,536. Needs
history.messages.enabledbooleanfalserefuses every run withtask_disabled.truewhen left out.
The answer is 201 with the task. A name already in use is refused with task_exists, and a project holds up to 100 tasks.
Change a task
/v1/projects/{project}/tasks/{task}Send every field, as for creating one. The answer is the task. The next run uses the change.
Delete a task
/v1/projects/{project}/tasks/{task}The answer is 204, and runs of it are refused with task_not_found.
Last updated