This guide walks you through your first successful inference call with API Keychain in under fifteen minutes.
- A running FastAPI gateway on port 8000
- A Next.js dashboard on port 3000
- A keychain
ak-key and at least one upstream provider key - A chat completion routed through
keychain-medium
- Node.js 18+ and Python 3.10+
- A Supabase project with email/password auth enabled
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export MASTER_SECRET="$(openssl rand -hex 32)"
export SUPABASE_JWT_SECRET="your-supabase-legacy-jwt-secret"
export SUPABASE_URL="https://YOUR-PROJECT.supabase.co"
uvicorn main:app --reloadVerify: curl http://localhost:8000/health
npm install
cp .env.example .env.local
# Edit .env.local with your Supabase URL, anon key, and API base URL
npm run devOpen http://localhost:3000 and create an account.
- Sign in and open Providers.
- Choose a provider (e.g. Groq) and paste your upstream API key.
- Save. The key is encrypted before it reaches the database.
- Open Keys in the dashboard.
- Copy your
ak-...key (shown once on creation; rotate if you lose it).
OpenAI client:
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer ak-YOUR-KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "keychain-medium",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'Claude Code (optional):
export ANTHROPIC_BASE_URL="http://localhost:8000"
export ANTHROPIC_API_KEY="ak-YOUR-KEY"
claudeYou should receive a response. The gateway selected a model from the appropriate tier cascade and failed over automatically if an upstream was throttled.
- Tune model priority in Models
- Exclude providers in Preferences
- Review latency and token usage in Dashboard
- Read configuration.md for production env vars
- Browse examples/ for SDK integrations
| Symptom | Fix |
|---|---|
MASTER_SECRET environment variable is not set |
Export MASTER_SECRET before starting uvicorn |
| Dashboard cannot reach API | NEXT_PUBLIC_API_BASE_URL must be a public URL (e.g. https://api.apikeychain.dev) |
No provider keys configured |
Add at least one provider key in the dashboard |
401 on /v1/* |
Use the ak- keychain key, not the Supabase JWT |
See troubleshooting.md for more.