JSON job interface#
Any work you give rAPIdtools can be written down as a JSON file. A client (the graphical interface, a scheduler, a partner’s system) writes a job file that lists the steps to run. rAPIdtools runs it and keeps a result file next to it up to date. Only files cross that boundary, never Python objects, so the client and rAPIdtools can run in different processes or on different machines as long as both can reach the same files.
client rAPIdtools
------ ----------
writes job.json ---> validates every step, then runs them in order
polls job.result.json <--- rewrites it at every change of state
reads the output files named in job.result.json
The graphical interface works this way too. Every download, detection,
inference and prompt-assistant request it starts is a job file under
<output folder>/jobs, and you can rerun any of them unchanged from a
terminal.
This page specifies version 1.0 of the interface. Each of the three document types has a JSON Schema (draft 2020-12) you can use to validate files before submitting them:
Running a job#
From a terminal:
rapidtools-job run job.json
rapidtools-job run job.json --secrets secrets.json # credentials in a separate file
rapidtools-job run job.json --result /shared/status/job-42.json
rapidtools-job validate job.json # check a job without running it
rapidtools-job schema job # print a JSON Schema: job | result | secrets
rapidtools-job steps # print the catalog of step types as JSON
Where the console script is not on the path, python -m rapidtools.jobs
does the same thing. run prints progress to the console, writes the
result file and exits with one of these codes:
Exit status |
Meaning |
|---|---|
|
The job finished; every step succeeded. |
|
A step failed. The result file names the step and the error. |
|
The job file is invalid (or unreadable). Nothing was run. |
|
The job was canceled. |
SIGINT (Ctrl+C) or SIGTERM cancels the job gracefully. The batch or
tile in progress finishes, partial results are written, the result file is
marked canceled and the process exits with 3. A second signal ends
the process at once.
From Python it is a single call:
from rapidtools.jobs import run_job
result = run_job('job.json', secrets='secrets.json')
if result.ok:
print(result.step('detect').outputs['assets']) # a pathlib.Path
else:
print(result.status, result.message)
The job file#
A job file is one JSON object.
{
"schema": "rapidtools.job",
"schema_version": "1.0",
"id": "eaton-detect-and-grade",
"name": "Eaton fire: detect buildings and grade damage",
"output_dir": "output/eaton",
"steps": [
{
"id": "detect",
"type": "detect.aerial",
"inputs": {"raster": "eaton_patch_20250214.tiff"},
"params": {"assets": ["building"], "basemap": "bing"}
},
{
"id": "grade",
"type": "analyze.vlm",
"inputs": {
"raster": "eaton_patch_20250214.tiff",
"assets": {"step": "detect", "output": "assets"}
},
"params": {
"prompt": "Damage: [none, minor, major, destroyed]",
"backend": "gemini",
"api_key": {"$env": "GEMINI_API_KEY"}
}
}
]
}
Field |
Required |
Meaning |
|---|---|---|
|
yes |
Always |
|
yes |
Interface version the file was written for, |
|
yes |
Folder every step writes into. Created if missing. |
|
yes |
The steps, run in order. At least one. |
|
no |
Identifier of the job, repeated in the result file. Letters, digits,
|
|
no |
Human-readable name used in messages. Defaults to the |
|
no |
UTC creation time, ISO 8601 ( |
|
no |
Free-form object naming the client, e.g.
|
|
no |
Free-form object for the client’s own bookkeeping (ticket numbers, event names). Never interpreted. |
Field |
Required |
Meaning |
|---|---|---|
|
yes |
The step type, e.g. |
|
no |
Name of the step inside the job; later steps and the result file
refer to it. Unique within the job. Defaults to |
|
depends |
The data the step reads: files, regions, or outputs of earlier steps. |
|
depends |
The options of the step type. Omitted options take the documented default. |
|
no |
Free-form object. Never interpreted. |
Any other field is an error, whether it is at the top level, in a step, or
under inputs or params. A misspelled option is reported along with
the closest valid name, rather than silently ignored.
Paths#
Every path in a job file (output_dir and the file inputs) is either
absolute or relative to the folder that holds the job file, and ~ is
expanded. A job that uses relative paths can therefore move together with
its data. The process that runs the job must be able to read the inputs and
write to the output folder, so when the client and rAPIdtools run on
different machines, the files have to be on storage both can reach.
Inputs#
There are three kinds of input values.
A file (kinds raster, assets and file) is a path string, or a
reference to something an earlier step of the same job wrote:
{"raster": "/data/eaton/ortho.tiff"}
{"assets": {"step": "detect", "output": "assets"}}
A reference names the id of an earlier step and one of the outputs
its step type declares. It is checked before the job starts. Assets are
exchanged as GeoJSON FeatureCollection files in WGS84 (EPSG:4326), one
feature per asset, attributes in properties.
A region is a WGS84 bounding box or the extent of a GeoJSON file:
{"region": {"bbox": [-117.489, 47.711, -117.487, 47.7125]}}
{"region": {"geojson": "study_area.geojson"}}
The box is [min_lon, min_lat, max_lon, max_lat] with longitudes in
[-180, 180] and latitudes in [-85, 85].
Secrets#
API keys and access tokens are parameters like any other (the reference below marks them secret), but you do not have to write them into the job file. A secret parameter accepts three forms:
Form |
Where the value comes from |
|---|---|
|
The secrets file given to the runner; if the name is not there, the
environment variable |
|
The environment variable of that exact name. |
|
The literal value. The job file must then be protected like the key. |
A secrets file is a separate JSON document, passed with --secrets (or
secrets= in Python):
{
"schema": "rapidtools.secrets",
"schema_version": "1.0",
"secrets": {"mapillary_token": "MLY|...", "api_key": "AIza..."}
}
Secret values are never written to the result file or to the log. A
reference that cannot be resolved fails the job before any step runs;
rapidtools-job validate accepts unresolved references unless
--require-secrets is given, so a job can be checked on a machine that
does not hold the credentials.
The result file#
rAPIdtools writes <job file name without .json>.result.json next to the
job file, or wherever --result points. The file is rewritten when the job
starts, when each step starts and ends, and when the job ends. A job started
with rapidtools-job run or run_job also updates message with
every progress line. Each write replaces the file in a single atomic step,
so a reader always sees a complete document and polling it is safe.
{
"schema": "rapidtools.job_result",
"schema_version": "1.0",
"job_id": "20261124T154952Z-74fa-download-bing-imagery",
"job_name": "Download Bing imagery",
"job_file": "/data/out/jobs/20261124T154952Z-74fa-download-bing-imagery.json",
"status": "done",
"message": "Download Bing imagery finished.",
"started_at": "2026-11-24T15:49:52Z",
"updated_at": "2026-11-24T15:49:54Z",
"finished_at": "2026-11-24T15:49:54Z",
"duration_s": 1.646,
"rapidtools_version": "0.3.0",
"steps": [
{
"id": "basemap",
"type": "imagery.basemap",
"status": "done",
"started_at": "2026-11-24T15:49:52Z",
"finished_at": "2026-11-24T15:49:53Z",
"duration_s": 1.234,
"outputs": {
"raster": {
"path": "/data/out/bing_z19_m117p48900_47p71100_m117p48700_47p71250.tiff",
"kind": "raster"
}
},
"files": [],
"summary": {"provider": "bing", "zoom": 19}
}
]
}
Field |
Meaning |
|---|---|
|
|
|
While running: the latest progress line. At the end: the outcome, or the error message. |
|
Copied from the job. |
|
UTC, ISO 8601. |
|
Wall-clock seconds, |
|
The release that ran the job. |
|
One entry per step of the job, in the same order. |
Field |
Meaning |
|---|---|
|
Copied from the job. |
|
|
|
The declared outputs that were written, by name: |
|
Other files worth listing, each with |
|
Small facts about the run, such as |
|
Present only for steps whose result is not a file
( |
|
Present when the step failed or was canceled:
|
|
As above; |
How a job ends#
Every step is validated before the first one runs. An invalid job ends with
status: "error", the offending step markederrorand no step started.Steps run one after the other. The first step that fails or is canceled ends the job; the steps after it are
skipped.A detection step that finds nothing succeeds, but a later step that needed its assets fails with a message saying so (“No assets were detected; skipping inference.”).
A canceled
analyze.vlmstep keeps what it finished: the assets analyzed so far are written and listed as thepartial_assetsoutput.
Step types#
A step type is named <stage>.<variant>. Version 1.0 defines six:
Type |
What it does |
|---|---|
|
Stitches a Bing or Google satellite basemap over a region. |
|
Fetches a sample dataset from the rAPIdtools registry. |
|
Finds assets in an orthomosaic with SAM 3. |
|
Finds objects along a Mapillary street survey. |
|
Asks a vision-language model a question about every asset. |
|
Asks a model to draft, refine or review a prompt. |
The tables below are generated from the code that validates job files, and
rapidtools-job steps prints the same catalog as JSON for clients that
build their forms from it.
imagery.basemap#
Download a satellite basemap. Stitches Bing or Google satellite tiles over a region into one georeferenced GeoTIFF. An existing file for the same provider, zoom and bounds is reused instead of downloaded again.
Inputs
Name |
Kind |
Required |
Description |
|---|---|---|---|
|
region |
no |
Area to cover: a WGS84 box, or a GeoJSON file whose extent is used. |
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Tile provider. One of: |
|
integer |
|
Web Mercator zoom level (Bing up to 20, Google up to 21). One level up doubles the resolution and quadruples the tile count. Must be at least 10 and at most 21. |
|
integer |
|
Refuse the download when the region needs more tiles than this. Must be at least 1. |
|
integer |
|
Concurrent tile downloads. Must be at least 1. |
Outputs
Name |
Kind |
Description |
|---|---|---|
|
raster |
The stitched GeoTIFF. |
data.download#
Download a sample dataset. Fetches a dataset of the rapidtools registry (sample orthomosaics, footprints, prompts) into the output folder. Files that are already there are not downloaded again.
Inputs: none.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
string |
required |
Registry name of the dataset, e.g. “eaton_patch1” (see rapidtools.list_datasets()). |
Outputs
Name |
Kind |
Description |
|---|---|---|
|
file |
The first file of the dataset; for the sample orthomosaics, the raster. Further files are listed under “files”. |
detect.aerial#
Detect assets in aerial imagery. Finds every instance of the named asset types in an orthomosaic with SAM 3, by default on a pre-event satellite basemap stitched over the raster extent (assets destroyed in the post-event imagery are still found there). Building footprints always get straight, square walls; by default they are also refined on close-up crops, and roads are regularized into clean polygons.
Inputs
Name |
Kind |
Required |
Description |
|---|---|---|---|
|
raster |
yes |
The georeferenced orthomosaic that defines the area. |
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
list of strings |
required |
Asset types to find, as plain-English prompts, e.g. [“building”, “tree”]. Each is scanned for separately. |
|
number |
|
Approximate size of one asset in meters; sets the size of the patches SAM 3 looks at. Must be greater than 0. |
|
string |
|
Imagery to detect in: a “bing” or “google” basemap stitched over the raster extent, or “recon” for the raster itself. One of: |
|
number |
|
Detection confidence threshold. Must be at least 0 and at most 1. |
|
number |
|
Mask binarization threshold. Must be at least 0 and at most 1. |
|
number |
|
Overlap between neighboring patches, as a fraction of the patch size. Must be at least 0. |
|
integer |
|
Patches per SAM 3 forward pass. Must be at least 1. |
|
string |
|
Margin around each detection in the crops used for regularization, e.g. “20 m”. |
|
boolean |
|
Refine building footprints with a second SAM 3 pass on close-up crops, and regularize road polygons. Building walls are squared either way. |
|
boolean |
|
Merge detections that overlap across patches into one asset. Turn off to keep touching instances separate. Building prompts are always kept separate, from patches overlapping by at least half. |
|
integer |
|
Concurrent tile downloads when a basemap is stitched. Must be at least 1. |
Outputs
Name |
Kind |
Description |
|---|---|---|
|
geojson |
All detected assets (assets_final.geojson). Absent when nothing was found. |
|
raster |
The raster detection ran on: the stitched basemap, or the input raster for “recon”. |
detect.street#
Discover objects along a street survey. Locates objects of the requested classes in the Mapillary street-level images of an area and fuses the sightings into one asset per object: a point for vehicles, poles and other objects, a footprint polygon for buildings. The area is the “region” input, or the extent of “raster” when no region is given.
Inputs
Name |
Kind |
Required |
Description |
|---|---|---|---|
|
region |
no |
Survey area: a WGS84 box, or a GeoJSON file whose extent is used. |
|
raster |
no |
A raster whose extent defines the area when no region is given. |
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
list of strings |
required |
Object classes in plain English, e.g. [“vehicles”, “utility poles”, “buildings”]. |
|
string (secret) |
|
Mapillary access token. |
|
string |
|
Only images captured on or after this date (YYYY-MM-DD). Empty for no limit. |
|
string |
|
Only images captured on or before this date (YYYY-MM-DD). Empty for no limit. |
|
boolean |
|
Use only imagery uploaded by the RAPID Facility. |
|
string |
|
Where detections come from: Mapillary segmentation metadata, SAM 3 run on the frames, Mapillary map features, or “auto” to choose per class. One of: |
|
number |
|
Thin each survey to one frame per this many meters; 0 keeps every frame. Must be at least 0. |
|
integer |
|
Sightings required before an object is reported. Must be at least 1. |
|
number |
|
Sightings closer than this are treated as the same object. Must be greater than 0. |
|
number |
|
Height of the survey camera above the road. Must be greater than 0. |
|
number |
|
Ignore sightings farther from the camera than this. Must be greater than 0. |
|
integer |
|
Concurrent Mapillary requests. Must be at least 1. |
Outputs
Name |
Kind |
Description |
|---|---|---|
|
geojson |
The discovered objects (street_objects.geojson). Absent when nothing was found. |
analyze.vlm#
Analyze assets with a vision-language model. Gathers imagery of every asset (aerial crops of a raster, Google Street View, Mapillary panoramas or Mapillary object crops) and asks a vision-language model the prompt about each one. The answers become attributes of the assets. Assets that already carry attributes keep them, so two models can be run one after the other on the same file.
Inputs
Name |
Kind |
Required |
Description |
|---|---|---|---|
|
assets |
yes |
The assets to analyze: a GeoJSON file, or the “assets” output of an earlier detection step. |
|
raster |
no |
The orthomosaic to crop. Required for the “aerial” imagery source only. |
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
string |
required |
The question put to the model about each asset. |
|
string |
|
Model provider: a cloud API or a local checkpoint. One of: |
|
string (secret) |
|
API key of a cloud backend. Not used by local backends. |
|
string |
|
Model name or Hugging Face repository. Empty selects the backend’s default. |
|
integer |
|
Concurrent requests to a cloud backend, and concurrent image downloads. Must be at least 1. |
|
integer |
|
Assets per forward pass of a local backend that supports batching. Must be at least 1. |
|
number |
|
Sampling temperature. Must be at least 0. |
|
integer or null |
|
Longest answer the model may give, in tokens. null uses the default of the chosen model: 2048 for most, 32768 for Gemini 4, whose thinking counts against the limit. Must be at least 1. |
|
boolean |
|
Ask the model for a JSON answer; each key becomes an attribute. |
|
boolean |
|
Load a local model with 4-bit quantization (less GPU memory). |
|
boolean |
|
Draw the outline of the asset on each crop so the model knows which one is meant. |
|
string |
|
Shape of the outline. One of: |
|
number or string |
|
Offset of the outline from the asset: pixels, a percentage (“5%”) or a distance (“2 m”). |
|
number or string |
|
Stroke width: pixels, or a percentage of the shorter crop side. |
|
string |
|
Outline color: a name or a hex code (“#00ffff”). |
|
string |
|
Prefix of the aerial crop file names. |
|
boolean |
|
Show the model only the crops gathered by this step, not images already attached to the assets. |
|
string |
|
Where the imagery of each asset comes from. One of: |
|
number or null |
|
Aerial crops: skip an asset when less than this fraction of its footprint lies inside the raster. null uses the extractor default. Must be at least 0 and at most 1. |
|
boolean or null |
|
Aerial crops: pad crops that reach past the raster edge instead of clipping them. null uses the extractor default. |
|
number |
|
Google Street View: how far from the asset to look for a panorama. Must be greater than 0. |
|
integer |
|
Google Street View: panoramas per asset. Must be at least 1. |
|
list of two numbers |
|
Google Street View: [top, bottom] fractions of the panorama height to keep, with 0 <= top < bottom <= 1. |
|
string (secret) |
|
Mapillary access token. Required for the two Mapillary imagery sources. |
|
string |
|
Mapillary panoramas: only images captured on or after this date (YYYY-MM-DD). |
|
string |
|
Mapillary panoramas: only images captured on or before this date (YYYY-MM-DD). |
|
boolean |
|
Mapillary panoramas: use only RAPID Facility uploads. |
|
integer |
|
Mapillary sources: images per asset. Must be at least 1. |
|
string |
|
Mapillary object crops: thumbnail size to download, “1024”, “2048” or “original”. |
|
number or string |
|
Mapillary object crops: margin around the object, as a percentage (“25%”), pixels or a distance (“1 m”). |
Outputs
Name |
Kind |
Description |
|---|---|---|
|
geojson |
The analyzed assets with their new attributes (assets_inferred.geojson). |
|
geojson |
Written only when the step is canceled: the assets analyzed so far (assets_inferred_partial.geojson). |
prompt.assist#
Ask a model for help with a prompt. Runs one prompt-assistant action: drafting a prompt specification from a brief, refining or reviewing one, suggesting visual indicators for a class, or importing an existing prompt. The answer is returned as “data” in the result file; no file is written.
Inputs: none.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
string |
required |
What to do. One of: |
|
string |
|
Model provider answering the request. One of: |
|
string (secret) |
|
API key of a cloud backend. |
|
string |
|
Model name. Empty selects the backend’s default. |
|
boolean |
|
Load a local model with 4-bit quantization. |
|
string |
|
Plain-language description of the task (“draft”). |
|
string |
|
What to change (“refine”). |
|
string |
|
An existing prompt (“review”, “import”). |
|
string |
|
The class to describe (“indicators”). |
|
object or null |
|
The current prompt specification, as produced by the prompt builder. |
|
object |
|
Extra facts for the assistant (asset type, imagery, outline). |
|
number |
|
Sampling temperature. Must be at least 0. |
|
integer |
|
Longest answer the model may give, in tokens. Must be at least 1. |
Outputs: none (see data in the result file).
Versioning#
schema_version is MAJOR.MINOR.
A minor release only adds: new step types, new optional parameters, new optional fields, new keys in
summary. A file written for 1.0 keeps working with every 1.x release, with the same meaning.A major release may change or remove things. A runner refuses files of another major version.
A runner accepts a file that declares a newer minor version than its own, but rejects any field or step type it does not know, with a message saying that rAPIdtools needs to be upgraded. A newer file that uses only 1.0 features therefore still runs.
Readers of result files should ignore fields they do not know, so that result files can grow in minor releases.
The JSON Schemas linked at the top of this page describe exactly one
version; rapidtools-job schema prints the ones matching the installed
release.
How the graphical interface uses it#
The GUI server is simply a client of this interface.
- Where the files are
Each run writes
<output folder>/jobs/<UTC time>-<random>-<name>.jsonand the matching.result.json. The log pane prints the path when a job starts, andGET /api/statelists both paths asjob.fileandjob.result_file.- How runs map to steps
Detect only, Run inference, a basemap download and a prompt-assistant request are one-step jobs. Detect + run inference is one job with two steps, the second reading the
assetsoutput of the first.- Assets between runs
An inference started on its own reads the assets from the file the previous run wrote (
assets_final.geojson,street_objects.geojson,assets_inferred.geojson) or from the file the user loaded. Running a second model therefore adds its attributes next to the first model’s.- Credentials
Keys typed into the page are replaced by
{"$secret": ...}in the job file. The values go to a secrets file in a private temporary folder outside the output folder. Only the server’s user can read it, and it is deleted when the job ends.- What is not a job
The GUI server answers some requests itself: loading a local image or an asset file for display, map tiles, address search, survey coverage and the list of models a key can reach. These prepare a request rather than run an analysis.
Adding a step type#
To add a step type, register one record. The runner, the schemas, the catalog and the tables on this page are all generated from it.
from rapidtools.jobs import Input, Output, Param, StepType, register_step
def build(step_type, params, inputs, output_dir, dry):
"""Return the settings the step runs with; raise ValueError if invalid."""
return {'buffer_m': params['buffer_m'], 'assets': inputs['assets']}
def run(ctx):
assets = ctx.inputs['assets'].load() # a PhysicalAssetCollection
path = ctx.output_dir / 'assets_buffered.geojson'
... # do the work, write the file
ctx.outputs['assets'] = path # what later steps can read
ctx.summary['n_assets'] = len(assets)
register_step(StepType(
name='postprocess.buffer',
title='Buffer asset footprints',
doc='Grows every footprint by a fixed distance.',
build=build,
run=run,
inputs=(Input('assets', 'assets', 'The assets to buffer.', required=True),),
params=(Param('buffer_m', 'number', 'Distance in meters.', default=2.0,
minimum=0),),
outputs=(Output('assets', 'geojson', 'The buffered assets.'),),
))
Limits of version 1.0#
Version 1.0 leaves these out on purpose. Each can be added in a minor release without breaking existing files.
Shared storage is assumed. Inputs and outputs are paths. There is no upload, download or object-store URL scheme yet.
Execution is local and sequential. The runner executes a job in its own process, one step at a time. The GUI runs one job at a time. Queuing, parallel steps and remote execution belong to the system that calls
rapidtools-job run.Progress is a message. The result file carries the latest progress line and the state of each step, not a percentage.
Cancellation is a signal. A job is canceled by signaling the process that runs it; there is no cancel file to drop next to the job.
No sandbox. The runner reads and writes whatever paths the job names and its user may access. The folder restriction of a shared GUI server (
--data-root) is enforced by the GUI before it writes a job file, not by the runner; a system that accepts job files from untrusted users should confine the process itself.Resources are not declared. A job does not say how much GPU memory or time it needs; the local model steps need a GPU with about 16 GB for SAM 3 and the default Gemma 4 checkpoint.