OP Inference
API reference

Run a task

POST
/v1/tasks/{name}

Run a task on an input and get JSON checked against its output schema. {name} is the task's name for its latest version, or name@n for version n. An answer that fails the schema is repaired once, as a second billed generation; a refusal or a cut-off answer is not.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key, sent as Authorization: Bearer <key>.

Path Parameters

name*string

The task's name, optionally with @ and a version.

Header Parameters

Idempotency-Key?string

Any string you choose. A retry with the same key and body returns the first result instead of running again. The same key with a different body is a 409 idempotency_conflict.

Request Body

The input object itself, matching the task's input_schema.

application/json
  1. body

Response Body

The checked answer.

application/json
  1. response
id*string

The generation whose answer is output.

object*string
task*string

The task and version that ran, as name@n.

model*string

The model that produced output.

output*

The answer, valid against the task's output schema.

usage*

Summed over every generation of the request.

op*
curl -X POST "https://example.com/v1/tasks/sentiment" \  -H "Authorization: Bearer $OP_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "text": "The battery lasts all day, but the screen scratches easily."  }'
{  "id": "string",  "object": "task.result",  "task": "string",  "model": "string",  "output": {},  "usage": {    "input_tokens": 0,    "output_tokens": 0  },  "op": {    "generations": [      "string"    ]  }}