One master key for all LLM/GenAI endpoints
Project description
LlaMaKey: one master key for accessing all cloud LLM/GenAI APIs
LlaMaKey is the easy and secure solution for key management of multiple users and multiple cloud LLM/GenAI APIs. LlaMaKey gives each user one master key to access multiple cloud AI APIs (OpenAI, Cohere, AnyScale, HuggingFace, Perplexity) through their official SDKs with no code change nor knowing the actual API keys. (How it works)
- For each user, one master key for multiple APIs.
- The master key is unique to each user. Granting and revoking a user's access won't impact other users.
- The actual API keys to authenticate with cloud APIs are never known to users.
- No code change! Keep using the official Python SDK of the cloud AI APIs.
It solves the pain point of having too many keys to manage for both the user and the administrator and eliminates the risk of key leakage due to user carelessness.
graph TD
subgraph Your team
A[User 1] -- Master Key 1 --> L["LlaMaKey server"]
B[User 2] -- Master Key 2 --> L
C[User 100] -- Master Key 100 --> L
end
L -- Actual <br> OPENAI_API_KEY --> O[OpenAI <br> endpoints]
L -- Actual <br> CO_API_KEY--> P[Cohere <br> endpoints]
L -- Actual <br> HF_API_KEY--> Q[HuggingFace <br>endpoints]
Roadmap
Supported APIs:
- OpenAI (all endpoints)
- Cohere (all endpoints)
- AnyScale (AnyScale API is OpenAI-client compatible)
- Perplexity AI (Perplexity API is OpenAI-client compatible)
- HuggingFace Inference API (free tier)
- HuggingFace EndPoint API
- Anthropic
- Google Vertex AI
- Vectara AI
Currently, authentication with the LlaMaKey server is not enabled. All users share the master key LlaMaKey
. If you want to see it, please upvote here.
Installation
-
Stable version:
pip install llamakey
-
Nightly version: download from here
-
For building from source, see Build from source.
Usage
The server end
Set up the actual API keys as environment variables per their respective APIs, and then start the server, for example:
# Step 1: Set the actual API keys as environment variables
export OPENAI_API_KEY=sk-xxx # openai
export CO_API_KEY=co-xxx # cohere
export HF_TOKEN=hf-xxx # huggingface
export ANYSCALE_API_KEY=credential-xxx # anyscale
export PERPLEXITY_API_KEY=pplx-xxx # perplexity
lmk # Step 2: start the server
By default, the server is started at http://localhost:8000
(8000 is the default port of FastAPI).
Shell commands to activate proper environment variables on your client end will be printed, like this:
export OPENAI_BASE_URL="http://127.0.0.1:8000/openai" # direct OpenAI calls to the LlaMaKey server
export CO_API_URL="http://127.0.0.1:8000/cohere"
export ANYSCALE_BASE_URL="http://127.0.0.1:8000/anyscale"
export HF_INFERENCE_ENDPOINT="http://127.0.0.1:8000/huggingface"
export OPENAI_API_KEY="LlaMaKey" # One master key for all APIs
export CO_API_KEY="LlaMaKey"
export ANYSCALE_API_KEY="LlaMaKey"
export HF_TOKEN="LlaMaKey"
Such environment variables will direct the API calls to the LlaMaKey server. For your convenience, the commands are also dumped to the file./llamakey_client.env
.
The client end
Just activate the environment variables generated above and then run your code as usual!
You may copy and paste the commands above or simply source the llamakey_client.env
file generated above, for example:
# step 1: activate the environment variables that tell official SDKs to make requests to LlaMaKey server
source llamakey_client.env
# Step 2: Call offical Python SDKs as usual, for example, for OpenAI:
python3 -c '\
from openai import OpenAI;
client = OpenAI();
print (\
client.chat.completions.create(\
model="gpt-3.5-turbo",\
messages=[{"role": "user", "content": "How hot is the sun?"}]
)
)'
Build from source
Requirements: git and Rust Toolchain.
git clone git@github.com:TexteaInc/LlaMasterKey.git
# you can switch to a different branch:
# git switch dev
cargo build --release
# binary at ./target/release/lmk
# run it without installation
cargo run
# you can also install it system-wide
cargo install --path .
# run it
lmk
How LlaMaKey works
As a proxy, LlaMaKey takes advantage of a feature in the Python SDK of most cloud LLM/GenAI APIs that they allow setting the base URL and API keys/tokens to and with which a request is sent and authenticated (OpenAI's, Cohere's). The base URL and API key can be set easily via environment variables. So a client just needs to set such environment variables (or manually configure in their code) and then call the APIs as usual -- see how simple and easy. LlaMaKey will receive the request, authenticate the user (if authentication is enabled), and then forward the request to the corresponding actual cloud API with an actual API key (set by the administrator when starting a LlaMaKey server). The response will be passed back to the client after the LlaMaKey server hears back from a cloud API.
License
Ah, this is important. Let's say MIT for now?
Contact
For usage, bugs, or feature requests, please open an issue on Github. For private inquiries, please email hello@LlaMaKey.ai
.
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 Distributions
File details
Details for the file llamakey-0.1.4.tar.gz
.
File metadata
- Download URL: llamakey-0.1.4.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9ecdb3d4c8eff54c8c982e03b084a90fdf6dede323637490392ab9d6909d5db |
|
MD5 | 1569c4cb09b397e37bc3bdd33f7f9239 |
|
BLAKE2b-256 | 85baed0572eb94fd1428a57c2e516efdd41584f3126e8fbb957687e038ed74aa |
File details
Details for the file llamakey-0.1.4-py3-none-win_amd64.whl
.
File metadata
- Download URL: llamakey-0.1.4-py3-none-win_amd64.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ef6bf2dc7a92eacebcd4f7adf7133389e613e653df08596239d0cff1a4798f4 |
|
MD5 | d5f5b2a4aa271b478c3f8dcb35602d44 |
|
BLAKE2b-256 | 4059e41a8d06bb7aa989324352928b4c25a780b0b12fbbe9626deadbe894b66c |
File details
Details for the file llamakey-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: llamakey-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 211c4697f9e080871152ed5e60323c2dd04670ba8118f4c924eb4964a2c360dd |
|
MD5 | c322aa39e75cc27b43bdd521ae87f7b4 |
|
BLAKE2b-256 | 97ebc2e26e21ee046d861f72560e43671bc622bf8b47a1cf4b5da0ec8d6c2a33 |
File details
Details for the file llamakey-0.1.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
.
File metadata
- Download URL: llamakey-0.1.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 6.8 MB
- Tags: Python 3, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636a9fe762235cd228fefe9a014c699d7d7459cb1ee3eeec8bc8fb9803729b9f |
|
MD5 | 43cdd85e37bec0eb825c090575e2abcb |
|
BLAKE2b-256 | addfb39659a3c458fda7330fccdb2d7fd21b66e24ab8bf15a60ca153f98847f5 |