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, three clouds — swap providers without touching app code.
  • Keyless by default — Managed Identity, IAM roles, ADC.
  • TTL cache built in — fewer vault calls, lower bills.
  • Convenience helpers for OpenAI, Anthropic, and Gemini.
  • Pluggable — bring your own backend in a few lines.

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/:

Caching at a glance

sk = GenAIKeys.azure(cache_duration=300)   # 5-minute TTL
sk.clear("OPENAI_API_KEY")                 # invalidate one key
sk.clear()                                 # invalidate everything

Custom backend in 10 lines

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.0rc3.tar.gz (114.8 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.0rc3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file genaikeys-0.1.0rc3.tar.gz.

File metadata

  • Download URL: genaikeys-0.1.0rc3.tar.gz
  • Upload date:
  • Size: 114.8 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.0rc3.tar.gz
Algorithm Hash digest
SHA256 421846af3eaafd8bcd33890e5e6a75c0874af6c494ea0064f1925388de9e9a82
MD5 5c8305220afdca9125c0be4769c2e301
BLAKE2b-256 e282ea86427e1116c88ffd2c1f5ccecbc97112ff517ce132be850d12c4a7709a

See more details on using hashes here.

Provenance

The following attestation bundles were made for genaikeys-0.1.0rc3.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.0rc3-py3-none-any.whl.

File metadata

  • Download URL: genaikeys-0.1.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 8935cfa11e7bf8152ee17b2a438b34ecea976f8012ef861d1cff1f3da5306697
MD5 3f3cdc092d4981b41d7e19b43445dd72
BLAKE2b-256 39270b55c32822fabedac6d756d66ad2121937dedb2fe9c17dfb6f5643e6c980

See more details on using hashes here.

Provenance

The following attestation bundles were made for genaikeys-0.1.0rc3-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