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

0

The job finished; every step succeeded.

1

A step failed. The result file names the step and the error.

2

The job file is invalid (or unreadable). Nothing was run.

3

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"}
      }
    }
  ]
}
Top-level fields#

Field

Required

Meaning

schema

yes

Always "rapidtools.job".

schema_version

yes

Interface version the file was written for, "1.0". See Versioning.

output_dir

yes

Folder every step writes into. Created if missing.

steps

yes

The steps, run in order. At least one.

id

no

Identifier of the job, repeated in the result file. Letters, digits, ., _ and -. Generated from the time and the name when omitted.

name

no

Human-readable name used in messages. Defaults to the id.

created_at

no

UTC creation time, ISO 8601 (2026-11-24T15:49:52Z).

created_by

no

Free-form object naming the client, e.g. {"client": "rapidtools-gui", "version": "0.3.0"}.

metadata

no

Free-form object for the client’s own bookkeeping (ticket numbers, event names). Never interpreted.

Fields of a step#

Field

Required

Meaning

type

yes

The step type, e.g. "detect.aerial". See Step types.

id

no

Name of the step inside the job; later steps and the result file refer to it. Unique within the job. Defaults to s1, s2, …

inputs

depends

The data the step reads: files, regions, or outputs of earlier steps.

params

depends

The options of the step type. Omitted options take the documented default.

metadata

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

{"$secret": "mapillary_token"}

The secrets file given to the runner; if the name is not there, the environment variable RAPIDTOOLS_SECRET_MAPILLARY_TOKEN (the name in upper case, other characters replaced by _).

{"$env": "GEMINI_API_KEY"}

The environment variable of that exact name.

"AIza..."

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}
    }
  ]
}
Top-level fields#

Field

Meaning

status

running, done, error or canceled. A job is finished when the status is anything but running.

message

While running: the latest progress line. At the end: the outcome, or the error message.

job_id, job_name, job_file

Copied from the job. job_file is null for a job that was passed in memory.

started_at, updated_at, finished_at

UTC, ISO 8601. updated_at changes on every write; finished_at is null until the job ends.

duration_s

Wall-clock seconds, null until the job ends.

rapidtools_version

The release that ran the job.

steps

One entry per step of the job, in the same order.

Fields of a step result#

Field

Meaning

id, type

Copied from the job.

status

pending (not reached yet), running, done, error, canceled, or skipped (an earlier step ended the job).

outputs

The declared outputs that were written, by name: {"path": <absolute path>, "kind": "raster" | "geojson" | "file"}. An output the step did not produce (nothing was detected, say) is absent.

files

Other files worth listing, each with label, path and kind, for example the per-asset-type GeoJSON files of a detection.

summary

Small facts about the run, such as {"n_assets": 179}. The keys depend on the step type.

data

Present only for steps whose result is not a file (prompt.assist).

error

Present when the step failed or was canceled: {"type": <exception name>, "message": <text>}.

started_at, finished_at, duration_s

As above; null for steps that never started.

How a job ends#

  • Every step is validated before the first one runs. An invalid job ends with status: "error", the offending step marked error and 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.vlm step keeps what it finished: the assets analyzed so far are written and listed as the partial_assets output.

Step types#

A step type is named <stage>.<variant>. Version 1.0 defines six:

Type

What it does

imagery.basemap

Stitches a Bing or Google satellite basemap over a region.

data.download

Fetches a sample dataset from the rAPIdtools registry.

detect.aerial

Finds assets in an orthomosaic with SAM 3.

detect.street

Finds objects along a Mapillary street survey.

analyze.vlm

Asks a vision-language model a question about every asset.

prompt.assist

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

region

no

Area to cover: a WGS84 box, or a GeoJSON file whose extent is used.

Parameters

Name

Type

Default

Description

provider

string

"bing"

Tile provider. One of: "bing", "google".

zoom

integer

19

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.

max_tiles

integer

2500

Refuse the download when the region needs more tiles than this. Must be at least 1.

