Secrets and API keys
Four ways to give a provider its API key without putting the key in git. Server environment, CI push, Vault, or set by hand.
The settings file never contains a key. It contains a secret reference: a small object that tells Lunnoa where to find the value. The same shape is used wherever the file takes a secret, and each provider chooses its own source.
"apiKey": { "source": "serverEnv", "name": "OPENAI_API_KEY" }Choose a source
| Source | Where the value lives | When Lunnoa reads it | Best for |
|---|---|---|---|
serverEnv | An environment variable on the Lunnoa server | At use time. Never stored in the Lunnoa database | Kubernetes secrets, Docker secrets, variables injected by your platform |
env | A secret in your CI environment (GitHub or GitLab) | Pushed by the pipeline on deploy, then stored encrypted | Teams that keep keys in CI and do not want to touch the server |
vault | HashiCorp Vault (KV v2) | At use time, cached in memory for a few minutes | Regulated installs, rotation, central audit of secret access |
manual | Admin Space or the API | Set by a person | A quick start, a one-off key, or a key your pipeline must never see |
If you are unsure, start with serverEnv. It needs no extra setup and the key never touches git or CI.
serverEnv
{
"name": "Company OpenAI",
"provider": "openai",
"apiKey": { "source": "serverEnv", "name": "OPENAI_API_KEY" },
"models": ["gpt-6-luna"]
}| Key | Rules |
|---|---|
name | The name of an environment variable on the server. Uppercase letters, digits, and underscores, starting with a letter, up to 128 characters |
The variable must be set on the server when the file is applied, or the pull fails. Lunnoa reads the value from the server environment each time it needs it and does not store it. To rotate the key, change the variable and restart the server.
Each environment needs its own value. A provider that works in development fails the staging promotion if staging does not have the variable yet.
env
{
"name": "Company OpenAI",
"provider": "openai",
"apiKey": { "source": "env", "name": "OPENAI_API_KEY" },
"models": ["gpt-6-luna"]
}| Key | Rules |
|---|---|
name | The name the pipeline pushes the secret under. Same character rules as serverEnv |
With env, your pipeline sends the value to Lunnoa. The deploy workflow reads a secret called OPENAI_API_KEY from the GitHub environment and posts it to the secrets endpoint before it asks the install to reload. Lunnoa stores it encrypted.
curl --fail-with-body -X POST \
-H "Authorization: Bearer your_machine_user_token_here" \
-H "Content-Type: application/json" \
-d '{"secrets": {"OPENAI_API_KEY": "sk-..."}}' \
https://your-deployment.example/api/admin/installation-settings/secretsUse a machine user token. A workspace API key (lna_...) is not accepted. The response lists the names that were stored and never repeats a value.
If a reference uses env and no value was pushed for that name, the reload fails. To rotate the key, change the CI secret and run the deploy again.
vault
{
"name": "Company OpenAI",
"provider": "openai",
"apiKey": { "source": "vault", "path": "lunnoa/prod/openai", "key": "api_key" },
"models": ["gpt-6-luna"]
}| Key | Required | Rules |
|---|---|---|
path | Yes | The secret path inside the KV v2 mount, for example lunnoa/prod/openai. No leading slash and no ... Up to 255 characters |
key | Yes | The field inside that secret. Up to 128 characters |
mount | No | The KV v2 mount. Defaults to LUNNOA_VAULT_MOUNT |
How Lunnoa connects to Vault
The Vault connection is configured once on the server, with environment variables. See Environment variables. The settings file only holds the path.
| Auth method | Use it when |
|---|---|
| Kubernetes | Lunnoa runs in a cluster. The pod's service account logs in to Vault |
| AppRole | Lunnoa runs anywhere else and you can place a role id and secret id on the server |
| Cloud IAM (AWS, GCP, Azure) | Lunnoa runs on a cloud VM or service with an attached identity |
| JWT/OIDC | You already issue workload identity tokens |
Give the Lunnoa role a read-only policy on the paths it needs and nothing else.
How the value is used
- Lunnoa reads the secret when a model call needs it and keeps it in memory only for a short time (five minutes by default). It never writes the value to the database.
- If the provider answers
401or403, Lunnoa fetches the secret again once and retries. A key you rotated in Vault is picked up without a restart. - If Vault cannot be reached and there is no cached value, the call fails. Lunnoa does not fall back to another source.
manual
{
"name": "Company OpenAI",
"provider": "openai",
"apiKey": { "source": "manual" },
"models": ["gpt-6-luna"]
}manual has no other keys. The file creates the provider, and a person adds the key in Admin Space → AI configuration or through the API. Until then the provider shows Secret missing and cannot be used.
A pull never overwrites or clears a manual key. The secret field stays editable in Admin Space even though the rest of a file-owned provider is read-only.
Rules for every source
apiKeymust be a secret reference object. A plain string such as"apiKey": "sk-..."is rejected and the whole pull fails.- Leave
apiKeyout for providers that need no key, such asollama. - Secret values never appear in the file, in logs, in the reload response, or in Admin Space. Admin Space only shows whether a secret is set or missing.
- Different providers in one file can use different sources.
- A secret reference points to a value. It does not copy it, so changing the source of a provider changes where the next call reads from.