# Secrets

> Store API keys and passwords once, and give them to the functions that need them as environment variables.

Canonical page: https://klio.tech/docs/secrets

## Create a secret

```bash
klio secret create HF_TOKEN hf_your_token
klio secret list
```

`NAME VALUE` stores one value. `KEY=VALUE` pairs make a group, as Modal does, and `--from-dotenv .env` reads them from a file; `--force` replaces a group that exists. `klio secret delete` removes one.

## Use it in a function

```python
import os
from klio_compute import function

@function(secrets=["HF_TOKEN"])
def download():
    token = os.environ["HF_TOKEN"]
    ...
```

Each secret named in `secrets=` is set as an environment variable in the container. With the Modal-compatible API, `modal.Secret.from_name("group")` gives a function every key of a group.
