Skip to content
Get started

Run a task immediately

client.promptly.tasks.run(stringtaskID, RequestOptionsoptions?): TaskRun { id, completedAt, costCents, 9 more }
POST/api/promptly/tasks/{taskId}/run

Execute a task immediately, regardless of its schedule

ParametersExpand Collapse
taskID: string
formatuuid
ReturnsExpand Collapse
TaskRun { id, completedAt, costCents, 9 more }
id?: string
formatuuid
completedAt?: string
formatdate-time
costCents?: number

Cost in cents

createdAt?: string
formatdate-time
deliveryStatus?: "pending" | "delivered" | "failed"
Accepts one of the following:
"pending"
"delivered"
"failed"
durationMs?: number

Execution time in milliseconds

error?: string

Error message if failed

output?: string

AI-generated output

startedAt?: string
formatdate-time
status?: "pending" | "running" | "completed" | "failed"
Accepts one of the following:
"pending"
"running"
"completed"
"failed"
taskId?: string
formatuuid
tokensUsed?: number

Total tokens consumed

Run a task immediately

import _0ct from '0ct';

const client = new _0ct({
  apiKey: process.env['0CT_API_KEY'], // This is the default and can be omitted
});

const taskRun = await client.promptly.tasks.run('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');

console.log(taskRun.id);
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "completedAt": "2019-12-27T18:11:19.117Z",
  "costCents": 0,
  "createdAt": "2019-12-27T18:11:19.117Z",
  "deliveryStatus": "pending",
  "durationMs": 0,
  "error": "error",
  "output": "output",
  "startedAt": "2019-12-27T18:11:19.117Z",
  "status": "pending",
  "taskId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "tokensUsed": 0
}
Returns Examples
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "completedAt": "2019-12-27T18:11:19.117Z",
  "costCents": 0,
  "createdAt": "2019-12-27T18:11:19.117Z",
  "deliveryStatus": "pending",
  "durationMs": 0,
  "error": "error",
  "output": "output",
  "startedAt": "2019-12-27T18:11:19.117Z",
  "status": "pending",
  "taskId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "tokensUsed": 0
}