Workflows API
Build a vision pipeline that detects, filters, tracks, counts line crossings and measures dwell, and run it on a video, image, dataset or live stream.
On this page
- Quick start
- The graph
- Conditions
- Multiple models
- Outputs
- Event keys
- Endpoint
- Compute
- Build a graph
- nodes
- templates
- validate
- Create and manage
- compute_options
- create
- list
- get
- update
- delete
- bulk_delete
- Run over files and datasets
- run
- upload_source
- wait_for_run
- watch_run
- get_run
- list_runs
- iter_runs
- cancel_run
- bulk_cancel_runs
- Serve it live
- Live outputs
- deploy
- wait_until_live
- update_endpoint
- pause
- resume
- connect
- Edge
- edge_session
- Run and stream logs
- logs
- Common errors
A workflow is a graph of blocks. It holds no input or outputs: each run names what it runs on and what it writes (Outputs). Build one in the app, or here from a template, and validate it.
Each workflow gets its own GPU endpoint at create, which runs it over files and
datasets and serves it live; no model deployment is needed. You pay for the
endpoint’s uptime. Changing a workflow needs a member key.
Quick start
Create a workflow that runs one model, then run it over a local video (the CLI and REST read
the graph from graph.json):
from pictograph import Client
client = Client()
model = client.models.get(model="road-signs-detector")
graph = {
"version": 1,
"nodes": [
{"id": "s", "type": "source"},
{"id": "m", "type": "model", "config": {"model_id": model.id}},
{"id": "k", "type": "sink"},
],
"edges": [{"source": "s", "target": "m"}, {"source": "m", "target": "k"}],
}
wf = client.workflows.create(
name="Sign finder",
graph=graph,
)
run = client.workflows.run(
workflow=wf.id,
source="clip.mp4",
outputs={"annotated_video": True},
wait=True,
)
for artifact in run.artifacts:
print(artifact["kind"], artifact.get("download_url"))
pictograph workflows create "Sign finder" --graph graph.json
pictograph workflows run "Sign finder" --file clip.mp4 --write-video
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "Sign finder", "graph": '"$(cat graph.json)"'}'
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Sign%20finder/run?wait=true" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"source": {"kind": "video", "url": "https://example.com/clip.mp4"}, "outputs": {"annotated_video": true}}'
The endpoint deploys once the workflow has a model, so the first run may wait for it.
The graph
A graph is {"version": 1, "nodes": [...], "edges": [...]}. Each node is
{"id", "type", "config"}; each edge is {"source", "sourceHandle", "target", "targetHandle"}.
| Block | Does | In | Out | Main settings |
|---|---|---|---|---|
source |
Where a run’s input enters | - | frames | None |
model |
Runs a model on each frame | frames | detections | model_id (a ready model) or model_kind: "sam3" with prompt_classes; confidence_threshold, class_filter, precision |
filter |
Keeps chosen classes and confidences | detections | detections | keep_classes, min_confidence |
track |
Follows objects across frames | detections | detections | tracker: bytetrack, or botsort for a moving camera |
crop |
Cuts detections out as images | detections | frames | source_classes, max_crops (up to 200), min_crop_size |
condition |
Routes frames by rule | detections | detections | rules, combinator (Conditions) |
measure |
Counts line crossings, measures zones | detections | events | geometries (lines and zones), frame |
visualize |
Draws results | detections, events | frames | draw (boxes, labels, track tails, …), watermark_gcs_uri |
sink |
Marks which frames outputs take | detections, events, frames | - | None |
- A graph has one
source, no loops and no loose blocks.measurecomes aftertrack, which comes aftermodel.filteracts before anycrop, so it can’t follow one. - A
modelafter acropruns on each crop: its detections join the frame’s (in full-image coordinates) and are drawn and written, but never tracked or counted. A classifier there labels each crop, and a run that writes annotations saves each crop as an image from a Sink block after it. - A polygon’s crop (an instance mask or a region) keeps only the polygon’s pixels: the rest of its box is black, for the models after it and in its saved image. A box’s crop is the whole box.
- Lines and zones are in the pixels of the Measure block’s
frame({"width", "height"}), the frame they were drawn on, and scale to inputs of other sizes; without aframe, they’re used as written. - Labels sit at the top center of each box, unless
draw.badge_position(or a class’s entry indraw.badge_positions) names another of the nine positions. A classifier’s classes at or above its confidence are badges in the frame’s top-left corner. - A tracked object draws its tail (its recent path) only when
draw.tailsistrue; a class indraw.trail_off_classesdraws none. - A single image can’t be tracked or measured.
nodes lists every block’s settings, values and defaults.
Conditions
A condition block sends each frame down its true or false output (the edge’s
sourceHandle). A Visualize or Sink block reached from one output takes only that branch’s
frames, so outputs write only that branch; one reached from both, or neither, takes every
frame. The run’s condition_results count each branch’s frames.
subject |
Options | Reads |
|---|---|---|
class_count |
class_name (empty: any class) |
The frame’s annotations of that class (classifier labels count) |
detection_size |
metric: px (default) or pct |
The frame’s largest box, in pixels or percent of the frame |
line |
metric: in, out or total (default) |
The running count of the workflow’s first line |
zone |
metric: in, out, total (default), avg_time or total_time |
The running value of the workflow’s first zone (occupancy zones keep only total) |
Each rule compares its value to a numeric threshold with >, >=, <, <=, == or !=;
combinator all needs every rule, any just one. Frames are decided after the Measure
blocks update, so a line rule sees a crossing in the same frame. Wire Measure and Condition
side by side after Track: a Condition can’t take a Measure block’s output.
{
"nodes": [
{"id": "s", "type": "source"},
{"id": "m", "type": "model", "config": {"model_id": "<uuid>"}},
{"id": "t", "type": "track", "config": {"tracker": "bytetrack"}},
{"id": "gate", "type": "measure", "config": {"geometries": [
{"id": "l1", "kind": "line", "polyline": {"path": [{"x": 0, "y": 540}, {"x": 1920, "y": 540}]}}]}},
{"id": "busy", "type": "condition", "config": {"combinator": "any", "rules": [
{"subject": "class_count", "class_name": "car", "operator": ">=", "threshold": 5},
{"subject": "line", "metric": "in", "operator": ">", "threshold": 100}]}},
{"id": "keep", "type": "sink"}
],
"edges": [
{"source": "s", "target": "m"}, {"source": "m", "target": "t"},
{"source": "t", "target": "gate"}, {"source": "t", "target": "busy"},
{"source": "busy", "sourceHandle": "true", "target": "keep"}
]
}
Run it with outputs={"annotations": {"dataset": "Traffic", "directory": "/busy-frames"}} and
only busy frames (five or more cars, or past 100 crossings) are saved. A rule that can never
be true (a non-numeric threshold, a metric its subject doesn’t keep, a line rule with no line)
is refused when the workflow is saved or run.
Multiple models
Up to three models can run on the same frames: wire each model block from the source.
Every model’s detections are kept; where two of the same class overlap, the more confident one
wins, as its model predicted it.
{
"nodes": [
{"id": "s", "type": "source"},
{"id": "m1", "type": "model", "config": {"model_id": "<uuid-a>"}},
{"id": "m2", "type": "model", "config": {"model_id": "<uuid-b>"}},
{"id": "out","type": "sink"}
],
"edges": [
{"source": "s", "target": "m1"}, {"source": "s", "target": "m2"},
{"source": "m1", "target": "out"}, {"source": "m2", "target": "out"}
]
}
Each model runs on every frame, so two cost about twice as much as one. All must fit on the GPU at once.
Outputs
Every run logs each frame; read frames and events from its log (a single image’s
frame is also the run’s result). Anything else it writes is chosen when it starts: the
outputs of run, or of a stream when it opens (Live outputs). Each
output is off unless named, and one set applies to every Sink block. A Sink block’s position
decides which frames outputs take: on a Condition branch, that branch’s; under a Crop, its
crops; with no Sink block, every frame.
| Output | Writes | Settings | Inputs |
|---|---|---|---|
annotated_video: true |
The run as its blocks draw it, as a video in its artifacts (for a stream, once it ends) |
- | video, dataset, export, stream |
annotations |
Frames or images with their annotations, into a dataset folder (at most 2,000 a run) | only_with_detections (default true); for video, min_interval_s (at most one frame per that many seconds, up to 3600) |
image, video, dataset, export |
passive_capture |
A frame every every_s seconds, with or without detections |
every_s (1 to 3600, default 10) |
video, stream |
event_capture |
The frame of each chosen event | events (1 to 64 event keys), min_interval_s |
video, stream |
webhook |
A delivery when the run ends, plus its events as they happen (video or stream) |
endpoint (an enabled webhook endpoint’s id), events |
every input |
- Folders.
annotations,passive_captureandevent_captureeach takedataset(name or id; default: the run’s input dataset, for a dataset or export input),directory(such as"/captures"; default: the top folder) andnew_folder_each_run(a folder<workflow name>-<first 8 characters of the run id>inside it; for a stream, the run id its runs list shows). The dataset must be your organization’s and not in cold storage (409dataset_cold). - One capture rate.
event_capture’smin_interval_s(1 to 3600, default 1) caps event and passive captures together, events first, so a busy scene can leave no room for passive frames. An event whose frame is skipped is still posted and logged. - An output the input can’t take, an event the workflow doesn’t offer, or a field the API
doesn’t know is a 400 (
invalid_outputs, naming it). The SDK takes a mapping or aWorkflowRunOutputsand refuses a misspelled field before any request. - A run answers what it writes, resolved, under
outputs(on get_run and each list_runs row): each folder asdataset(its id),dataset_name,directory,new_folder_each_runandfolder(where it writes), the webhook asendpointandevents.Nonewrites nothing but the log. - What a run saved is in its
artifacts: the annotated video, and anannotationsartifact for each output that saved images (output:annotations,event_captureorpassive_capture; its dataset, directory andcount). An output that hit the 2,000-image cap or couldn’t save some images says so in the run’swarnings.
{
"annotated_video": true,
"annotations": {"dataset": "Dock frames", "directory": "/busy",
"new_folder_each_run": true},
"event_capture": {"dataset": "Dock frames",
"events": ["crossing:measure-1:gate", "appearance:forklift"]},
"passive_capture": {"dataset": "Dock frames", "every_s": 30},
"webhook": {"endpoint": "8c1f...", "events": ["crossing:measure-1:gate"]}
}
Event keys
event_capture and webhook pick a workflow’s events by key. endpoint.live.events lists
every event a workflow offers (each trigger, key, kind and
name), plus a passive row for Passive capture.
| Event key | Fires when |
|---|---|
crossing:<measure block>:<line> |
A tracked object crosses the line |
entry:<measure block>:<zone> / exit:... |
A tracked object enters or leaves the zone |
dwell:<measure block>:<zone> |
A visitor stays in a dwell zone for its minimum time |
appearance:<class> / appearance:* |
A new object of the class (or any class) appears: a new track, or without a Track block, the class coming into view |
condition |
The Condition block becomes true |
Endpoint
create makes the endpoint with its region (fixed once deployed), GPU and
autoscaling. Its pk_deploy_ token is in the create response once (endpoint_token); members
can reveal it in the app (Run on the workflow, then Overview). The endpoint deploys
once the workflow has something to run and picks up every save. An older workflow without one
gets it at its first run, or from deploy. An edge workflow holds none of
this: it runs in the browser of whoever opens it.
- Runs queue until the endpoint is up, holds the run’s models and has room: one run a
container, up to
max_containers(endpoint.run_limit). A queued run’sdispatch_notesays what it waits for. A run not started within 30 minutes fails, and a run is stopped after an hour. A run never shares its GPU. - Streams run beside the runs, four per container (
endpoint.stream_limit): Serve it live. - States.
endpoint.statusisdraft(nothing to run yet;error_messagesays why),provisioning,active,pausedorfailed. An active endpoint’sruntime.stateislive,starting,waiting(for a GPU) orasleep(scaled to zero; the next run or stream wakes it in about 20 seconds). The workflow’s ownstatus(draft,ready,archived) is a label for you. - No GPU free. If no GPU is free in the region for 30 seconds, runs and streams are
offered GPUs elsewhere in the US, at the endpoint’s price (
endpoint.region_fallback;runtime.fallbackcounts containers running elsewhere). See Regions. - Cost. The endpoint’s containers, by the minute at its GPU’s price in its region, from
start until
scaledown_windowafter the last run or stream ends, failed and cancelled runs included (endpoint.accrued_cost_micro_usd). Add a SAM3 block’s GPU seconds, charged when its run ends, and streams’ data transfer. A run’sfinal_micro_usdis its share: its own seconds at the endpoint’s price, plus its SAM3 charge. Nothing is charged up front.
Compute
A workflow’s compute is its endpoint’s GPU; each Model block holds its own precision. A run
records both (WorkflowRun.compute).
| Choice | Set on | Values | Notes |
|---|---|---|---|
gpu |
The workflow’s compute |
t4 (default, 16 GB), l4 (24 GB) |
Both can encode annotated video; prices per region in compute_options |
precision |
A Model block’s config |
fp32 (default), fp16 (an edge workflow’s default) |
fp16 is faster and as accurate, but not output-identical |
A SAM3 block runs on a separate shared GPU, charged at the t4 price when the run ends.
The first deploy of a model on a GPU at a precision builds its TensorRT engine (a minute or
two for most models, unbilled; later deploys reuse it). A queued run shows the build in
engine_build: "building" (each model and precision, its start, and estimate_s from
earlier builds on that GPU), then "built" (each model’s build_s); None on stored engines.
A compute with another GPU, or with a precision in it, is a 400 that says what’s allowed.
Build a graph
nodes
Every block a graph can hold, with its ports, a new block’s config (new_block), its settings
(fields: type, required, default and allowed values) and its validation rules, plus the graph
format (graph).
Source: Workflows.nodes
catalog = client.workflows.nodes()
for block in catalog.nodes:
print(block.type, block.inputs, "->", block.output)
measure = catalog.card("measure")
for setting in measure.fields[0].fields or []:
print(setting.key, setting.default, setting.values)
pictograph workflows nodes # every block, in one table
pictograph workflows nodes measure # one block's card, as JSON
curl -s "https://api.pictograph.io/api/v1/developer/workflows/nodes" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns WorkflowNodeCatalog
WorkflowNodeCatalog · 2 fields
class WorkflowNodeCatalog(BaseModel):
"""Every block type (`nodes`, in the editor's order) and how a graph is written (`graph`)."""
graph: dict[str, Any] = {}
nodes: list[WorkflowNodeCard] = []
templates
The app’s “New workflow” templates (traffic monitoring, parking occupancy, retail dwell, package sorting, sports, quality inspection, a line counter, dwell time and a blank canvas), each with a graph lacking only what’s yours to give: a model, and the line or zone to measure.
Source: Workflows.templates
for template in client.workflows.templates():
print(template.key, template.title)
pictograph workflows templates
pictograph workflows templates traffic -o graph.json
curl -s "https://api.pictograph.io/api/v1/developer/workflows/templates" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Sequence[WorkflowTemplate]
WorkflowTemplate · 4 fields
class WorkflowTemplate(BaseModel):
"""A template from the app's "New workflow" list, with its graph; `client.workflows.create(name, template_key=key)` starts from it."""
key: str
title: str
description: str
graph: dict[str, Any] = {}
validate
Check whether a run of a graph would start, without saving or running anything: every issue a
start would raise, each on its block (node_id), with the models and datasets it names looked
up (only your balance isn’t checked). source checks against an input too (a link is judged by
its kind, never downloaded), and outputs, given with a source, are checked as a run would
check them. valid is true when no issue is an error; warnings (a block that feeds nothing, a
dataset cut at 2,000 images) keep it valid. Any role can call it.
Source: Workflows.validate
report = client.workflows.validate(graph=graph)
if not report.valid:
for issue in report.errors:
print(issue.node_id, issue.code, issue.message)
# Against the input a run would name, and what it would write:
report = client.workflows.validate(
graph=graph,
source={"kind": "dataset", "dataset": "Lobby cams", "directory": "/north"},
outputs={"annotations": {"directory": "/drafts"}},
)
# Exit 6, every issue on stderr, when the graph would not run.
pictograph workflows validate --graph graph.json
pictograph workflows validate "Vehicle detector" # a saved one
pictograph workflows validate "Vehicle detector" --dataset "Lobby cams" --directory /north \
--outputs '{"annotations": {"directory": "/drafts"}}'
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/validate" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"graph": '"$(cat graph.json)"', "source": {"kind": "dataset", "dataset": "Lobby cams"}}'
Returns WorkflowValidation
WorkflowValidation · 2 fields
class WorkflowValidation(BaseModel):
"""Whether a run of a graph would start: `valid` when no issue is an error, and every issue."""
valid: bool
issues: list[WorkflowIssue] = []
# The issues that stop a run.
@property
def errors(self) -> list[WorkflowIssue]: ...
Create and manage
compute_options
Each GPU with its memory and its endpoint’s price a minute and an hour in one region, each precision, the default, and every region. Prices are in µUSD.
Source: Workflows.compute_options
| Arg | Type | Default | Notes |
|---|---|---|---|
region |
str | None |
None |
Region to price, us-east or us-west; None is the one nearest the caller |
options = client.workflows.compute_options(region="us-west")
for gpu in options.gpus:
print(gpu.gpu, gpu.label, f"{gpu.vram_gb} GB", f"${gpu.cost_per_hour_micro_usd / 1_000_000:.2f} per hour")
print(options.default.gpu, [r.id for r in options.regions]) # 't4', ['us-east', 'us-west']
pictograph workflows compute-options --region us-west
curl -s "https://api.pictograph.io/api/v1/developer/workflows/compute-options?region=us-west" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns WorkflowComputeOptions
WorkflowComputeOptions · 6 fields
class WorkflowComputeOptions(BaseModel):
"""A workflow's compute choices, priced in one region: each GPU with its memory and price, each precision a Model block may take, the default, and every region."""
gpus: list[WorkflowComputeGpu] = []
precisions: list[WorkflowComputePrecision] = []
default: WorkflowCompute = WorkflowCompute(gpu='t4')
region: str | None = None
regions: list[DeploymentRegion] = []
transfer_per_gib_micro_usd: int | None = None
create
Create a workflow from a graph, from a template (template_key), or empty. It
returns with status draft, validation listing what would still block a run (such as a
template’s missing model, line or zone), and its endpoint, whose token appears in
this response once (endpoint_token).
Source: Workflows.create
| Arg | Type | Default | Notes |
|---|---|---|---|
name |
str |
required | Workflow name |
graph |
dict[str, Any] | None |
None |
The graph |
readme |
str | None |
None |
Workflow card, in Markdown |
description |
str | None |
None |
One-line summary |
template_key |
str | None |
None |
Template key, used when there’s no graph |
compute |
WorkflowCompute | Mapping[str, Any] | None |
None |
Endpoint GPU, e.g. {"gpu": "l4"}; None is a T4 (Compute) |
region |
str |
"auto" |
us-east, us-west, or auto (nearest the caller) |
min_containers |
int |
0 |
Containers kept warm for streams, 0 to 5 (billed while warm); runs start their own |
max_containers |
int |
1 |
Most containers, 1 to 10; each holds four streams or one run |
scaledown_window |
int |
60 |
Seconds a container stays after its last run or stream, 2 to 3600 |
environment |
Literal["cloud", "edge"] |
"cloud" |
Where it runs, fixed once made: cloud (its endpoint, above) or edge (the browser of whoever opens its Run view, on that device’s GPU), which takes no compute, region or autoscaling (Edge) |
graph = {
"version": 1,
"nodes": [
{"id": "s", "type": "source"},
{"id": "m", "type": "model", "config": {"model_id": "your-model-uuid", "confidence_threshold": 0.4}},
{"id": "f", "type": "filter", "config": {"keep_classes": ["car", "truck"]}},
{"id": "k", "type": "sink"},
],
"edges": [
{"source": "s", "target": "m"},
{"source": "m", "target": "f"},
{"source": "f", "target": "k"},
],
}
wf = client.workflows.create(
name="Vehicle detector",
graph=graph,
)
print(wf.id, wf.status, wf.endpoint.region) # 'draft', and the region nearest you
token = wf.endpoint_token # in this response once
# Or on an L4, its model at fp16 (the Model block's own precision):
graph["nodes"][1]["config"]["precision"] = "fp16"
wf = client.workflows.create(
name="Vehicle detector (L4)",
graph=graph,
compute={"gpu": "l4"},
region="us-west",
max_containers=2,
)
print(wf.compute.gpu)
# Or from a template: give it a model and a line, then validate.
wf = client.workflows.create(
name="Gate counter",
template_key="line_counter",
)
print([issue.code for issue in wf.validation]) # ['model_missing', 'measure_no_geometry']
# Or on the edge: it runs in the browser that opens its Run view, on that device's GPU.
wf = client.workflows.create(
name="Gate counter (edge)",
graph=graph,
environment="edge",
)
print(wf.endpoint.environment, wf.endpoint_token) # 'edge' None
pictograph workflows create "Vehicle detector" --graph graph.json
pictograph workflows create "Vehicle detector (L4)" --graph graph.json --gpu l4 --region us-west --max-containers 2
pictograph workflows create "Gate counter" --template line_counter
pictograph workflows create "Gate counter (edge)" --graph graph.json --environment edge
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Vehicle detector", "graph": '"$(cat graph.json)"', "compute": {"gpu": "l4"}, "region": "us-west", "max_containers": 2}'
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
list
Every workflow in your organization.
Source: Workflows.list
for w in client.workflows.list():
print(w.id, w.name, w.status)
pictograph workflows list
curl -s "https://api.pictograph.io/api/v1/developer/workflows/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Sequence[Workflow]
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
get
One workflow. validation lists what would block a run, each issue
{code, message, node_id, severity} on its block, recomputed on every read.
Source: Workflows.get
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
wf = client.workflows.get(workflow="Vehicle detector")
print(wf.status, wf.last_run_id, wf.graph)
pictograph workflows get "Vehicle detector"
curl -s "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
update
Change only the fields you pass. graph replaces the whole graph; a compute change redeploys
the endpoint on that GPU.
Source: Workflows.update
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
name |
str | None |
None |
New name |
readme |
str | None |
None |
New card, in Markdown |
description |
str | None |
None |
New summary |
graph |
dict[str, Any] | None |
None |
New graph |
status |
WorkflowStatus | None |
None |
Label: draft, ready or archived |
compute |
WorkflowCompute | Mapping[str, Any] | None |
None |
New endpoint GPU, e.g. {"gpu": "l4"} |
wf = client.workflows.update(
workflow="Vehicle detector",
status="ready",
)
# Run it on an L4 from now on:
wf = client.workflows.update(
workflow="Vehicle detector",
compute={"gpu": "l4"},
)
print(wf.compute.gpu)
pictograph workflows update "Vehicle detector" --status ready
pictograph workflows update "Vehicle detector" --gpu l4
curl -s -X PATCH "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"status": "ready", "compute": {"gpu": "l4"}}'
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
delete
Delete a workflow, its endpoint and its run history.
Source: Workflows.delete
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
client.workflows.delete(workflow="Vehicle detector")
pictograph workflows delete "Vehicle detector" --yes
curl -s -X DELETE "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns None
bulk_delete
Delete many workflows in one call. A name that isn’t found is listed in not_found.
Source: Workflows.bulk_delete
| Arg | Type | Default | Notes |
|---|---|---|---|
workflows |
Sequence[str] |
required | Workflow names or ids; duplicates are ignored |
res = client.workflows.bulk_delete(workflows=["Vehicle detector", "Dwell monitor"])
print(res.succeeded, res.not_found, res.count)
pictograph workflows delete "Vehicle detector" "Dwell monitor" --yes
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/bulk-delete" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"workflow_ids": ["<uuid-a>", "<uuid-b>"]}'
Returns BulkDeleteResult
BulkDeleteResult · 3 fields
class BulkDeleteResult(BaseModel):
"""What a bulk delete removed."""
# Ids that existed and were deleted.
succeeded: list[str] = []
# Ids that were not found.
not_found: list[str] = []
# How many were deleted.
count: int = 0
# The same as succeeded.
@property
def deleted(self) -> list[str]: ...
Run over files and datasets
run
Run a workflow on one input, writing the outputs you name. The run queues until the endpoint is up and has room; the call returns its id at once.
source is one of:
- A local path (
strorPath) to a video or image: it’s uploaded (upload_source), then run. - A link (a
strstartinghttp://orhttps://) to a video or image: Pictograph downloads it and runs on its copy. The kind comes from the link’s extension; for a link without one, use a mapping withurl. - Bytes of a video or image: the kind is read from the bytes, then they’re uploaded.
- A mapping (or
WorkflowRunInput) with akind:dataset:dataset, its name or id, and optionally one folder of it,directory.export:export, its name or id: the images it captured.videoorimage:videoorimage, a handle from upload_source, orurl, a link to download. A video also takessample_fpsandduration_seconds.
A mistyped mapping key, or a sample_fps for anything but a video, raises before any request.
A link is downloaded before the call returns (a video up to 1 GB, an image up to 25 MB, within
10 minutes); it must lead to the file itself, not a web page.
Video, dataset and export runs have a live view (watch_run); its pictures are off
unless stream=True, so an unwatched run draws nothing. On an image run, stream or overlay
raises ValueError before any upload.
Source: Workflows.run
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
source |
RunSource |
required | What it runs on (above) |
sample_fps |
float | None |
None |
Video frames to read per second (up to 60); None reads every frame |
outputs |
RunOutputs | None |
None |
What it writes (Outputs); None writes only its log |
stream |
bool | None |
None |
Send the live view’s pictures from the start (otherwise none until set_stream(True)); not for images |
overlay |
bool | None |
None |
Draw the workflow’s look on the live view (default on); not for images |
confidence |
float | None |
None |
Every whole-frame model’s confidence as it starts, over 0 and at most 1 (default: each Model block’s own); move it while it runs with its live view’s set_confidence |
wait |
bool |
False |
Wait for the run to end and return it |
poll_interval |
float |
5.0 |
Seconds between checks |
timeout |
float |
3600.0 |
Max seconds to wait |
# A video on disk, uploaded for you, drawn as a video; wait for the counts.
run = client.workflows.run(
workflow="Vehicle detector",
source="clip.mp4",
outputs={"annotated_video": True},
wait=True,
)
print(run.step_results, run.source.name, run.artifacts)
# A video at a link, two frames a second: Pictograph downloads it, then runs.
run = client.workflows.run(
workflow="Vehicle detector",
source="https://example.com/clips/north-cam.mp4",
sample_fps=2,
wait=True,
)
# One folder of a dataset, its annotations written to a folder of it, without waiting.
created = client.workflows.run(
workflow="Vehicle detector",
source={"kind": "dataset", "dataset": "Rush-hour clips", "directory": "/north-cam"},
outputs={"annotations": {"directory": "/north-cam-labels"}},
)
print(created.run_id, created.status_url)
# An export's images; then the same input again, as the run recorded it.
run = client.workflows.run(
workflow="Vehicle detector",
source={"kind": "export", "export": "Night shift"},
wait=True,
)
again = client.workflows.run(
workflow="Vehicle detector",
source=run.source.input,
)
# A file on disk (uploaded), a link Pictograph downloads, or a video piped in:
pictograph workflows run "Vehicle detector" --file clip.mp4 --write-video
pictograph workflows run "Vehicle detector" --file https://example.com/clips/north-cam.mp4 --sample-fps 2
cat clip.mp4 | pictograph workflows run "Vehicle detector" --file -
# Its live view's pictures on from the start, without waiting (then: workflows watch):
pictograph workflows run "Vehicle detector" --file clip.mp4 --stream --no-wait
# --video / --image say the kind of a link without an extension:
pictograph workflows run "Vehicle detector" --video https://example.com/live/north
# One folder of a dataset, or an export's images, without waiting:
pictograph workflows run "Vehicle detector" --dataset "Rush-hour clips" --directory /north-cam \
--outputs '{"annotations": {"directory": "/north-cam-labels"}}' --no-wait
pictograph workflows run "Vehicle detector" --export "Night shift" --outputs @outputs.json --no-wait
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector/run" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"source": {"kind": "dataset", "dataset": "Rush-hour clips", "directory": "/north-cam"},
"outputs": {"annotations": {"directory": "/north-cam-labels"}}}'
# A link Pictograph downloads first, two frames a second; ?wait=true waits up to 300 seconds:
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector/run?wait=true" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"source": {"kind": "video", "url": "https://example.com/clips/north-cam.mp4", "sample_fps": 2}}'
Returns WorkflowRunCreated | WorkflowRun
WorkflowRunCreated · 2 fields
class WorkflowRunCreated(BaseModel):
"""What `run` returns at once: the new run's id. The run is billed as its endpoint's uptime; its share lands on `final_micro_usd` when it ends."""
run_id: str
status_url: str | None = None
WorkflowRun · 27 fields
class WorkflowRun(BaseModel):
"""One execution of a workflow over a source."""
id: str
organization_id: str
workflow_id: str
status: Literal['queued', 'processing', 'completed', 'error', 'cancelled']
progress: float = 0.0
frames_total: int | None = None
frames_done: int = 0
sample_fps: float | None = None
step_results: dict[str, Any] = {}
condition_results: dict[str, Any] = {}
artifacts: list[dict[str, Any]] = []
warnings: list[str] = []
final_micro_usd: int | None = None
error: str | None = None
dispatch_note: str | None = None
endpoint_id: str | None = None
has_log: bool = False
compute: WorkflowRunCompute = ...
engine_build: EngineBuild | None = None
source: WorkflowRunSource | None = None
stream_session: str | None = None
outputs: WorkflowRunWrites | None = None
live_view: WorkflowRunLiveView | None = None
recording: WorkflowRunRecording | None = None
result: dict[str, Any] | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
upload_source
Upload a local video or image and get its handle, to name in a run:
{"kind": "video", "video": handle}. run does this for a local path; call it yourself
to upload once and run several times.
Source: Workflows.upload_source
| Arg | Type | Default | Notes |
|---|---|---|---|
file_path |
str | Path |
required | Local video or image file |
content_type |
str | None |
None |
MIME type (default: from the extension) |
handle = client.workflows.upload_source(file_path="clip.mp4")
for name in ("Vehicle detector", "Gate counter"):
client.workflows.run(
workflow=name,
source={"kind": "video", "video": handle},
)
# The CLI uploads and runs in one step:
pictograph workflows run "Vehicle detector" --file clip.mp4
# 1. A signed upload URL, and the file's handle (as "video" or "image", by its content type):
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/upload-url" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"filename": "clip.mp4", "content_type": "video/mp4"}'
# 2. PUT the bytes to the returned upload_url (same Content-Type), then run on the handle:
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Vehicle%20detector/run" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" -H "Content-Type: application/json" \
-d '{"source": {"kind": "video", "video": "<handle>"}}'
Returns str
wait_for_run
Wait for a run to end: it returns a completed run and raises ApiError for one that ends
error or cancelled.
Source: Workflows.wait_for_run
| Arg | Type | Default | Notes |
|---|---|---|---|
run |
str |
required | Run id |
poll_interval |
float |
5.0 |
Seconds between checks |
timeout |
float |
3600.0 |
Max seconds to wait |
run = client.workflows.wait_for_run(
run=created.run_id,
poll_interval=5.0,
timeout=3600.0,
)
for art in run.artifacts:
print(art["kind"], art.get("download_url"))
# `run` waits for the run unless --no-wait:
pictograph workflows run "Vehicle detector" --file clip.mp4 --timeout 3600
# Poll the run until status is terminal.
curl -s "https://api.pictograph.io/api/v1/developer/workflows/runs/<run-id>" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns WorkflowRun
WorkflowRun · 27 fields
class WorkflowRun(BaseModel):
"""One execution of a workflow over a source."""
id: str
organization_id: str
workflow_id: str
status: Literal['queued', 'processing', 'completed', 'error', 'cancelled']
progress: float = 0.0
frames_total: int | None = None
frames_done: int = 0
sample_fps: float | None = None
step_results: dict[str, Any] = {}
condition_results: dict[str, Any] = {}
artifacts: list[dict[str, Any]] = []
warnings: list[str] = []
final_micro_usd: int | None = None
error: str | None = None
dispatch_note: str | None = None
endpoint_id: str | None = None
has_log: bool = False
compute: WorkflowRunCompute = ...
engine_build: EngineBuild | None = None
source: WorkflowRunSource | None = None
stream_session: str | None = None
outputs: WorkflowRunWrites | None = None
live_view: WorkflowRunLiveView | None = None
recording: WorkflowRunRecording | None = None
result: dict[str, Any] | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
watch_run
Watch a video, dataset or export run: each frame’s results and its live view. It waits for the
run’s first frames, then joins with the endpoint’s token. A run started without stream=True
sends no picture until set_stream(True).
Source: Workflows.watch_run
created = client.workflows.run(
workflow="Vehicle detector",
source="clip.mp4",
)
with client.workflows.watch_run(
run=created.run_id,
token="pk_deploy_...",
) as live:
live.set_stream(on=True) # the live view's pictures, at live.whep_url
for frame in live.frames():
print(frame.index, frame.result)
print(live.ended) # run_completed, run_failed or run_cancelled
# One JSON line per frame, and where to watch the live view; --stream turns its pictures on.
pictograph workflows watch <run-uuid> --token pk_deploy_... --stream
# Ctrl-C stops watching; the run goes on.
# The run's live view, once it's dispatched: "live_view": {"stream": false, "overlay": true, "session": "9c2e41d07ab35f88"}
curl -s "https://api.pictograph.io/api/v1/developer/workflows/runs/<run-id>" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
# Join it on the workflow's endpoint_url (its sessions): its paths, and ICE servers for a WHEP player.
curl -s "$ENDPOINT_URL/9c2e41d07ab35f88?ice=1" -H "Authorization: Bearer pk_deploy_..."
# Turn its pictures on.
curl -s -X POST "$ENDPOINT_URL/9c2e41d07ab35f88/stream" -H "Authorization: Bearer pk_deploy_..." \
-H "Content-Type: application/json" -d '{"on": true}'
Returns DeploymentStream[Any]
The stream is a deployment’s open_stream stream
joined to the run: frames(), messages(), whep_url, set_stream, set_overlay and
set_confidence (the run’s confidence, from its next frame) work as on any stream. It ends with
the run; stop() only stops watching
(cancel_run stops the run). A run’s live view doesn’t count against the stream
limit and works with a SAM3 block. Watching with the stream on slows a run by about 2% (T4).
get_run
A run’s state and, once it completes, its artifacts with download links.
Source: Workflows.get_run
| Arg | Type | Default | Notes |
|---|---|---|---|
run |
str |
required | Run id |
run = client.workflows.get_run(run=created.run_id)
print(run.status, f"{run.frames_done}/{run.frames_total}", f"{run.progress:.0f}%")
pictograph workflows run-status 7f3a1b2c-4d5e-4f60-8a91-2b3c4d5e6f70
curl -s "https://api.pictograph.io/api/v1/developer/workflows/runs/$RUN_ID" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns WorkflowRun
WorkflowRun · 27 fields
class WorkflowRun(BaseModel):
"""One execution of a workflow over a source."""
id: str
organization_id: str
workflow_id: str
status: Literal['queued', 'processing', 'completed', 'error', 'cancelled']
progress: float = 0.0
frames_total: int | None = None
frames_done: int = 0
sample_fps: float | None = None
step_results: dict[str, Any] = {}
condition_results: dict[str, Any] = {}
artifacts: list[dict[str, Any]] = []
warnings: list[str] = []
final_micro_usd: int | None = None
error: str | None = None
dispatch_note: str | None = None
endpoint_id: str | None = None
has_log: bool = False
compute: WorkflowRunCompute = ...
engine_build: EngineBuild | None = None
source: WorkflowRunSource | None = None
stream_session: str | None = None
outputs: WorkflowRunWrites | None = None
live_view: WorkflowRunLiveView | None = None
recording: WorkflowRunRecording | None = None
result: dict[str, Any] | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
| Field | Meaning |
|---|---|
step_results |
Per Measure block: aggregate (the headline numbers), time_series and per_track events |
artifacts |
[{kind, filename, bytes, download_url}]: the annotated video, and an annotations artifact for each output that saved images (Outputs) |
outputs |
What it writes, resolved (Outputs); None writes only its log |
recording |
A stream run’s annotated video (Live outputs): state (saved, partial or none), bytes, parts, at and detail; None while streaming or when none was asked for |
live_view |
Video, dataset and export runs: stream and overlay as started, and session once dispatched (None while queued; watch_run); None for image and stream runs |
result |
A single image’s frame, {"frames": [{"frame", "t", "annotations"}]}; None for other runs |
source |
What it ran on: kind, name (the file’s, dataset’s or export’s) and input, which run takes to run it again |
list_runs
One page of a workflow’s runs, newest first (get_run has the full record). Each
stream is a run too: source.kind is "stream", source.via how its video came in (whip,
rtsp or whep), and stream_session its session.
Source: Workflows.list_runs
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
limit |
int |
50 |
Page size (max 100) |
offset |
int |
0 |
Items to skip |
kind |
WorkflowRunsKind |
"all" |
all, file (video, image, dataset or export runs) or stream |
runs = client.workflows.list_runs(
workflow="Line counter",
limit=20,
)
for run in runs:
print(run.id, run.status, f"${run.cost_micro_usd / 1_000_000:.2f}", f"{run.artifact_count} artifacts")
pictograph workflows runs "Line counter" --limit 20
curl -s "https://api.pictograph.io/api/v1/developer/workflows/$WORKFLOW_ID/runs?limit=20" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Sequence[WorkflowRunSummary]
WorkflowRunSummary · 20 fields
class WorkflowRunSummary(BaseModel):
"""A run as `client.workflows.list_runs` lists it."""
id: str
status: Literal['queued', 'processing', 'completed', 'error', 'cancelled']
created_at: datetime | None = None
completed_at: datetime | None = None
runtime_seconds: float | None = None
cost_micro_usd: int = 0
cost_settled: bool = False
frames_done: int = 0
frames_total: int | None = None
progress: float = 0.0
artifact_count: int = 0
has_log: bool = False
compute: WorkflowRunCompute = ...
engine_build: EngineBuild | None = None
source: WorkflowRunSource | None = None
stream_session: str | None = None
outputs: WorkflowRunWrites | None = None
live_view: WorkflowRunLiveView | None = None
recording: WorkflowRunRecording | None = None
error: str | None = None
iter_runs
Every run of a workflow, fetched page by page, newest first.
Source: Workflows.iter_runs
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
page_size |
int |
50 |
Items fetched per request |
max_total |
int | None |
None |
Stop after this many items |
kind |
WorkflowRunsKind |
"all" |
As in list_runs |
for run in client.workflows.iter_runs(workflow="Line counter"):
print(run.id, run.status)
# Or materialize every run:
all_runs = client.workflows.iter_runs(workflow="Line counter").all()
print(len(all_runs), "runs")
# The CLI does not auto-page; this lists a single page of up to 100.
pictograph workflows runs "Line counter" --limit 100
# Page manually with limit + offset until pagination.has_more is false.
curl -s "https://api.pictograph.io/api/v1/developer/workflows/$WORKFLOW_ID/runs?limit=100&offset=100" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns OffsetPager[WorkflowRunSummary]
WorkflowRunSummary · 20 fields
class WorkflowRunSummary(BaseModel):
"""A run as `client.workflows.list_runs` lists it."""
id: str
status: Literal['queued', 'processing', 'completed', 'error', 'cancelled']
created_at: datetime | None = None
completed_at: datetime | None = None
runtime_seconds: float | None = None
cost_micro_usd: int = 0
cost_settled: bool = False
frames_done: int = 0
frames_total: int | None = None
progress: float = 0.0
artifact_count: int = 0
has_log: bool = False
compute: WorkflowRunCompute = ...
engine_build: EngineBuild | None = None
source: WorkflowRunSource | None = None
stream_session: str | None = None
outputs: WorkflowRunWrites | None = None
live_view: WorkflowRunLiveView | None = None
recording: WorkflowRunRecording | None = None
error: str | None = None
cancel_run
Stop a run; what it made so far is kept. Endpoint time until it stops is billed; a queued run that never started costs nothing.
Source: Workflows.cancel_run
| Arg | Type | Default | Notes |
|---|---|---|---|
run |
str |
required | Run id |
client.workflows.cancel_run(run=created.run_id)
pictograph workflows cancel 7f3a1b2c-4d5e-4f60-8a91-2b3c4d5e6f70 --yes
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/runs/$RUN_ID/cancel" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns None
bulk_cancel_runs
Cancel several runs in one call, billed as with cancel_run. A run that has
ended, or isn’t found, is listed in not_found.
Source: Workflows.bulk_cancel_runs
| Arg | Type | Default | Notes |
|---|---|---|---|
runs |
Sequence[str] |
required | Run ids |
result = client.workflows.bulk_cancel_runs(
runs=[
"7f3a1b2c-4d5e-4f60-8a91-2b3c4d5e6f70",
"8a4b2c3d-5e6f-4071-9b02-3c4d5e6f7081",
],
)
print(result.count, "cancelled;", result.not_found, "skipped")
pictograph workflows cancel-batch \
7f3a1b2c-4d5e-4f60-8a91-2b3c4d5e6f70 8a4b2c3d-5e6f-4071-9b02-3c4d5e6f7081 --yes
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/runs/bulk-cancel" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"runs": ["7f3a1b2c-4d5e-4f60-8a91-2b3c4d5e6f70", "8a4b2c3d-5e6f-4071-9b02-3c4d5e6f7081"]}'
Returns BulkActionResult
BulkActionResult · 3 fields
class BulkActionResult(BaseModel):
"""What a bulk change (pause, resume, cancel) did."""
# Ids this call changed.
succeeded: list[str] = []
# Ids not found, or not in a state it could change.
not_found: list[str] = []
# How many were changed.
count: int = 0
Serve it live
The endpoint runs a camera, video or stream through the workflow frame by frame and returns each frame’s results, like a deployment’s stream; the Streams guide covers the stream itself.
- A workflow can stream once it has a Model block with a model. A SAM3 block can’t run live: a
workflow with one runs files but refuses streams (
endpoint.streamsisFalse). - A save takes effect at the next stream; one that needs another model, precision or GPU
redeploys the endpoint first. After a save that adds a SAM3 block, the last streamable
version keeps streaming only while the endpoint can also run the new version’s runs;
otherwise streams are refused and
error_messagesays why. - Streams use the endpoint’s token, never an API key; connect gives a client. Each
StreamFramecarries the frame’s results andmeasures: each line’s and zone’s counts by id, named inendpoint.live.measures(L1,P1, …). - Each stream is also a run: list_runs with
kind="stream"lists them.
wf = client.workflows.create(
name="Gate counter",
graph=graph,
region="us-west",
)
token = wf.endpoint_token # in this response once
wf = client.workflows.wait_until_live(workflow=wf)
live = client.workflows.connect(
workflow=wf,
token=token,
)
with live.open_stream(source="rtsp://camera.example.com:554/live") as stream:
for frame in stream.frames():
print(frame.index, frame.measures)
pictograph workflows create "Gate counter" --graph graph.json --region us-west # prints its token once
pictograph workflows stream "Gate counter" rtsp://camera.example.com:554/live --token pk_deploy_...
pictograph workflows stream "Gate counter" rtsp://camera.example.com:554/live --token pk_deploy_... --outputs @outputs.json
pictograph workflows stream "Gate counter" rtsp://camera.example.com:554/live --token pk_deploy_... --write-video
Live outputs
A stream writes the outputs picked when it opens: outputs beside source in
open_stream (or the session request), shaped like a run’s. The open returns them resolved
(stream.outputs).
with live.open_stream(
source="rtsp://camera.example.com:554/live",
outputs={
"annotated_video": True,
"event_capture": {"dataset": "Dock frames", "events": ["entry:measure-1:bay"]},
"passive_capture": {"dataset": "Dock frames", "every_s": 30},
"webhook": {"endpoint": "8c1f...", "events": ["crossing:measure-1:gate"]},
},
) as stream:
print(stream.outputs)
- Webhook - posts the events it picked in a
workflow_stream.eventsdelivery (at most one a second, with every event since), and aworkflow_stream.endeddelivery when the stream ends. - Annotated video - records the stream as its blocks draw it, saving as it goes, so a lost
container keeps what was saved. When the stream ends it becomes one video (
annotated.mp4) in the stream run’sartifacts, usually within seconds; the run’srecordingsays whether it’s whole. An endpoint that can’t write one yet answers 409invalid_outputsuntil it updates (within minutes, or at once if you pause and resume it). - Captures - save each picked event’s frame (
event_capture) and a frame everyevery_sseconds (passive_capture), with annotations, under onemin_interval_scap on the stream’s own clock (Outputs). - Counts -
endpoint.live_outputscounts its streams’ events, deliveries, frames saved, frames not saved (with the last reason: a cold dataset, the image limit, a failed upload) and frames skipped. A failed upload’scapture_uploadedlog record hascapture_okfalse andcapture_detailsaying why. - Log names - a log page’s
event_namesnames each record’strigger, and an event’svalues_textgives its values in words (1 crossed,Lot: 3 inside).
deploy
Redeploy a failed or draft endpoint. For an older workflow without one, it creates the
endpoint with the given region and autoscaling and returns its token once. A live endpoint is
a 409 (not_failed).
Source: Workflows.deploy
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
region |
str |
"auto" |
As in create |
min_containers |
int |
0 |
As in create |
max_containers |
int |
1 |
As in create |
scaledown_window |
int |
60 |
As in create |
wf = client.workflows.deploy(
workflow="Gate counter",
region="us-east",
max_containers=2,
)
print(wf.endpoint.status, wf.endpoint_token)
pictograph workflows deploy "Gate counter" --region us-east --max-containers 2 --wait
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter/deploy" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"region": "us-east", "max_containers": 2}'
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
wait_until_live
Wait until the endpoint is active (asleep counts, as does one that runs files but can’t
stream). It raises ApiError, with the workflow as its response, when waiting can’t help:
not_deployed, workflow_not_runnable, a failed deploy or a pause.
Source: Workflows.wait_until_live
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str | Workflow |
required | Workflow name or id, or a Workflow |
timeout |
float |
900.0 |
Max seconds to wait; the deploy continues |
poll_interval |
float |
5.0 |
Seconds between checks |
wf = client.workflows.wait_until_live(
workflow="Gate counter",
timeout=600,
)
print(wf.endpoint.runtime.state) # 'asleep' until a stream starts
pictograph workflows deploy "Gate counter" --wait
# Poll the workflow until endpoint.status is "active":
curl -s "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
update_endpoint
Change the endpoint’s autoscaling; only what you pass changes. A live endpoint applies it at once, a paused one when resumed. A minimum above 0 is billed continuously.
Source: Workflows.update_endpoint
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
min_containers |
int | None |
None |
As in create |
max_containers |
int | None |
None |
As in create |
scaledown_window |
int | None |
None |
As in create |
wf = client.workflows.update_endpoint(
workflow="Gate counter",
max_containers=3,
scaledown_window=300,
)
print(wf.endpoint.max_containers, wf.endpoint.stream_limit)
pictograph workflows scale "Gate counter" --max-containers 3 --scaledown-window 300
curl -s -X PATCH "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter/endpoint" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"max_containers": 3, "scaledown_window": 300}'
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
pause
Pause a workflow: its endpoint stops and billing stops. Runs and streams are refused until you resume it.
Source: Workflows.pause
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
wf = client.workflows.pause(workflow="Gate counter")
print(wf.endpoint.status) # 'paused'
pictograph workflows pause "Gate counter"
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter/pause" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
resume
Resume a paused workflow: its endpoint redeploys with the current graph.
Source: Workflows.resume
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id |
wf = client.workflows.resume(workflow="Gate counter")
print(wf.endpoint.status) # 'provisioning'
pictograph workflows resume "Gate counter" --wait
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter/resume" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Workflow
Workflow · 15 fields
class Workflow(BaseModel):
"""A saved node-graph workflow."""
id: str
organization_id: str
name: str
description: str | None = None
readme: str | None = None
graph: dict[str, Any] = {}
template_key: str | None = None
status: Literal['draft', 'ready', 'archived'] = 'draft'
compute: WorkflowCompute = WorkflowCompute(gpu='t4')
last_run_id: str | None = None
validation: list[WorkflowIssue] = []
endpoint: WorkflowEndpoint | None = None
endpoint_token: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
connect
A client for the workflow’s endpoint, for streams: open_stream(source=...), as on a
deployment. Each frame’s result is typed by the first Model block’s task, and
frame.measures holds each line’s and zone’s counts. The endpoint takes streams, not single
images. An edge workflow has no endpoint, so connect raises ValueError for one.
Source: Workflows.connect
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
Workflow |
required | The workflow, as get, create or wait_until_live return it |
token |
str |
required | The endpoint’s pk_deploy_ token (endpoint_token from create, or revealed in the app) |
timeout |
float |
150.0 |
Max seconds a request to the endpoint may take |
wf = client.workflows.get(workflow="Gate counter")
live = client.workflows.connect(
workflow=wf,
token="pk_deploy_...",
)
with live.open_stream(source="rtsp://camera.example.com:554/live") as stream:
for frame in stream.frames():
print(frame.index, frame.measures)
# No `connect` command - it returns an SDK object. The CLI streams the workflow directly:
pictograph workflows stream "Gate counter" rtsp://camera.example.com:554/live --token pk_deploy_...
# `connect` builds a client locally and issues no request of its own. A stream opens
# on the workflow's endpoint_url, its sessions:
curl -s -X POST "$ENDPOINT_URL" \
-H "Authorization: Bearer pk_deploy_..." \
-H "Content-Type: application/json" \
-d '{"source": {"kind": "rtsp", "uri": "rtsp://camera.example.com:554/live"}}'
Returns DeploymentClient[Any]
Edge
An edge workflow runs in the browser of whoever opens its Run view, on that device’s own GPU
(WebGPU): each model’s ONNX graph runs on that GPU, and Pictograph’s engine, compiled to
WebAssembly, runs every block a frame passes (its lines and zones, tracker, conditions and
look). Its events, captures and webhook act as a cloud stream’s do, and each stream is one of its
runs. It holds no GPU of ours, so nothing is deployed or billed for compute, and its endpoint has
no URL, token, region or GPU. Create one with create and environment="edge" (fixed
once made), then run it from its Run view in the app (Workflows, then Run): a camera, or a
video file played once, start to finish. A file or dataset run is a cloud workflow’s, and an edge
stream is never recorded. It needs a browser with WebGPU: Chrome or Edge on a computer, or Safari
on macOS 26 and later.
Each Model block runs at FP16 unless its precision is fp32; a GPU without 16-bit shaders runs
the model’s FP32 graph instead. The first time a model runs on the edge at FP16 its FP16 graph is
built (a minute or two, not billed): the workflow’s endpoint is provisioning until it is ready,
with engine_build reporting the build.
edge_session
Open a stream of an edge workflow, to run it yourself: its spec (the compiled workflow, its one
source this stream’s), each model’s ONNX graph (a download URL good for 60 minutes, and the key its
bytes are cached by) and the config its engine reads it by, its outputs as resolved, its own
token (good until expires_at), events_url (where its events, its end and its reports go, the
token as a bearer), its log and its watermark. The app’s Run view runs it from exactly this. Any
role may open one with no outputs; writing (a dataset’s captures, a webhook) takes a member or
above. A cloud workflow, or one that cannot stream, answers 409.
Source: Workflows.edge_session
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | Workflow name or id: an edge one |
outputs |
RunOutputs | None |
None |
What the stream writes beside its log (Outputs): event_capture, passive_capture or webhook, never annotated_video (raises ValueError before any request) |
session = client.workflows.edge_session(
workflow="Gate counter (edge)",
outputs={"event_capture": {"dataset": "Street scenes", "events": ["crossing:ms:l1"]}},
)
print(session.session_id, [m.graph.cache_key for m in session.models])
print(session.events_url, session.expires_at)
pictograph workflows edge-session "Gate counter (edge)"
pictograph workflows edge-session "Gate counter (edge)" --outputs @outputs.json
curl -s -X POST "https://api.pictograph.io/api/v1/developer/workflows/Gate%20counter%20(edge)/edge-sessions" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"outputs": {"event_capture": {"dataset": "Street scenes", "events": ["crossing:ms:l1"]}}}'
Returns WorkflowEdgeSession
WorkflowEdgeSession · 14 fields
class WorkflowEdgeSession(BaseModel):
"""A stream of an EDGE workflow (pictograph.resources.workflows.Workflows.edge_session): what a browser - or a client of your own - runs it with. Its `spec` (the compiled workflow, its one source this session's), each of its `models`, its `outputs` as resolved, its own `token` (good until `expires_at`: its batches' Bearer), `events_url` (a path on the API: where its events, its end and its reports go, as a cloud stream's do), its `log` and its watermark (`mark`: base64 bytes, or None). Its stream runs at most `max_seconds`; each model's graph URL lapses at `graphs_expire_at`."""
session_id: str
token: str
endpoint_id: str
spec: dict[str, Any]
models: list[WorkflowEdgeModel]
outputs: dict[str, Any] | None = None
captures: dict[str, Any] | None = None
events_url: str
log: EdgeLog | None = None
mark: dict[str, Any] | None = None
opened_at: datetime | None = None
max_seconds: int
expires_at: datetime
graphs_expire_at: datetime | None = None
Run and stream logs
Every run and live stream logs its frames, events, stats and status. logs reads the
workflow’s whole Live log, as it arrives or as history: every run’s and every stream’s records
in one shape, filtered by the server. One run’s log is logs(workflow, session=run_id).
logs
The workflow’s records as they arrive (live=True), or over a window, from every run, stream and
device, read page by page as you loop. The record, its webhooks and REST paging: Live log guide.
Source: Workflows.logs
| Arg | Type | Default | Notes |
|---|---|---|---|
workflow |
str |
required | The workflow’s name. |
live |
bool |
False |
A live connection: the records as they arrive, until you stop looping. With since, the history from then first, then live - each record once. |
since |
str | datetime | timedelta | None |
None |
Where the history starts: "now", a duration ago ("30s", "10m", "1h30m", "2d"), an ISO 8601 time, a datetime or a timedelta ago. Default: an hour before until (with live: no history, only what arrives). |
until |
str | datetime | timedelta | None |
None |
Where it ends (the same forms; not with live). Default: now. |
kinds |
Sequence[LogKind] | None |
None |
Only these kinds: "frame", "event", "capture", "stats", "status". Default: every kind the organization’s plan logs (frames on paid plans). |
classes |
Sequence[str] | None |
None |
Only records with an annotation of these classes - each record carrying those alone. |
min_confidence |
float | None |
None |
Only annotations at least this confident (0 to 1). |
session |
str | None |
None |
One stream’s records (the stream’s id) or one run’s (the run’s id). |
every |
int | None |
None |
Every Nth frame of each stream. |
cursor |
str | None |
None |
Where to resume: after a record’s cursor (where an earlier read stopped), or from a gap’s gap.backfill (logs(name, cursor=gap_record.gap.backfill, until=gap_record.time): what the gap stood for - keep each record once by its identity). |
records = client.workflows.logs(
workflow="crosswalk",
kinds=["event"],
since="10m",
)
for record in records:
print(record.time, record.event.name, record.event.text)
pictograph workflows logs crosswalk --kind event --since 10m
# One run's records (its id), one record a line, for jq.
pictograph workflows logs crosswalk --session "$RUN_ID" --json | jq -c '{time, kind}'
curl -s "https://api.pictograph.io/api/v1/developer/workflows/crosswalk/logs?kinds=event&since=10m" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns Iterator[LogRecord]
LogRecord · 20 fields
class LogRecord(BaseModel):
"""One record of a Live log: every kind in one shape; the fields of another kind are `None`."""
# The record's identity, and where a read resumes after it.
cursor: str | None = None
kind: Literal['frame', 'event', 'capture', 'stats', 'status', 'gap']
time: datetime | None = None
# When the log stored it.
logged_at: datetime | None = None
deployment: str | None = None
workflow: str | None = None
# A stream's id, or a workflow run's.
session: str | None = None
# The engine run that wrote it.
run: str | None = None
# Its batch in its run.
seq: int | None = None
# Its place in its batch.
index: int | None = None
source: LogSource | None = None
model: LogModel | None = None
frame: LogFrame | None = None
annotations: list[Annotation] = []
tags: list[LogTag] = []
event: LogEvent | None = None
capture: LogCapture | None = None
stats: LogStats | None = None
status: LogStatus | None = None
gap: LogGap | None = None
# The record's identity: the same for one record wherever it was read - a history
# page, a live connection, a webhook - though a live connection's `cursor` also says
# where it arrived. Keep a gap's backfill to the records not seen yet with it.
# `None` for a record with no cursor (a `capture.saved` delivery's).
@property
def identity(self) -> tuple[Any, ...] | None: ...
session takes a stream’s id (16 hex characters) or a run’s id; a run’s session in its
records is the run’s id. A live connection opens again from where it stood whenever it drops or
the server ends it: nothing is lost or seen twice. Errors are the deployment log’s
(Live log errors), and a session the
workflow never ran is a 404 (session_not_found), as is a run with no log (no_log: it ran
before runs were logged).
Common errors
| Status | Exception | Cause |
|---|---|---|
| 400 | ValidationError |
The graph can’t run (invalid_workflow, each issue on its block); a run with no input (source_required) or an input the graph can’t take; outputs it can’t write (invalid_outputs); a link to a web page or private address; a run naming another GPU (run_compute_retired); or stream / overlay on an image run (live_view_unavailable) |
| 402 | PaymentRequiredError |
Your organization can’t spend |
| 404 | NotFoundError |
The workflow, run, dataset or export doesn’t exist; a run has no log (no_log); or there’s no endpoint (not_deployed) |
| 409 | ConflictError |
The workflow is paused (workflow_paused), its endpoint failed (endpoint_failed; deploy it again) or has nothing to run (workflow_not_runnable); deploy on a live endpoint (not_failed); or an output’s dataset is in cold storage (dataset_cold) |
| 409 | - | A stream of a workflow with a SAM3 block (workflow_not_streamable), or during a redeploy (endpoint_updating) |
| 413 | ApiError |
A linked file over the size limit |
| 502 | ServerError |
A link that can’t be reached |
| - | ConflictError |
watch_run on a run with no live view (no_live_view) or one that ended (run_ended) |
| - | PollTimeoutError |
The wait passed timeout; the run or deploy keeps going |