Tokenminning with Portkey
Portkey is an AI gateway for production apps — unified API, fallback chains, budget controls, and observability across 250+ models.
Hub for the Portkey cluster. Best fit for teams needing org-wide caps and config overrides without self-hosting a proxy.
Quick checklist
- Open Portkey dashboard → Analytics for spend by model and config.
- Set budgets per API key and workspace — budgets.
- Configure fallback chains with cheap models first — routing.
- Use config overrides to enforce model allowlists per environment.
- Export traces for cost attribution — observability.
Typical impact: 50–90% routing routine work to mini-tier; budgets prevent runaway agent loops.
How to reduce Portkey spending
1. Measure first
Portkey Analytics shows requests, tokens, cost, and latency per model, config, and API key.
2. Cap spend
Set budget limits on API keys and workspaces. Block requests when caps are reached.
→ Budgets
3. Route cheap
Build fallback chains: haiku/mini first, capable model second. Use config overrides to lock CI keys to cheap tiers.
4. Cache prefixes
Portkey supports gateway-level caching for identical requests. Stabilize prefixes for provider-side cache too.
5. Trim upstream bloat
Reduce tool schemas and context in your agent — Context hygiene.
6. Guardrail in prod
Use config overrides for model allowlists. Separate configs for dev, staging, and production.
→ Budgets
How Portkey bills
Provider rates plus Portkey platform fee. Check current pricing on portkey.ai. BYOK supported for enterprise contracts.
Guides
| Guide | What you’ll learn |
|---|---|
| Budgets | API key budgets, workspace caps |
| Model routing | Fallback chains, config overrides |
| Observability | Analytics, traces, cost attribution |
Anti-patterns
| Anti-pattern | Why it fails |
|---|---|
| One config for all environments | CI agents burn prod budget |
| Unbounded fallback chain | Every failure retries at frontier tier |
| Portkey + OpenRouter double proxy | Latency and fees stack |