---
question: How do I start the ABI process API?
kind: guide
---

# REST API

The ABI API is a FastAPI application and the primary programmatic interface to the ABI stack. The Nexus API is mounted on the same process, under `/api`: it reaches the agents, workflows and pipelines your modules publish. The engine's own routes (`/agents`, `/workflows`, `/pipelines`, `/tools`) serve the marketplace modules enabled under `modules:` in `config.yaml`.

---

## Starting the API

```bash
# Natively: Oxigraph, NATS, the API and Nexus web
abi dev up

# With Docker Compose
abi stack start
```

The API listens on port **9879** by default. `abi dev up` offsets the ports per checkout so several projects can run side by side: `abi dev ports` prints the live ones. In the ABI repository, `make api` runs the API alone (`uv run python -m naas_abi_core.apps.api.api`); it needs a broker.

The first boot takes a few minutes: the engine loads its marketplace modules and ontologies. The API is ready when `/docs` answers. For a production deployment, see [Deploy](/capabilities/deploy/overview).

---

## API documentation

When the server is running:

- `http://localhost:9879/docs` - Swagger UI (interactive)
- `http://localhost:9879/redoc` - Redoc (readable)
- `http://localhost:9879/openapi.json` - OpenAPI spec

(Use the `api` port printed by `abi dev ports` with `abi dev up`.)

---

## Authentication

The routes the engine registers (`/agents`, `/workflows`, `/pipelines`, `/tools`) require the project's API key as a Bearer token. It is `ABI_API_KEY` in the project's `.env`:

```bash
curl -X POST "http://localhost:9879/agents/Abi/completion" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "What organizations are in my knowledge graph?", "thread_id": 1}'
```

There is no token endpoint for these routes. The key can also be sent as `?token=<key>`.

The Nexus routes under `/api` use the Nexus sign-in instead: `POST /api/auth/login` returns an access token and a refresh token, `POST /api/auth/refresh` renews it. See [Nexus](/capabilities/build/applications/nexus#authentication).

---

## Endpoints

### Agents of your modules

A module's agents are published in discovery. Call them through the chat API, which selects an agent by its **id**:

```http
POST /api/chat/stream
POST /api/chat/complete
```

Auth: a Nexus session. Nexus chat uses the same routes: see [Chat with an agent](/capabilities/build/agents/chat-with-an-agent).

### Workflows and pipelines of your modules

Every durable workflow a module declares (`@workflow` methods, and its `Workflow` and `Pipeline` classes as `workflow.<slug>` and `pipeline.<slug>`) is reachable under `/api/workflows`:

```http
GET  /api/workflows
POST /api/workflows/{module_id}/{name}/runs
GET  /api/workflows/{module_id}/runs/{run_id}
POST /api/workflows/{module_id}/runs/{run_id}/cancel
```

The start body is the workflow's input, a JSON object. `?wait=<seconds>` (up to 120) waits for the result, and an `Idempotency-Key` header makes a repeated start the same run. Auth: `Authorization: Bearer` with `ABI_API_KEY`, or a platform super admin's session. See [Expose as an API](/capabilities/build/workflows/expose-as-an-api).

```bash
curl -s -H "Authorization: Bearer $ABI_API_KEY" -H "Content-Type: application/json" \
  -d '{"topic": "news"}' \
  "http://localhost:9879/api/workflows/my_project.research/digest/runs?wait=30"
```

### Agents of marketplace modules

The engine gives every agent of the marketplace modules it loads (`naas_abi` and the others enabled under `modules:`) a route of its own:

```http
POST /agents/{agent_name}/completion
POST /agents/{agent_name}/stream-completion
```

`{agent_name}` is the agent's `name`, with characters other than letters, digits, `_` and `-` replaced by `_`. Request body:

```json
{
  "prompt": "Your question or instruction",
  "thread_id": 1
}
```

`stream-completion` answers with server-sent events. The workflows, pipelines and tools of those modules get `POST /workflows/{name}`, `POST /pipelines/{name}` and `POST /tools/{name}`. Your own modules' agents and workflows have no route here: use the chat API and `/api/workflows` above.

### The Nexus API

The Nexus API is served under `/api`: authentication (`/api/auth/...`), organizations and workspaces (`/api/organizations`, `/api/workspaces`), chat (`/api/chat/...`), the knowledge graph (`/api/graph/...`, `/api/ontology/...`, `/api/search`), modules and apps (`/api/modules`, `/api/apps`), files, and the admin and System endpoints. Its OpenAPI document is part of `/openapi.json`; browse it in Swagger UI.

---

## CORS

CORS origins are configured in `config.yaml` under `api.cors_origins`. This is the single source of truth - both the core API and the embedded Nexus API share the same origin list. See [ADR: CORS](/capabilities/release-notes/cors-single-source-of-truth).

---

## Tenant configuration

The `/api/tenant` endpoint returns the branding configuration of the deployment (tab title, logo, colors). It is consumed by the Nexus frontend and set in the `tenant:` block of the `naas_abi` module's `nexus_config` in `config.yaml`. See [Nexus](/capabilities/build/applications/nexus#tenant-branding) and [ADR: Tenant Provisioning](/capabilities/release-notes/config-driven-tenant-provisioning).
