Workflows

Run a Roboflow Workflow through the inference-sdk client, by workflow ID or by inline specification.

Start a local inference server with inference server start, then run a Workflow:

from inference_sdk import InferenceHTTPClient

# Replace ROBOFLOW_API_KEY with your Roboflow API Key
CLIENT = InferenceHTTPClient(
    api_url="http://localhost:9001",
    api_key="ROBOFLOW_API_KEY"
)

CLIENT.run_workflow(
    specification={
        "version": "1.0",
        "inputs": [
            {"type": "InferenceImage", "name": "image"},
            {"type": "InferenceParameter", "name": "my_param"},
        ],
        # ...
    },
    # OR
    # workspace_name="my_workspace_name",
    # workflow_id="my_workflow_id",

    images={
        "image": "url or your np.array",
    },
    parameters={
        "my_param": 37,
    },
)

Either specification is provided with the specification of the Workflow as described in Workflow Definitions, or both workspace_name and workflow_id are given to use a Workflow predefined in the Roboflow app. workspace_name can be found in the Roboflow app URL once the browser shows the main panel of the workspace.

Server-side caching of Workflow definitions: when you use run_workflow(...) with workspace_name and workflow_id, the server caches the definition for 15 minutes. If you change the definition in the Workflows UI and re-run the method, you may not see the change. To force processing without cache, pass use_cache=False as a parameter of run_workflow(...).

Workflows profiling: you may request a profiler trace by passing enable_profiling=True to run_workflow(...). If the server configuration enables trace exposure, you will find a JSON file with the trace in the directory specified by the profiling_directory parameter of InferenceConfiguration (default: inference_profiling in your current working directory). The traces can be loaded and rendered in Google Chrome at chrome://tracing.