Skip to main content

Convenient, extensible API key management for Generative AI applications using cloud secret vaults.

Project description

GenAIKeys

PyPI version CI License

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 _-, so sk.get("OPENAI_API_KEY") looks up OPENAI-API-KEY.

Working examples for each cloud live in examples/.

Documentation

Full docs are published at https://ndamulelonemakh.github.io/genaikeys/:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genaikeys-0.1.0rc5.tar.gz (103.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genaikeys-0.1.0rc5-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

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

Hashes for genaikeys-0.1.0rc5.tar.gz
Algorithm Hash digest
SHA256 70c120358cebc9b895c62a089bda48b87d567d7b60185dbacd45a8e42608059d
MD5 31040184a2b0332e5c9da283669f4aaa
BLAKE2b-256 3d0193c9e2c84ddfdd9abbbc44352147eaa0048412eb5e4c4d279d08360962e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for genaikeys-0.1.0rc5.tar.gz:

Publisher: python-publish.yml on ndamulelonemakh/genaikeys

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for genaikeys-0.1.0rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 58f2beeba9dadf73d2ae4ea54d6aa4cb18bf5484840c55cc230a42517b7c87e7
MD5 228d3909de229e39a0aa5f446345d7d3
BLAKE2b-256 18f4da886c1bb901ff729b1de8f27e8fd4c0a20046c3df9e3efb886f560cf633

See more details on using hashes here.

Provenance

The following attestation bundles were made for genaikeys-0.1.0rc5-py3-none-any.whl:

Publisher: python-publish.yml on ndamulelonemakh/genaikeys

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page