KeyGood / Docs
Quick start
Protect OpenAI spend with virtual keys and hard budget limits.
Quick Configuration Example
- Base URL:
- https://your-domain.com/api/v1/openai
- API Key:
- kg_live_xxxx
- Model:
- gpt-4o-mini
Replace the API key with your virtual key from the dashboard. Use a model supported by KeyGood and permitted by your virtual key's model allowlist.
Make your first API request
Copy the command below and replace the virtual key.
curl https://your-domain.com/api/v1/openai/chat/completions \
-H "Authorization: Bearer kg_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Hello from KeyGood"
}
]
}'The endpoint is OpenAI-compatible. Your virtual key is used for authentication and budget enforcement.
Environment / client config
OPENAI_BASE_URL=https://your-domain.com/api/v1/openai OPENAI_API_KEY=kg_live_xxxx
- Sign up
Create an account and sign in to the dashboard.
- Bind your OpenAI API key
Settings → save your master key. It is encrypted (AES-256-GCM) and never shown again.
- Create a virtual key
Set daily/monthly budgets, optional model allowlist and expiration. Copy the key once — only a hash is stored.
- Point your client at KeyGood
Use the Base URL above and your
kg_live_...key. Same paths as OpenAI, e.g./chat/completions. Streaming is supported. - Hard Stop
When the budget is exhausted, the API returns
402withbudget_exceeded— the provider is not called.