Developer documentation
Everything you need to ship with Tokenwise — integration, proxy behaviour, rules engine, public API. No login required to read.
Quickstart
One line of code in your AI SDK. Works with OpenAI, Anthropic, Gemini, Grok, OpenRouter, Groq, DeepSeek, Mistral.
Open onboarding→CodeSDK presets
Drop-in snippets for Vercel AI SDK, OpenAI / Anthropic JS + Python, cURL. No client libraries to install.
Browse SDKs→APIPublic REST API
tw_api_* keys with HMAC-only lookup. Per-plan rate limits. Read requests, metrics, evals.
OpenAPI spec→LiveStatus
Real-time edge proxy + app health, refreshed every 30 seconds. Programmatic JSON at /api/status.
View status→1-line integration
Tokenwise is an HTTP proxy. Point your existing SDK at our base URL with your tw_live_* key — no client library to install, no SDK to maintain. Example (OpenAI JS):
Provider paths
What the proxy does
- +Forwards every request with <50 ms of edge overhead (CF Workers).
- +Logs metadata async — never blocks the upstream response.
- +Applies your rules — caching, model-switch, fallback chains, A/B splits, tag-based overrides.
- +Retries with exponential backoff on 5xx and 429s.
- +Pass-through prompt caching when the upstream supports it (Anthropic, OpenAI).
Rules engine
Create rules in /optimize. Five types: Model switch, Cache, Fallback chain, A/B split, Tag override. Rules can match on model name, request tag, or workspace-wide. Hit-rate + savings shown live on the rule card.
Webhooks
Configure outbound webhooks in Settings → Integrations. Events: alert fired, recommendation ready, eval regression detected. Destination URLs must be on the allowlist (HTTPS only, no private IPs).
Public REST API
Read-only access to your requests, metrics, evals via tw_api_* bearer tokens. Full OpenAPI 3.1 spec · openapi.json.