> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/workflows/deploy/deploy-a-workflow.md).

# Deploy a Workflow

You can deploy a Workflow in four ways:

1. Send images to the [Roboflow API](#process-images) for processing using your Workflow.
2. Create a [Roboflow Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) on infrastructure provisioned exclusively for your use.
3. Run your Workflow on your own hardware using [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).
4. Use [Batch Processing](https://docs.roboflow.com/deployment/roboflow-cloud/batch-processing) to process large amounts of data without coding cost efficiently.

### Which option should I use?

| Option                                                                                       | Best for                                                                                                                                                                                                                                |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **HTTP API** (Roboflow hosted, or a self-hosted `inference` server)                          | Using Workflows as a stand-alone service, keeping your application in a language other than Python, or offloading compute-heavy work to dedicated servers.                                                                              |
| [**WebRTC streaming**](/workflows/deploy/video-processing.md)                                | Processing video files, webcams, and camera streams through a Workflow on Serverless or a self-hosted Inference Server.                                                                                                                 |
| [**`inference-cli`**](https://docs.roboflow.com/reference/inference/inference-cli/workflows) | Processing images, directories, or video files from the command line with no code.                                                                                                                                                      |
| [**Batch Processing**](https://docs.roboflow.com/deployment/roboflow-cloud/batch-processing) | Large asynchronous jobs over stored images and videos, with infrastructure provisioned for you.                                                                                                                                         |
| **`inference` Python package**                                                               | Running the Execution Engine directly inside your Python application, with full control and no HTTP hop. See [Execution Engine](/workflows/developer-guide/developer-guide/execution-engine.md#running-the-execution-engine-in-python). |

{% hint style="warning" %}
Running a Workflow on the Roboflow hosted API has two limits to plan around:

* Workflow runtime is capped at 20 seconds.
* The response payload is capped at 6 MB, so Workflows with many visualization blocks, or with large input images, can fail.

Self-hosted and dedicated deployments do not have these limits.
{% endhint %}

If you run your Workflow on your own hardware, you can run it on both images and video files (including streams from regular **webcams** and professional **CCTV cameras**).

By choosing on-premises deployment, you can run Workflows on any system where you can deploy Inference. This includes:

* NVIDIA Jetson
* AWS EC2, GCP Cloud Engine, and Azure Virtual Machines
* Raspberry Pi

{% hint style="info" %}
Roboflow Enterprise customers have access to additional video stream options, such as running inference on Basler cameras. To learn more about our offerings, [contact the Roboflow sales team](https://roboflow.com/sales).
{% endhint %}

### Deploy a Workflow

To deploy a workflow, click the "Deploy" button in the top left corner of the Workflows editor. All deployment options are documented on this page.

The code snippets in your Workflows editor will be pre-filled with your Workflows URL and API key.

Snippets match the runtime your editor is running on. If you switch the editor to a local Inference server or a [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments), the `api_url` in each snippet points at that server, and the matching tab is marked as recommended. Snippets also fill in an example image from your saved Workflow preview when there is one.

{% hint style="info" %}
To learn more about usage limits for Workflows, refer to the [Roboflow pricing page](https://roboflow.com/workflows).
{% endhint %}

#### Process Images

You can run your Workflow on single images using the Roboflow API or local Inference server.

First, install the Roboflow Inference SDK:

```bash
pip install inference-sdk inference-cli
```

If you run locally, follow the [official Docker installation instructions](https://docs.docker.com/get-docker/) to install Docker on your machine and start Inference server:

```
inference server start
```

Then, create a new Python file and add the following code:

```python
from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",  # or "http://127.0.0.1:9001" for local deployment
    api_key="API_KEY"
)

result = client.run_workflow(
    workspace_name="workspace-name",
    workflow_id="workflow-id",
    images={
        "image": "YOUR_IMAGE.jpg"
    }
)

```

Above, replace `API_KEY` with your Roboflow API key. Replace `workspace-name` and `workflow-id` with your Roboflow workspace name and Workflow IDs.

To find these values, open your Roboflow Workflow and click "Deploy Workflow". Then, copy your workspace name and workflow ID from the code snippet that appears on the page.

Local execution works on CPU and NVIDIA CUDA GPU devices. For the best performance, deploy on a GPU-enabled device such as an NVIDIA Jetson or a cloud server with an NVIDIA GPU.

If you prefer to call the endpoint directly, from any language, send an HTTP request:

```bash
curl --location 'https://serverless.roboflow.com/infer/workflows/<your-workspace-name>/<your-workflow-id>' \
    --header 'Content-Type: application/json' \
    --data '{
    "api_key": "<YOUR-API-KEY>",
    "inputs": {
        "image": {"type": "url", "value": "https://your-image-url"},
        "parameter": "some-value"
    }
}'
```

The keys of the `inputs` object are dictated by your Workflow, so the names differ depending on the inputs you defined. Inputs declared as `WorkflowImage` take an object with `type` and `value` keys; over HTTP the supported `type` values are `url` and `base64`.

The examples above run a Workflow that is saved on the Roboflow platform. You can also send a full Workflow definition with the request, which is useful for Workflows built from scratch that do not use API-key gated blocks. See the [Inference SDK](https://docs.roboflow.com/reference/inference/inference-sdk/workflows) for the `specification` argument.

#### Process a video stream

Use the Inference SDK WebRTC client to run a Workflow on a webcam, an RTSP stream, or a video file. The same code works with Serverless and a self-hosted Inference Server.

Install the SDK with its WebRTC dependencies:

```
pip install "inference-sdk[webrtc]"
```

Start a self-hosted Inference Server, or use `https://serverless.roboflow.com` without running a server. Then create a Python file:

```python
from inference_sdk import InferenceHTTPClient
from inference_sdk.webrtc import StreamConfig, WebcamSource

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",  # or "http://localhost:9001"
    api_key="API_KEY",
)

session = client.webrtc.stream(
    source=WebcamSource(),
    workflow="workflow-id",
    workspace="workspace-name",
    config=StreamConfig(data_output=["predictions"]),
)

@session.on_data("predictions")
def handle_predictions(predictions, metadata):
    print(predictions)

session.run()
```

Above, replace `API_KEY` with your Roboflow API key. Replace `workspace-name` and `workflow-id` with your Roboflow workspace name and Workflow IDs.

To find these values, open your Roboflow Workflow and click "Deploy Workflow". Then, copy your workspace name and workflow ID from the code snippet that appears on the page.

Change `WebcamSource()` to another source when the video does not come from a local webcam. See [Video processing with Workflows](/workflows/deploy/video-processing.md) for RTSP streams, video files, and output video.

#### Process Batches of Data

You can efficiently process entire batches of data - directories of images and video files - using the Roboflow Batch Processing service. This fully managed solution requires no coding or local computation. Simply select your data and Workflow, and let Roboflow handle the rest.

We support both UI, CLI and REST API interactions with Batch Processing. Below, we present CLI commands. Discover [all options](https://docs.roboflow.com/deployment/roboflow-cloud/batch-processing#cli).

To run the processing, install Inference CLI:

```
pip install inference-cli
```

Then you can ingest your data:

```
inference rf-cloud data-staging create-batch-of-images \
    --images-dir <your-images-dir-path> \
    --batch-id <your-batch-id>
```

When data are loaded, start the processing job:

```
inference rf-cloud batch-processing process-images-with-workflow \
    --workflow-id <workflow-id> \
    --batch-id <batch-id>
```

Progress of the job can be displayed using:

```
inference rf-cloud batch-processing show-job-details \
    --job-id <your-job-id>  # job-id will be displayed when you create a job
```

And when the job is done, export the results:

```
inference rf-cloud data-staging export-batch \
    --target-dir <dir-to-export-result> \
    --batch-id <output-batch-of-a-job>
```

#### Process a Local Directory with the CLI

For data that already sits on the machine you are running from, `inference-cli` can run a Workflow over individual images, a directory of images, or a video file without any code:

```bash
pip install inference-cli
```

```bash
inference workflows process-images-directory \
    -i {your_input_directory} \
    -o {your_output_directory} \
    --workspace_name {your-roboflow-workspace-url} \
    --workflow_id {your-workflow-id} \
    --api-key {your_roboflow_api_key}
```

In the output directory you will find one sub-directory per input file, each containing a `results.json` file with that file's Workflow results plus any images produced during execution, and an `aggregated_results.csv` file with the results for every input concatenated together.

See the [Inference CLI reference](https://docs.roboflow.com/reference/inference/inference-cli/workflows) for all options.

## Next steps

* Run the Execution Engine directly inside your own Python application: see the [Developer Guide](/workflows/developer-guide/developer-guide.md).
* Understand the shape of the results a Workflow returns: see [Workflow execution](/workflows/developer-guide/developer-guide/workflow-execution.md#output-construction).
