Docs

Developer documentation

Everything you need to ship with Tokenwise — integration, proxy behaviour, rules engine, public API. No login required to read.

Start

Quickstart

One line of code in your AI SDK. Works with OpenAI, Anthropic, Gemini, Grok, OpenRouter, Groq, DeepSeek, Mistral.

Open onboarding
Code

SDK presets

Drop-in snippets for Vercel AI SDK, OpenAI / Anthropic JS + Python, cURL. No client libraries to install.

Browse SDKs
API

Public REST API

tw_api_* keys with HMAC-only lookup. Per-plan rate limits. Read requests, metrics, evals.

OpenAPI spec
Live

Status

Real-time edge proxy + app health, refreshed every 30 seconds. Programmatic JSON at /api/status.

View status
01

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):

openai.ts
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://proxy.tokenwisehq.com/openai/v1",
  defaultHeaders: { "x-tw-key": process.env.TW_LIVE_KEY },
});
02

Provider paths

ProviderPathShape
OpenAI/openai/v1OpenAI
Anthropic/anthropicAnthropic
Google Gemini/googleOpenAI-compatible
xAI Grok/xai/v1OpenAI-compatible
OpenRouter/openrouter/api/v1OpenAI-compatible
Groq/groq/openai/v1OpenAI-compatible
DeepSeek/deepseek/v1OpenAI-compatible
Mistral/mistral/v1OpenAI-compatible
03

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).
04

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.

05

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).

06

Public REST API

Read-only access to your requests, metrics, evals via tw_api_* bearer tokens. Full OpenAPI 3.1 spec · openapi.json.

Need help?[email protected] — we reply within a day.