max_workers

integer

10

Concurrent tile downloads. Must be at least 1.

Outputs

Name

Kind

Description

raster

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

dataset

string

required

Registry name of the dataset, e.g. “eaton_patch1” (see rapidtools.list_datasets()).

Outputs

Name

Kind

Description

file

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

raster

yes

The georeferenced orthomosaic that defines the area.

Parameters

Name

Type

Default

Description

assets

list of strings

required

Asset types to find, as plain-English prompts, e.g. [“building”, “tree”]. Each is scanned for separately.

asset_size_m

number

50.0

Approximate size of one asset in meters; sets the size of the patches SAM 3 looks at. Must be greater than 0.

basemap

string

"bing"

Imagery to detect in: a “bing” or “google” basemap stitched over the raster extent, or “recon” for the raster itself. One of: "bing", "google", "recon".

threshold

number

0.5

Detection confidence threshold. Must be at least 0 and at most 1.

mask_threshold

number

0.4

Mask binarization threshold. Must be at least 0 and at most 1.

overlap_ratio

number

0.25

Overlap between neighboring patches, as a fraction of the patch size. Must be at least 0.

batch_size

integer

4

Patches per SAM 3 forward pass. Must be at least 1.

crop_buffer

string

"20 m"

Margin around each detection in the crops used for regularization, e.g. “20 m”.

regularize

boolean

true

Refine building footprints with a second SAM 3 pass on close-up crops, and regularize road polygons. Building walls are squared either way.

merge_overlaps

boolean

true

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.

max_workers

integer

10

Concurrent tile downloads when a basemap is stitched. Must be at least 1.

Outputs

Name

Kind

Description

assets

geojson

All detected assets (assets_final.geojson). Absent when nothing was found.

detection_raster

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

region

no

Survey area: a WGS84 box, or a GeoJSON file whose extent is used.

raster

raster

no

A raster whose extent defines the area when no region is given.

Parameters

Name

Type

Default

Description

classes

list of strings

required

Object classes in plain English, e.g. [“vehicles”, “utility poles”, “buildings”].

access_token

string (secret)

""

Mapillary access token.

start_date

string

""

Only images captured on or after this date (YYYY-MM-DD). Empty for no limit.

end_date

string

""

Only images captured on or before this date (YYYY-MM-DD). Empty for no limit.

filter_rapid_only

boolean

true

Use only imagery uploaded by the RAPID Facility.

detection_source

string

"auto"

Where detections come from: Mapillary segmentation metadata, SAM 3 run on the frames, Mapillary map features, or “auto” to choose per class. One of: "auto", "mapillary", "sam3", "map_features".

frame_spacing_m

number

3.0

Thin each survey to one frame per this many meters; 0 keeps every frame. Must be at least 0.

min_observations

integer

2

Sightings required before an object is reported. Must be at least 1.

cluster_radius_m

number

4.0

Sightings closer than this are treated as the same object. Must be greater than 0.

camera_height_m

number

2.4

Height of the survey camera above the road. Must be greater than 0.

max_range_m

number

60.0

Ignore sightings farther from the camera than this. Must be greater than 0.

max_workers

integer

10

Concurrent Mapillary requests. Must be at least 1.

Outputs

Name

Kind

Description

assets

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

assets

yes

The assets to analyze: a GeoJSON file, or the “assets” output of an earlier detection step.

raster

raster

no

The orthomosaic to crop. Required for the “aerial” imagery source only.

Parameters

Name

Type

Default

Description

prompt

string

required

The question put to the model about each asset.

backend

string

"gemini"

Model provider: a cloud API or a local checkpoint. One of: "gemini", "claude", "openai", "muse_spark", "qwen", "gemma4", "llama", "muse_glimmer", "qwen_vl", "hf".

api_key

string (secret)

""

API key of a cloud backend. Not used by local backends.

model_id

string

""

Model name or Hugging Face repository. Empty selects the backend’s default.

