Using Hub API keys in OAK Apps and scripts
Hub API keys have full team admin access
Treat Hub API keys as high-sensitivity secrets. They currently have full admin access to your team's resources. See more.
- devices not adopted to Luxonis Hub that need to download private models from Models Registry
- local scripts
oakapp.toml, Python source files, JSON, YAML, or shell scripts. Instead, use runtime-only injection patterns such as environment variables, .env files, or oakctl login flows.General Recommendations
- Never commit API keys directly into repositories (e.g.,
.toml,.json,.yaml, or.pyfiles under git). - Prefer using environment variables or
.envfiles (excluded from git via.gitignore). - Do not add team API keys to adopted-device or Hub-managed OAK App workflows unless you have a specific non-Hub requirement.
- Prefer
oakctl-managed authentication or local runtime injection when you do need a key. - Keep
.envfiles local only, and avoid sharing them.
Modes & Secure Setup Options
Standalone Mode
When you do not need to pass a key manually
Local and device-side setup
Option 1 - Device adopted
Command Line
1oakctl app run .Option 2 - Override the Key
DEPTHAI_HUB_API_KEY.In that case, load the value from a local .env file:Python
1import os
2from dotenv import load_dotenv
3
4load_dotenv(override=True)
5
6print(os.environ["DEPTHAI_HUB_API_KEY"]).env file next to main.py:Command Line
1cd <INSERT_PATH_TO_PROJECT>
2echo "DEPTHAI_HUB_API_KEY=<INSERT_YOUR_DEPTHAI_HUB_API_KEY>" > .env
3echo ".env" >> .gitignoreCommand Line
1oakctl app run .oakctl copies the .env file into the app environment on the device. Your app still needs its own logic to read that value at runtime, for example with dotenv.load_dotenv().