---
question: How do I run a pipeline from Python or HTTP?
kind: task
via_web: na
via_cli: available
via_python: available
via_api: available
via_config: na
ref_cli: abi run script
ref_python: Pipeline.run
ref_api: POST /pipelines/{name}
prereq: You need a pipeline whose `run` is filled in, in an in-engine module listed under `modules:`. See [Create a pipeline](/user-guide/build/knowledge-graph/creating-a-pipeline).
next:
  - /capabilities/build/pipelines/schedule-a-pipeline
  - /capabilities/build/pipelines/monitor-runs
---

# Run a pipeline

Running a pipeline calls its `run(parameters)`. It returns an `rdflib.Graph`, and the usual class also inserts that graph into the triple store before returning. Every tab below ends in the same call; they differ in where it runs.

## Web UI

Not applicable. Nexus has no screen that lists or runs pipelines. When a [module job](/user-guide/build/pipelines/schedule-a-pipeline) calls the pipeline, **Run now** in the System app's Jobs tab runs that job: see [Monitor runs](/user-guide/build/pipelines/monitor-runs).

## CLI

### Write a script

```python title="scripts/run_items.py"
from my_module.pipelines.ItemsPipeline import (
    ItemsPipeline,
    ItemsPipelineConfiguration,
    ItemsPipelineParameters,
)

graph = ItemsPipeline(ItemsPipelineConfiguration()).run(ItemsPipelineParameters())
print(f"{len(graph)} triples")
```

### Run it with the engine

```bash
abi run script scripts/run_items.py
```

`abi run script` loads the engine (configuration, services, modules), then runs the file. Arguments after the path reach the script as `sys.argv`. In a NATS project the broker has to be up (`abi dev up` or `abi stack start`). The command is [`abi run script`](/user-guide/reference/cli#abi-run-script).

## Python

### Call run

```python
from my_module.pipelines.ItemsPipeline import (
    ItemsPipeline,
    ItemsPipelineConfiguration,
    ItemsPipelineParameters,
)

pipeline = ItemsPipeline(ItemsPipelineConfiguration())
graph = pipeline.run(ItemsPipelineParameters(filter="open"))
```

The pipeline reads its services from the module, so call it where the engine is loaded: an agent tool, a workflow, a [module job](/user-guide/build/pipelines/schedule-a-pipeline), or a script run with `abi run script`. Outside the engine, `ABIModule.get_instance()` raises "Module … not initialized".

### Give it to an agent

`as_tools()` returns the pipeline as LangChain tools. An agent adds them in its `New()`; see [Give it tools](/user-guide/build/agents/give-it-tools).

## REST API

### Find the route

The engine mounts one route per loaded pipeline whose `run` takes a Pydantic parameters model: `POST /pipelines/<class name in snake case>`, so `ItemsPipeline` is `/pipelines/items_pipeline`. The API's `/docs` page lists them under **Pipelines**. There is no route that lists pipelines.

### Call it

```bash
curl -s -X POST "http://localhost:9879/pipelines/items_pipeline" \
  -H "Authorization: Bearer $ABI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filter": "open"}'
```

The body is the parameters model as JSON (`{}` when it has no fields). The token is the engine's `ABI_API_KEY`, not a Nexus login: see [Authentication](/api/authentication). The response is the graph as Turtle:

```json
{"format": "turtle", "data": "@prefix ..."}
```

## Config

Not applicable. `config.yaml` has no key that runs a pipeline. To run one on a schedule, declare a module job: see [Schedule a pipeline](/user-guide/build/pipelines/schedule-a-pipeline).
