Convenient, extensible API key management for Generative AI applications using cloud secret vaults.
Project description
GenAIKeys
Convenient, extensible API key management for Generative AI applications using cloud secret vaults. One Python API across Azure Key Vault, AWS Secrets Manager, and Google Secret Manager.
flowchart LR
App[Your AI App] -->|sk.get| Cache{TTL Cache}
subgraph GenAIKeys
Cache
end
Cache -->|Cache miss| Azure[(Azure Key Vault)]
Cache -->|Cache miss| AWS[(AWS Secrets)]
Cache -->|Cache miss| GCP[(GCP Secret Manager)]
Why GenAIKeys?
- One API, multiple vaults — swap providers without touching app code.
- Keyless by default — Managed Identity, IAM roles, ADC.
- TTL cache built in — fewer vault calls, lower bills.
- Extensible — bring your own backend in a few lines.
- Convenience helpers for OpenAI, Anthropic, and Gemini.
Install
pip install genaikeys # Azure (default)
pip install "genaikeys[aws]"
pip install "genaikeys[gcp]"
pip install "genaikeys[all]"
Quick start
from genaikeys import GenAIKeys
sk = GenAIKeys.azure() # or .aws() / .gcp()
api_key = sk.get("huggingface-api-key")
openai_key = sk.get_openai_key() # → "OPENAI-API-KEY"
anthropic_key = sk.get_anthropic_key() # → "ANTHROPIC-API-KEY"
gemini_key = sk.get_gemini_key() # → "GEMINI-API-KEY"
Factory methods read defaults from the environment:
| Backend | Env var(s) |
|---|---|
GenAIKeys.azure() |
AZURE_KEY_VAULT_URL |
GenAIKeys.aws() |
AWS_DEFAULT_REGION, optional AWS_PROFILE |
GenAIKeys.gcp() |
GOOGLE_CLOUD_PROJECT |
Azure tip: Key Vault disallows underscores in secret names. GenAIKeys auto-converts
_→-, sosk.get("OPENAI_API_KEY")looks upOPENAI-API-KEY.
Working examples for each cloud live in examples/.
Documentation
Full docs are published at https://ndamulelonemakh.github.io/genaikeys/:
- Configuration & authentication — Azure, AWS, GCP setup, credential chains, IAM/RBAC requirements.
- CLI — populate
.envfiles from a vault. - Custom backends — implement your own secret store.
- Logging — enable, disable, route to a custom handler.
CLI
Populate a .env (or .env.example) file with values from your vault:
genaikeys fill .env --keyvault https://my-kv.vault.azure.net
Or go the other way — upload values from a .env into a vault:
genaikeys push .env --keyvault https://my-kv.vault.azure.net
Only empty values are filled by default; push skips keys that already exist. See docs/cli.md for all options (--backend, --overwrite, --dry-run, --strict, --only, --output, …).
Caching
sk = GenAIKeys.azure(cache_duration=300) # 5-minute TTL
sk.clear("OPENAI_API_KEY") # invalidate one key
sk.clear() # invalidate everything
Custom backends
from genaikeys import GenAIKeys
from genaikeys.plugins import SecretManagerPlugin
class MyPlugin(SecretManagerPlugin):
def get_secret(self, secret_name: str) -> str:
return "my-secret-value"
sk = GenAIKeys(MyPlugin())
See Custom backends for the full interface and entry-point registration.
Contributing
PRs welcome — see CONTRIBUTING.md and CHANGELOG.md.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genaikeys-0.1.0rc5.tar.gz.
File metadata
- Download URL: genaikeys-0.1.0rc5.tar.gz
- Upload date:
- Size: 103.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70c120358cebc9b895c62a089bda48b87d567d7b60185dbacd45a8e42608059d
|
|
| MD5 |
31040184a2b0332e5c9da283669f4aaa
|
|
| BLAKE2b-256 |
3d0193c9e2c84ddfdd9abbbc44352147eaa0048412eb5e4c4d279d08360962e0
|
Provenance
The following attestation bundles were made for genaikeys-0.1.0rc5.tar.gz:
Publisher:
python-publish.yml on ndamulelonemakh/genaikeys
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genaikeys-0.1.0rc5.tar.gz -
Subject digest:
70c120358cebc9b895c62a089bda48b87d567d7b60185dbacd45a8e42608059d - Sigstore transparency entry: 1342982816
- Sigstore integration time:
-
Permalink:
ndamulelonemakh/genaikeys@dc50a860096c47e3dc52666cea65f2a0b8bed52d -
Branch / Tag:
refs/tags/0.1.0rc5 - Owner: https://github.com/ndamulelonemakh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dc50a860096c47e3dc52666cea65f2a0b8bed52d -
Trigger Event:
release
-
Statement type:
File details
Details for the file genaikeys-0.1.0rc5-py3-none-any.whl.
File metadata
- Download URL: genaikeys-0.1.0rc5-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58f2beeba9dadf73d2ae4ea54d6aa4cb18bf5484840c55cc230a42517b7c87e7
|
|
| MD5 |
228d3909de229e39a0aa5f446345d7d3
|
|
| BLAKE2b-256 |
18f4da886c1bb901ff729b1de8f27e8fd4c0a20046c3df9e3efb886f560cf633
|
Provenance
The following attestation bundles were made for genaikeys-0.1.0rc5-py3-none-any.whl:
Publisher:
python-publish.yml on ndamulelonemakh/genaikeys
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genaikeys-0.1.0rc5-py3-none-any.whl -
Subject digest:
58f2beeba9dadf73d2ae4ea54d6aa4cb18bf5484840c55cc230a42517b7c87e7 - Sigstore transparency entry: 1342982821
- Sigstore integration time:
-
Permalink:
ndamulelonemakh/genaikeys@dc50a860096c47e3dc52666cea65f2a0b8bed52d -
Branch / Tag:
refs/tags/0.1.0rc5 - Owner: https://github.com/ndamulelonemakh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@dc50a860096c47e3dc52666cea65f2a0b8bed52d -
Trigger Event:
release
-
Statement type: