# Jobs

5 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## Run tasks with a solver and a sealed grader, server-side, into an RL run[#]

POST`/v1/jobs`scope sandboxes:write

With benchmark, leave out template, image, snapshot, size, tasks and grader: each instance runs in its ready-made environment and is graded by the benchmark's own grader (SWE-bench: the harness's eval script and log parser, reward 1 when resolved; Terminal-Bench: the task's tests/test.sh), sealed, in the background. solver is {cmd, timeout_s?, env?, files?} (timeout_s defaults to the instance's agent time), {patches: {instance id: diff}} (SWE-bench predictions) or {oracle: true} (the reference solutions). Each task gets its own sandbox, its input and files, then the solver in the background; the sealed grader scores it in a copy with no network. Infra failures are retried up to retries_on_infra, then recorded masked. Send an Idempotency-Key header to make a retried submit safe. tasks_url answers 501 until organization storage exists.

JSON body

`name`requiredstring

Max length 128.

`project`string

Max length 64.

`template`string

—

`image`string

—

`snapshot`string

Exactly one of template, image or snapshot

`size`string

A Cloud size, e.g. 2x4

`tasks`array of object

—

`solver`requiredobject

—

`solver.cmd`requiredstring | array of string

—

`solver.timeout_s`requiredinteger

Runs as a background command, polled, so it may run for hours Min 1. Max 86400.

`solver.env`object | array of string

{NAME: value} or ["NAME=value"]; KOSA8_ names are the job's

`grader`object

—

`grader.cmd`requiredstring | array of string

—

`grader.files`object

Hidden files: written only into the sealed copy (no network) the grader runs in; at most 1 MiB

`grader.timeout_s`integer

Default `60`. Min 1. Max 90.

`grader.env`object | array of string

{NAME: value} or ["NAME=value"]; KOSA8_ names are the job's

`concurrency`integer

Tasks in flight at once; at most the organization's running limit less one, kept for a sealed grader's copy (default 16, or that if lower) Min 1.

`retries_on_infra`integer

Default `2`. Min 0. Max 5.

`lease_s`integer

Each task sandbox's lease; the job's driver moves it on while it runs Default `900`. Min 120. Max 86400.

`budget_usd`number

Stop with status budget_reached once the job's list cost reaches this

`benchmark`object

—

`benchmark.name`requiredstring

A benchmark from GET /v1/benchmarks, e.g. swe-bench-verified or terminal-bench-2.1

`benchmark.instances`array of string | "all" | integer

Instance ids, "all", or n: a seeded sample of n

`benchmark.seed`integer

Default `0`. Min 0.

Responses

202400401402403413501

```
curl -s -X POST https://api.kosa8.com/v1/jobs \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## The organization's jobs, newest first[#]

GET`/v1/jobs`scope sandboxes:read

Parameters

`status`query · "queued" | "running" | "done" | "failed" | "cancelled" | "budget_reached"

Only this status

`project`query · string

Only this project

`limit`query · integer

Default 50

`cursor`query · string

next_cursor of the page before

Responses

200400401403

```
curl -s -X GET https://api.kosa8.com/v1/jobs \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Estimate a job's sandbox-hours and list cost, as a range[#]

POST`/v1/jobs/estimate`scope sandboxes:read

From the timeout: tasks × (30 s + a quarter of solver.timeout_s) to tasks × (30 s + solver.timeout_s + grader.timeout_s). From a sample: tasks × p50 to tasks × p90. Sandbox-hours by the size's standard_hours_per_hour (plan_limits.json); dollars at list rates.

JSON body

`name`string

Max length 128.

`project`string

Max length 64.

`template`string

—

`image`string

—

`snapshot`string

Exactly one of template, image or snapshot

`size`string

A Cloud size, e.g. 2x4

`tasks`array of object

—

`solver`object

—

`solver.cmd`requiredstring | array of string

—

`solver.timeout_s`requiredinteger

Runs as a background command, polled, so it may run for hours Min 1. Max 86400.

`solver.env`object | array of string

{NAME: value} or ["NAME=value"]; KOSA8_ names are the job's

`grader`object

—

`grader.cmd`requiredstring | array of string

—

`grader.files`object

Hidden files: written only into the sealed copy (no network) the grader runs in; at most 1 MiB

`grader.timeout_s`integer

Default `60`. Min 1. Max 90.

`grader.env`object | array of string

{NAME: value} or ["NAME=value"]; KOSA8_ names are the job's

`concurrency`integer

Tasks in flight at once; at most the organization's running limit less one, kept for a sealed grader's copy (default 16, or that if lower) Min 1.

`retries_on_infra`integer

Default `2`. Min 0. Max 5.

`lease_s`integer

Each task sandbox's lease; the job's driver moves it on while it runs Default `900`. Min 120. Max 86400.

`budget_usd`number

Stop with status budget_reached once the job's list cost reaches this

`benchmark`object

—

`benchmark.name`requiredstring

A benchmark from GET /v1/benchmarks, e.g. swe-bench-verified or terminal-bench-2.1

`benchmark.instances`array of string | "all" | integer

Instance ids, "all", or n: a seeded sample of n

`benchmark.seed`integer

Default `0`. Min 0.

`task_count`integer

Instead of tasks Min 1. Max 10000.

`sample`integer

Run the first n tasks for real (a pilot job, 202; needs sandboxes:write); estimate again with sample_job_id once it has rollouts Min 1. Max 50.

`sample_job_id`string

Estimate from this job's measured p50 and p90 rollout time

Responses

200400401403404

```
curl -s -X POST https://api.kosa8.com/v1/jobs/estimate \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## A job: status, counts by state and failure class, progress, cost so far and ETA[#]

GET`/v1/jobs/{id}`scope sandboxes:read

Rollouts are in the job's run: GET /v1/rl/runs/{run_id}/rollouts, or …/export?format=jsonl.

Parameters

`id`requiredpath · string

Job id (job_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/jobs/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Cancel a job: no new rollouts, its sandboxes drained[#]

POST`/v1/jobs/{id}/cancel`scope sandboxes:write

Rollouts already recorded stay in the run.

Parameters

`id`requiredpath · string

Job id (job_…)

Responses

200401403404

```
curl -s -X POST https://api.kosa8.com/v1/jobs/$SBX/cancel \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/jobs/
