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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: genaikeys-0.1.0rc4.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.0rc4.tar.gz
Algorithm Hash digest
SHA256 c96d1f2d62e96044a1c94d833099c55a412563eede9140dd9623fcb258f36ef9
MD5 611b3928a637a5952e766840e7374330
BLAKE2b-256 ec8d40cedfa6bc34e737aca5038e8d30443de59abfaf1b537c125784dc5b1d52

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: genaikeys-0.1.0rc4-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.0rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 829fd79276e8be1efc4e20f28748cbefe61a4734b60d2fd1d8da1119593193ab
MD5 120bb2f100336935e2788a2034e26ac5
BLAKE2b-256 e770ad448a6308c75a12a0e90f08667e405062e981241261364876b9d96fbe0e

See more details on using hashes here.

Provenance

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