max_workers

integer

5

Concurrent requests to a cloud backend, and concurrent image downloads. Must be at least 1.

batch_size

integer

4

Assets per forward pass of a local backend that supports batching. Must be at least 1.

temperature

number

0.4

Sampling temperature. Must be at least 0.

max_tokens

integer or null

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.

json_mode

boolean

false

Ask the model for a JSON answer; each key becomes an attribute.

load_in_4bit

boolean

true

Load a local model with 4-bit quantization (less GPU memory).

overlay_asset_outline

boolean

true

Draw the outline of the asset on each crop so the model knows which one is meant.

outline_shape

string

"geometry"

Shape of the outline. One of: "geometry", "bbox", "rotated_bbox", "convex_hull", "corners".

outline_buffer

number or string

0

Offset of the outline from the asset: pixels, a percentage (“5%”) or a distance (“2 m”).

outline_width

number or string

6

Stroke width: pixels, or a percentage of the shorter crop side.

outline_color

string

"red"

Outline color: a name or a hex code (“#00ffff”).

image_prefix

string

"aerial"

Prefix of the aerial crop file names.

only_analyze_inference_crops

boolean

true

Show the model only the crops gathered by this step, not images already attached to the assets.

imagery

string

"aerial"

Where the imagery of each asset comes from. One of: "aerial", "google_streetview", "mapillary", "mapillary_objects".

min_footprint_coverage

number or null

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.

pad_edges

boolean or null

null

Aerial crops: pad crops that reach past the raster edge instead of clipping them. null uses the extractor default.

street_search_radius_m

number

50.0

Google Street View: how far from the asset to look for a panorama. Must be greater than 0.

street_max_images

integer

1

Google Street View: panoramas per asset. Must be at least 1.

street_vertical_crop

list of two numbers

[0.0, 1.0]

Google Street View: [top, bottom] fractions of the panorama height to keep, with 0 <= top < bottom <= 1.

mapillary_token

string (secret)

""

Mapillary access token. Required for the two Mapillary imagery sources.

mapillary_start_date

string

""

Mapillary panoramas: only images captured on or after this date (YYYY-MM-DD).

mapillary_end_date

string

""

Mapillary panoramas: only images captured on or before this date (YYYY-MM-DD).

mapillary_rapid_only

boolean

true

Mapillary panoramas: use only RAPID Facility uploads.

mapillary_max_images

integer

4

Mapillary sources: images per asset. Must be at least 1.

object_image_size

string

"2048"

Mapillary object crops: thumbnail size to download, “1024”, “2048” or “original”.

object_crop_buffer

number or string

"25%"

Mapillary object crops: margin around the object, as a percentage (“25%”), pixels or a distance (“1 m”).

Outputs

Name

Kind

Description

assets

geojson

The analyzed assets with their new attributes (assets_inferred.geojson).

partial_assets

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

action

string

required

What to do. One of: "draft", "refine", "review", "indicators", "import".

backend

string

"gemma4"

Model provider answering the request. One of: "gemini", "claude", "openai", "muse_spark", "qwen", "gemma4", "llama", "muse_glimmer", "qwen_vl", "hf".

api_key

string (secret)

""

API key of a cloud backend.

model_id

string

""

Model name. Empty selects the backend’s default.

load_in_4bit

boolean

true

Load a local model with 4-bit quantization.

brief

string

""

Plain-language description of the task (“draft”).

instruction

string

""

What to change (“refine”).

prompt_text

string

""

An existing prompt (“review”, “import”).

class_value

string

""

The class to describe (“indicators”).

spec

object or null

null

The current prompt specification, as produced by the prompt builder.

context

object

{}

Extra facts for the assistant (asset type, imagery, outline).

temperature

number

0.2

Sampling temperature. Must be at least 0.

max_tokens

integer

4096

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>.json and the matching .result.json. The log pane prints the path when a job starts, and GET /api/state lists both paths as job.file and job.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 assets output 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.