Skip to content

openkeyprotocol/server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OKAP Logo

OKAP Vault

Reference implementation of an OKAP vault - self-host your API key manager.

Features

  • Secure key storage: Master keys never leave the vault
  • Token management: Issue, list, and revoke tokens
  • API proxy: Forward requests using your master keys
  • Fast: Built on FastAPI + async
  • Docker ready: Easy deployment

Quick Start

1. Clone

git clone https://github.com/openkeyprotocol/server.git
cd server
pip install -e .

2. Configure

Create .env:

# Required: Set your API keys
OKAP_OPENAI_API_KEY=sk-...
OKAP_ANTHROPIC_API_KEY=sk-ant-...
OKAP_GOOGLE_API_KEY=AIza...

# Optional
OKAP_BASE_URL=https://vault.yourdomain.com
OKAP_PORT=8000

3. Run

python -m app.main
# or
uvicorn app.server:app --reload

Server runs at http://localhost:8000

API Endpoints

Health Check

GET /

Request Access

POST /okap/request
Content-Type: application/json

{
  "okap": "1.0",
  "provider": "openai",
  "models": ["gpt-4"],
  "capabilities": ["chat"],
  "limits": {
    "monthly_spend": 10.00
  }
}

List Tokens

GET /okap/tokens

Revoke Token

DELETE /okap/tokens/{token_id}

Proxy Requests

POST /v1/openai/chat/completions
Authorization: Bearer okap_abc123...
Content-Type: application/json

{
  "model": "gpt-4",
  "messages": [{"role": "user", "content": "Hello"}]
}

Using with OpenAI SDK

from openai import OpenAI

# Get token from vault first, then:
client = OpenAI(
    api_key="okap_abc123...",
    base_url="http://localhost:8000/v1/openai"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

Docker

docker build -t okap-vault .
docker run -p 8000:8000 \
  -e OKAP_OPENAI_API_KEY=sk-... \
  okap-vault

Architecture

┌──────────────┐     okap token      ┌──────────────┐     real key      ┌──────────────┐
│     App      │ ──────────────────▶ │  OKAP Vault  │ ────────────────▶ │   OpenAI     │
│              │ ◀────────────────── │              │ ◀──────────────── │   Anthropic  │
└──────────────┘     response        └──────────────┘     response      │   Google     │
                                                                        └──────────────┘

Development

# Install dev deps
pip install -e ".[dev]"

# Run tests
pytest

# Run with reload
uvicorn app.server:app --reload

License

MIT

About

Reference OKAP vault implementation - self-host your API key manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published