Skip to main content

Use AI to manage your Bitwarden API keys.

Project description

Bitwarden AI Key Manager (BAKM)

BAKM is a command-line interface (CLI) tool designed to streamline the management of AI model configurations by syncing them between a local LiteLLM-formatted YAML file and a Bitwarden vault.

It leverages Bitwarden's Secure Notes and Custom Fields to store model parameters, ensuring that sensitive information like API keys is kept secure. The tool also supports pulling configurations from Bitwarden and converting them into various formats, such as LiteLLM YAML, Claude Code Router JSON, or a generic JSON structure.

Features

  • Sync to Bitwarden: Upload models from a litellm_config.yaml to a specified folder in your Bitwarden vault.
  • Pull from Bitwarden: Fetch model configurations from Bitwarden.
  • Multiple Output Formats: Convert pulled configurations into litellm, claude-router, or json formats.
  • Secure Storage: Automatically stores api_key values in hidden custom fields within Bitwarden.
  • Easy Configuration: Uses a .env file to configure the target Bitwarden folder.

Prerequisites

  1. Python: Version 3.8 or higher.
  2. Bitwarden CLI: The bw command-line tool must be installed and accessible in your system's PATH. You can find installation instructions here. For macOS users, you can install it using Homebrew:
    brew install bitwarden-cli
    

Installation

  1. Clone the repository:

    git clone <repository_url>
    cd BitwardnAiKeyManager
    
  2. Install dependencies using uv: This project uses uv for dependency management. If you don't have it, install it first. Then, install the project in editable mode:

    uv pip install -e .
    

    This will install all required packages and register the bakm command in your shell.

Configuration

  1. Log in to Bitwarden CLI: Before using the tool, you must be logged in to your Bitwarden account and your vault must be unlocked.

    # Log in (only needs to be done once)
    bw login
    
    # Unlock your vault (session-based)
    bw unlock
    
  2. Create a Bitwarden Folder: In your Bitwarden vault (either via the app or web vault), create a new folder to store your AI model configurations. For example, you can name it AI_KEYS.

  3. Set up the Environment File: Create a .env file in the project root by copying the example file:

    cp .env.example .env
    

    Edit the .env file and set BITWARDEN_FOLDER_NAME to the exact name of the folder you created in the previous step.

    # .env
    BITWARDEN_FOLDER_NAME="AI_KEYS"
    

Usage

The CLI is available via the bakm command.

Sync to Bitwarden

The sync command reads a local litellm_config.yaml file and creates or updates corresponding Secure Notes in your Bitwarden vault.

# Sync using the default litellm_config.yaml in the current directory
bakm sync

# Sync using a specific config file
bakm sync --config /path/to/your/config.yaml

The tool will match models by the model_name field and either update existing entries or create new ones.

Pull from Bitwarden

The pull command fetches all model configurations from the specified Bitwarden folder and outputs them in the desired format.

1. Output as LiteLLM YAML (default):

bakm pull

Output:

model_list:
- model_name: openai/gpt-4o
  litellm_params:
    api_base: https://api.openai.com/v1/
    api_key: sk-xxxx
    model: gpt-4o
- model_name: azure/gpt-4o
  litellm_params:
    api_base: https://your-azure-deployment.openai.azure.com/
    api_key: xxxxx
    api_version: '2024-02-01'
    model: azure/gpt-4o-2024-05-13

2. Output as Claude Code Router JSON:

bakm pull --format claude-router

3. Output as Generic JSON and Save to a File:

bakm pull --format json --out my_models.json

This will create a file named my_models.json with the configuration data.

Get Help

For a full list of commands and options, use the --help flag.

bakm --help
bakm sync --help
bakm pull --help

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

bitwardnaikeymanager-0.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

bitwardnaikeymanager-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file bitwardnaikeymanager-0.1.0.tar.gz.

File metadata

File hashes

Hashes for bitwardnaikeymanager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a2e7ca4869c9f4f1695a1294ff696e28799c0254ff1e2575c8ea257b2b1c869
MD5 55529053d626000b3072c5569ca42fc3
BLAKE2b-256 e9cde359680c3a5b40bc8b94c40dac24e5517887c751d105be8957e7953844a1

See more details on using hashes here.

File details

Details for the file bitwardnaikeymanager-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bitwardnaikeymanager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9aa6002ea916a9b79f2b87443b06172edf9c5313badedf24729913f9050ef6d
MD5 6449502a21cee0e0f079cc6b46fbdcf2
BLAKE2b-256 3b66229ed5557669c1333bad99caa350f8a69e1d02c9a8fc80914996be0dc414

See more details on using hashes here.

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