vaultriever
Retrieve secrets in an ARN-like way from different vaults seamlessly, compatible with pydantic-settings — no custom field types, just str fields plus a reusable mixin.
It's particularly useful for projects that need to support multiple vaults, or for libraries that want to avoid forcing a specific vault on their users.
Secret Resource Identifier (SRI)
Secrets are addressed with a 4-part string:
provider:qualifier:secret_name:secret_key
| Provider | Example | Notes |
|---|---|---|
| AWS Secrets Manager | aws:us-east-1:my-secret:OPENAI_API_KEY |
JSON-object secrets: secret_key selects a key. Plaintext secrets: omit secret_key (aws:us-east-1:my-secret:) to get the whole value. |
| Databricks | databricks::my-secret-scope:OPENAI_API_KEY |
Empty qualifier → default workspace/profile; non-empty qualifier → CLI profile name. |
| Azure Key Vault | azure:my-vault:my-secret:latest |
Single-value secret; secret_key is the version (latest or a version id). |
| GCP Secret Manager | gcp:my-project:my-secret:latest |
Single-value secret; secret_key is the version (latest or a version number). |
Installation
pip install vaultriever[aws] # AWS Secrets Manager
pip install vaultriever[databricks] # Databricks (not needed on a Databricks runtime)
pip install vaultriever[azure] # Azure Key Vault
pip install vaultriever[gcp] # GCP Secret Manager
Usage
With pydantic-settings
from pydantic import Field, SecretStr
from pydantic_settings import BaseSettings
from vaultriever import SecretSRIMixin
class OpenAISettings(SecretSRIMixin, BaseSettings):
openai_api_key: str | SecretStr = Field(
default='aws:us-east-1:my-secret:OPENAI_API_KEY',
description='OpenAI API key; SRI or literal.',
)
settings = OpenAISettings()
settings.openai_api_key # SecretStr('**********') — masked
settings.openai_api_key.get_secret_value() # the resolved secret
Behavior:
str/SecretStrvalues that look like an SRI (and reference a registered provider) are resolved and wrapped inSecretStr, so they stay masked inrepr()and logs.- Everything else passes through unchanged — literals, URLs, non-string values.
- Validated values are also exported to
os.environunder the field name for downstream usage by default. This writes resolved secrets in plaintext to the process environment; see the opt out instructions and disable it per model:
from typing import ClassVar
class MySettings(SecretSRIMixin, BaseSettings):
enable_env_export: ClassVar[bool] = False
api_key: str | SecretStr
Standalone
from vaultriever import is_sri, resolve_secret
is_sri('aws:us-east-1:my-secret:API_KEY') # True
resolve_secret('aws:us-east-1:my-secret:API_KEY') # 'sk-...'
Custom providers
from vaultriever import SecretProviderRegistry
from vaultriever.sri import SecretProperties
class MyVaultProvider:
name = 'myvault'
def get_secret_value(self, props: SecretProperties) -> str:
...
SecretProviderRegistry.register(MyVaultProvider())
# Now 'myvault:qualifier:name:key' SRIs resolve through it.
Providers
AWS Secrets Manager
- Credentials come from the AWS SDK default chain (env vars, profile, IAM role).
- The region is required and taken from the SRI.
- If the secret's
SecretStringis a JSON object,secret_keyis required and selects a key from it. If it's plaintext (or JSON that isn't an object), omitsecret_key(aws:region:name:) to get the wholeSecretStringback — providing a key for a plaintext secret, or omitting it for a JSON-object secret, raises an error. - Secret payloads are cached per
(secret_name, region)for the process lifetime; callAWSSecretProvider.clear_cache()after a rotation.
Databricks
- On a Databricks runtime, secrets are read via the native
dbutils. - Elsewhere, the databricks-sdk is used with default authentication, or with the CLI profile named by the SRI's qualifier component (
databricks:staging:my-scope:MY_KEY).
Azure Key Vault
- Credentials come from
DefaultAzureCredential(env vars, managed identity, Azure CLI, etc.). - The qualifier is the vault name; the provider builds the vault URL as
https://<vault_name>.vault.azure.net/. - Secret values are cached per
(vault_name, secret_name, version)for the process lifetime; callAzureSecretProvider.clear_cache()after a rotation.
GCP Secret Manager
- Credentials come from Application Default Credentials (ADC).
- The qualifier is the GCP project id; the provider builds the resource name
projects/<project_id>/secrets/<secret_name>/versions/<version>. - Secret values are cached per
(project_id, secret_name, version)for the process lifetime; callGCPSecretProvider.clear_cache()after a rotation.
Development
uv sync --all-extras --dev
uv run pytest
uv run ruff check .
uv run mypy
Run uv run pre-commit install once so ruff format, ruff check --fix, and mypy run
automatically on git commit — this is the same pre-commit config the
CI lint job runs, so a clean local commit means CI lint will pass too.
Releases are published to PyPI by pushing a vX.Y.Z tag.
License
Release files for vaultriever 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vaultriever-0.3.0.tar.gz | 143.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vaultriever-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 159.3 kB
Release files / vaultriever-0.3.0.tar.gz
| Download URL | vaultriever-0.3.0.tar.gz |
|---|---|
| Size | 143.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
683dd213e444562ca452af704f5c60cac81110fdf0f45dd946c16a7452313e4e
|
|
BLAKE2b-256 checksum How to use checksums |
80fac0c1bfc4f70b56d3073c95b0754589855bf54dd4a273a63e0840cf41887f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.
Transparency logRelease files / vaultriever-0.3.0-py3-none-any.whl
| Download URL | vaultriever-0.3.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
731e85d2248e0382d0abb673820f512326559551d4b1ed0bdf272216140b73f1
|
|
BLAKE2b-256 checksum How to use checksums |
1bd5ace0f9075131a6c7f041acfdcf76ea1f20569cfc9470c6b66c8519106d28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.
Transparency log