---
question: How do I declare the services, modules and packages a module uses?
kind: guide
---

# Add dependencies

A module declares the engine services it calls and the other modules it talks to. Anything it did not declare is refused. Python packages are a separate matter: they go in the module's image.

## Services and modules

In the module class:

```python title="src/research/__init__.py"
from naas_abi_sdk import BaseModule, ModuleDependencies


class ABIModule(BaseModule):
    dependencies = ModuleDependencies(
        # The scaffold's three, plus object_storage. triple_store sends ontologies/:
        # a module with .ttl files there does not start without it.
        services=("model_registry", "document", "triple_store", "object_storage"),
        modules=("my_project.other",),
    )
```

- **`services`** names the kernel services the module calls: `activity_log`, `bus`, `cache`, `coding_environment`, `dataset`, `document`, `email`, `event` (or `events`), `keyvalue` (or `kv`), `model_registry`, `object_storage`, `secret`, `source_control`, `triple_store`, `vector_store`. An unknown name fails at start. Inside the module, `self.engine.services.<name>` is that service, called over NATS with `await`; one you did not declare raises `ValueError: Module did not declare service dependency`. The model registry is a service like the others: an agent on the engine's models needs `model_registry`. A module with `.ttl` files under `ontologies/` needs `triple_store`, or it stops at start (`... has ontologies ... but does not declare the triple_store service`). The scaffold declares `model_registry`, `document` and `triple_store`: keep them, and add yours.
- **`modules`** names other modules by their module id. At start, the module waits until each of them is ready in discovery, and fails with `DEPENDENCY_TIMEOUT` when one never is. Then `self.engine.modules["my_project.other"]` reaches it: its agents (`await other.get_agent("Other")`), its models and its workflows. A module you did not declare raises.

`self.engine.services.<name>_available()` tells whether the module declared a service, for code shared between modules.

## Python packages

A module's image installs the SDK only. A package your code imports goes in the module's `Dockerfile`, on its `pip install` line:

```dockerfile title="src/research/Dockerfile"
RUN pip install /build/naas-abi-proto "/build/naas-abi-sdk[agent,otel,workflows,rdf]" requests \
    && rm -rf /build
```

`abi dev up` runs the module with the Python that runs `abi`, with the project's `src/` on its path. When that is the project's environment (`uv run abi dev up`), add the package to the project too:

```bash
uv add requests
```

A module in its own repository (`abi new module <name> --standalone`) lists its packages in its own `pyproject.toml`, under `dependencies`.

Never add `naas-abi-core`, `naas-abi` or `naas-abi-marketplace`: the module's Docker build fails when `naas_abi_core` is installed. See [Creating a Module](/capabilities/build/modules/creating-a-module#the-module-class).
