How do I install the command?
pip install nalvera installs the nalvera command. It needs Python 3.10 or later.
pip install nalveraHow do I sign in?
Create a key on the website under Settings → API of the account that pays for the AI tasks.
- Sign in at nalvera.ai. Create and verify your account there if you have none.
- Open the menu (⋮) at the bottom left, then Settings → API.
- Switch API access on.
- Create a key that may run tasks.
The key is shown once. Tick only the permissions it needs: see tasks (always on), download results, and run tasks and spend credits.
nalvera login asks for the email and the key (hidden), checks them and stores them on this computer. On a cluster, fill NALVERA_EMAIL and NALVERA_API_KEY in the environment from a secret store instead.
nalvera loginHow do I run a scan?
nalvera models lists the models and tasks you may run, nalvera estimate prices the run without uploading anything, and nalvera run anonymizes the scan on your computer, uploads it, queues the AI task, waits and saves the result under the scan's original name.
nalvera models
nalvera estimate ct_scan.nii.gz --model totalsegmentator_ct
nalvera run ct_scan.nii.gz --model totalsegmentator_ct --budget personal --out resultsCommands
nalvera --help and nalvera COMMAND --help show the same list in the terminal, and nalvera --help also lists the settings read from the environment.
| Command | Option | What it does |
|---|---|---|
nalvera --help | Show this help and exit. | |
nalvera --version | Show the version and exit. | |
nalvera login | Check your email and API key and store them on this computer. | |
--email EMAIL | Email address of your Nalvera.AI account. Asked for when left out. Default: none. | |
nalvera logout | Remove the stored email and key from this computer. | |
nalvera whoami | Show your account, plan, key permissions, end date, free tasks and budgets. | |
nalvera limits | Show the limits that apply to your key. | |
nalvera models | List the models you can run, with their tasks and prices. | |
--model ID | Show only this model, with the settings a generation accepts. Default: none. | |
nalvera anonymize PATH... --out DIR | Write the anonymized copies of scans, as a run prepares them, into a folder. The folder holds the copies only. Nothing is sent and no key is needed. | |
PATH | NIfTI file (.nii or .nii.gz), folder of NIfTI files, or folder of DICOM files. Several paths may be given. Required. | |
--out DIR | Folder for the copies. Created when missing; no file in it is replaced. Required. | |
nalvera estimate PATH... --model M | Show what a run would cost, per scan and in total, with free tasks and budgets. Scans are anonymized in a temporary folder; nothing is uploaded. | |
PATH | NIfTI file (.nii or .nii.gz), folder of NIfTI files, or folder of DICOM files. Several paths may be given. Required. | |
--model M | Model to price, for example totalsegmentator_ct. See nalvera models. Required. | |
--task T | Task of the model. Without it the model's default task is priced. Default: none. | |
--force | Price scans that are already queued, running or done with this model and task too. Default: off. | |
nalvera run PATH... --model M | Anonymize scans on this computer, upload them, queue one task for each, wait and save the results. | |
PATH | NIfTI file (.nii or .nii.gz), folder of NIfTI files, or folder of DICOM files. Several paths may be given. Required. | |
--model M | Model to run, for example totalsegmentator_ct. See nalvera models. Required. | |
--task T | Task of the model. Without it the model's default task runs. Default: none. | |
--label L | Label that Nalvera.AI shows for the scans in place of the scan code. 1 to 60 letters, digits, spaces, dots, dashes or underscores. Default: none. | |
--text TEXT | Free-text query for tasks that need one. Default: none. | |
--budget BUDGET | Budget that pays beyond the free tasks: personal, lab:ID, free (free tasks only, nothing charged) or ask. Default: NALVERA_BUDGET, else free tasks first, then personal without a lab, or a question with a lab. | |
--max-credits N | Spending cap in credits: a run that would cost more does not start, and queueing stops before a task passes it. Default: NALVERA_MAX_CREDITS, else no cap. | |
--yes | Use the suggested budget without asking, and go ahead when a DICOM folder holds several scans. Default: off. | |
--encrypt | Encrypt each upload on this computer (NVLT, on top of HTTPS). Default: NALVERA_ENCRYPT, else only when your account requires it. | |
--no-encrypt | Do not add the NVLT layer. Refused when your account requires encrypted uploads. | |
--force | Do not leave out scans that are already queued, running or done with this model and task. Default: off. | |
--no-wait | Queue the tasks and return at once. Follow them later with nalvera status or nalvera wait. Default: off. | |
--ids | Write only the queued task ids to standard output, one per line, for a script; every other line goes to standard error. Default: off. | |
--out DIR | Folder for the result files. Default: results. | |
nalvera generate --model M --task T | Create a synthetic scan with a generative model, wait and save the result. No input scan is needed. | |
--model M | Generative model, for example nv_generate_ctmr. See nalvera models. Required. | |
--task T | Task of the model, for example rflow-ct or rflow-mr-brain. Required. | |
--param NAME=VALUE | One setting as name=value, for example mode=image-only. Repeat the option for each setting. Lists need quotes: "spacing=[1.5,1.5,2.0]". Settings per task: nalvera models --model ID. Default: none. | |
--label L | Label that Nalvera.AI shows for the task. The result file name starts with it. 1 to 60 letters, digits, spaces, dots, dashes or underscores. Default: none. | |
--estimate | Show what the generation would cost from each budget, and whether a free task pays for it. Nothing is queued; no budget is needed. Default: off. | |
--force | Queue it although a task with the same label, model, task and settings exists. Default: off. | |
--budget BUDGET | Budget that pays beyond the free tasks: personal, lab:ID, free (free tasks only, nothing charged) or ask. Default: NALVERA_BUDGET, else a free task first, then personal without a lab, or a question with a lab. | |
--max-credits N | Spending cap in credits: a generation that would cost more is not queued. Default: NALVERA_MAX_CREDITS, else no cap. | |
--yes | Use the suggested budget without asking. Default: off. | |
--no-wait | Queue the generation and return at once. Follow it later with nalvera status or nalvera wait. Default: off. | |
--ids | Write only the queued task id to standard output, for a script; every other line goes to standard error. Default: off. | |
--out DIR | Folder for the result files. Default: results. | |
nalvera status TASK_ID... | Show the state of tasks: queue position, time waited and time running. | |
TASK_ID | Task IDs to show. Without IDs, all tasks waiting or running. | |
--watch | Keep updating until the tasks finish. Default: off. | |
--all | List finished tasks too (completed, failed, cancelled), newest first, with their task IDs. Default: off. | |
--limit N | With --all: how many tasks to list, 1 to 100. Default: 50. | |
nalvera wait TASK_ID... | Wait until tasks finish, showing queue position, time waited and time running. | |
TASK_ID | Task IDs to wait for. Without IDs, all tasks waiting or running. | |
nalvera download TASK_ID... | Download the results of finished tasks. | |
TASK_ID | Task IDs to download. Without IDs, each completed task in this computer's record (nalvera scans) whose result is not saved yet. | |
--out DIR | Folder for the result files. Default: results. | |
--part PART | One file of a result that has several files, such as image or mask. Default: none. | |
nalvera cancel TASK_ID... | Cancel waiting or running tasks. | |
TASK_ID | Task IDs to cancel. Required. | |
nalvera scans | Show the scans recorded on this computer: code, original name, label, tasks and result files. | |
nalvera mcp | Run the MCP server for an AI assistant on this computer. The assistant's app starts it and speaks with it on standard input and output. |
Exit statuses
| Exit status | Meaning |
|---|---|
0 | all done |
1 | some scans failed or were rejected, or a task did not complete |
2 | wrong usage: an option, a path or a setting is not valid |
3 | sign-in or permission: no key, a key refused, expired or revoked, a permission the key lacks, API access off, an upload that cannot be encrypted as required, or a package too old |
4 | credits or budget: too few credits, no free task left, a budget choice or a confirmation needed, or the spending cap reached |
5 | limits or the platform unavailable after retries, or no connection |
130 | interrupted (Ctrl-C) |
Examples
set_api_key.sh
Sign in with nalvera login, check the sign-in with nalvera whoami, and remove the stored key with nalvera logout.
#!/usr/bin/env bash
# Give the nalvera command your API key, then check the sign-in. Spends nothing.
# Get a key: sign in at https://nalvera.ai, menu (⋮) → Settings → API, switch on API access and
# create a key; tick "Run tasks and spend credits" to run tasks. The key is shown once.
# Run: bash set_api_key.sh
set -euo pipefail
# 1. Once per computer: asks for the email and the key (hidden input), checks them and stores
# them (the system keychain with "nalvera[keyring]" installed, else a file only you can read).
# --email default: none (asked for)
nalvera login
# 2. On a cluster or in CI, fill the environment from a secret store instead (never write the
# key into this file). The environment comes before what nalvera login stored.
# export NALVERA_EMAIL="you@university.org"
# export NALVERA_API_KEY="$(your-secret-store read nalvera-api-key)"
# Check the sign-in: account, key prefix, permissions, end date.
nalvera whoami
# Remove the stored key from this computer:
# nalvera logoutcli_walkthrough.sh
Every command once, in the order a new user needs them.
#!/usr/bin/env bash
# Every nalvera command once, in the order a new user needs them. Spends credits: two scan
# tasks, and one generation that is cancelled at once (budget personal). Needs ct_scan.nii.gz
# and ct_scan_2.nii.gz here. Run: bash cli_walkthrough.sh
set -euo pipefail
nalvera --version
nalvera --help # every command, setting and exit status
# Sign in once per computer: asks for the email and the key (hidden input), checks and
# stores them.
# --email default: none (asked for)
nalvera login
nalvera whoami # account, key, permissions, end date, free tasks, budgets
nalvera limits # the numbers of your key's limits
nalvera models # every model and task you may run, with prices
# --model default: none (every model)
nalvera models --model totalsegmentator_ct
# What would leave this computer: the anonymized copy, in anonymized/.
# Nothing is sent and no key is needed.
# --out default: none (required)
nalvera anonymize ct_scan.nii.gz --out anonymized
# What a run would cost. The scan is anonymized in a temporary folder; nothing is uploaded.
# --task default: none (the model's default task)
nalvera estimate ct_scan.nii.gz --model totalsegmentator_ct --task total
# Anonymize, upload, queue, wait, and save the result in results/.
# --budget default: none (NALVERA_BUDGET, else free tasks first, then personal or a question)
# Options: personal | lab:<id> | free | ask
# --out default: results
nalvera run ct_scan.nii.gz --model totalsegmentator_ct --task total --budget personal --out results
# Queue and return at once; keep the task id to follow and collect it later, from any process.
# --no-wait default: off
# --ids default: off (only the queued task ids on standard output, one per line)
task_id=$(nalvera run ct_scan_2.nii.gz --model totalsegmentator_ct --budget personal --no-wait --ids)
nalvera status # waiting and running tasks: position, time waited, time running
nalvera wait "$task_id" # until it finishes
# --all default: off (waiting and running tasks only)
# --limit default: 50
nalvera status --all --limit 10 # finished tasks too, newest first, with their ids
nalvera scans # this computer's record: code, original name, tasks, results
# Without a task id: each result of this computer's record that was not saved yet.
nalvera download --out results
# A generation needs no scan. Every setting: nalvera models --model nv_generate_ctmr
# What it would cost from each budget; nothing is queued.
# --estimate default: off
nalvera generate --model nv_generate_ctmr --task rflow-ct --param mode=image-only \
--param "output_size=[256,256,128]" --param "spacing=[1.5,1.5,2.0]" --estimate
# --param default: none (each setting as name=value; lists in quotes)
generation_id=$(nalvera generate --model nv_generate_ctmr --task rflow-ct --param mode=image-only \
--param "output_size=[256,256,128]" --param "spacing=[1.5,1.5,2.0]" --budget personal \
--no-wait --ids)
nalvera cancel "$generation_id" # a running task stops at the worker's next check
# Remove the stored key from this computer.
nalvera logoutanonymize_only.sh
Write the anonymized copies of files and folders into one folder; nothing is sent.
#!/usr/bin/env bash
# Write the anonymized copies of scans, as a run prepares them, into one folder.
# Look at what would leave this computer: nothing is sent and no key is needed. Needs
# ct_scan.nii.gz and a folder scans/ here. Run: bash anonymize_only.sh
set -euo pipefail
# Each copy is named by a new code; no file in anonymized/ is replaced.
# --out default: none (required)
nalvera anonymize ct_scan.nii.gz scans --out anonymized
ls -l anonymized # scan-XXXXXXXX.nii.gz copies, and nothing elseslurm_job.sh
Run TotalSegmentator on a folder of scans from a Slurm cluster node.
#!/usr/bin/env bash
#SBATCH --time=04:00:00
#SBATCH --cpus-per-task=2
#SBATCH --mem=8G
# Run TotalSegmentator on a folder of scans from a Slurm cluster node with internet access.
# Sign in once on the cluster first: nalvera login stores the key readable by you only.
# A site secret store may export NALVERA_EMAIL and NALVERA_API_KEY instead; this script holds
# no key and writes none. Queues no task that would pass 50 credits (budget personal). Submit: sbatch slurm_job.sh
set -euo pipefail
# NALVERA_BUDGET default: unset (free tasks first, then personal, or a question with a lab)
# Options: personal | lab:<id> | free | ask
export NALVERA_BUDGET=personal
# NALVERA_MAPPING default: unset (one file per account in the configuration folder)
export NALVERA_MAPPING="$HOME/nalvera/nalvera_scans.csv"
# --max-credits default: none (NALVERA_MAX_CREDITS, else no cap)
# --out default: results
nalvera run "$HOME/scans" --model totalsegmentator_ct --max-credits 50 --out "$HOME/results"
# Exit status: 0 done, 1 scans failed, 3 sign-in, 4 credits or budget, 5 limits or network.github_actions_workflow.yml
Run TotalSegmentator in a GitHub Actions workflow on a runner inside your network, with the key in a repository secret.
# Run TotalSegmentator from GitHub Actions on a runner inside your network, where the scans
# are. The key is a repository secret (Settings → Secrets and variables → Actions); this file
# holds none. Queues no task that would pass 25 credits (budget personal). Copy to .github/workflows/.
name: nalvera
on:
workflow_dispatch:
jobs:
segment:
runs-on: self-hosted
steps:
- name: Install a pinned version of the nalvera package
run: python3 -m pip install "nalvera==0.1.1"
- name: Run the scans
env:
NALVERA_EMAIL: ${{ secrets.NALVERA_EMAIL }}
NALVERA_API_KEY: ${{ secrets.NALVERA_API_KEY }}
# NALVERA_BUDGET default: unset (free tasks first, then personal, or a question
# with a lab). Options: personal | lab:<id> | free | ask
NALVERA_BUDGET: personal
# --max-credits default: none (NALVERA_MAX_CREDITS, else no cap)
# --out default: results
run: nalvera run /data/scans --model totalsegmentator_ct --max-credits 25 --out /data/resultshttp_read_only.sh
Read your account, models and tasks over HTTP with curl; nothing is spent.
#!/usr/bin/env bash
# Read your account, models and tasks over HTTP with curl: read-only, spends nothing.
# Uploads go through the nalvera package, which anonymizes scans before they leave the computer.
# Needs NALVERA_EMAIL and NALVERA_API_KEY in the environment. Run: bash http_read_only.sh
set -euo pipefail
BASE="${NALVERA_BASE_URL:-https://nalvera.ai}"
# The key travels over HTTPS only (http:// only to this computer).
case "$BASE" in
https://* | http://localhost | http://localhost:* | http://127.0.0.1 | http://127.0.0.1:*) ;;
*) echo "NALVERA_BASE_URL must start with https://" >&2; exit 2 ;;
esac
# The key reaches curl on standard input, so it never shows in the list of processes.
get() {
printf 'Authorization: Bearer %s\n' "$NALVERA_API_KEY" |
curl --silent --show-error --fail-with-body -H @- \
-H "X-Nalvera-Email: $NALVERA_EMAIL" "$BASE$1"
echo
}
get /api/v1/me # account, key, limits
get /api/v1/models # the models and tasks you may run
get "/api/v1/tasks?state=active&limit=50" # state: active | finished | all; limit: 1 to 100Research use only. Nalvera.AI is not a medical device.