Documentation

Everything you need to start saving on LLM API costs.

Quick Start

Get up and running in under 5 minutes. Three steps, one line of code.

Step 1: Sign up

Create your account at tokenshield.dev and receive your API key instantly.

# Or via API: curl -X POST https://api.tokenshield.dev/auth/signup \ -H "Content-Type: application/json" \ -d '{"email": "you@company.com", "password": "your-password"}' # Response: { "access_token": "eyJhbG...", "api_key": "ts-live-abc123..." }

Step 2: Change your base_url

Point your existing SDK to TokenShield. No other changes needed.

# Python (Anthropic SDK) import anthropic client = anthropic.Anthropic( base_url="https://api.tokenshield.dev/v1", api_key="ts-live-your-key", ) response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}] )
# Python (OpenAI SDK) import openai client = openai.OpenAI( base_url="https://api.tokenshield.dev/v1", api_key="ts-live-your-key", ) response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}] )

Step 3: Check your dashboard

Visit your dashboard to see exactly how much you are saving. Every request is logged with full cost transparency.

How It Works

TokenShield sits between your code and the LLM provider. For each request, it applies three optimizations:

1. Semantic Caching

If we have seen a similar request before, we return the cached response instantly. Cost: $0, latency: near-zero.

2. Smart Routing

Easy queries are routed to cheaper, faster models (e.g., Haiku instead of Sonnet). Hard queries go to the original model you specified. You always get the quality you need.

3. PII Masking

Personal information is automatically detected and masked before sending to any model. It is restored in the response. This protects your users and reduces compliance risk.

Pricing

Simple, transparent, risk-free.

Free $0/mo 100 requests/month Pay as you save 20% of savings $200/month cap Enterprise Custom Contact us If we save you $0, you pay $0. Zero risk.

Savings calculation:

Original Cost = What you would have paid without TokenShield Actual Cost = What TokenShield actually spent Savings = Original - Actual TokenShield Fee = Savings x 20% (capped at $200/mo) Net Savings = Savings x 80% (always yours)

API Reference

Proxy

POST /v1/chat/completions

OpenAI-compatible chat completions endpoint. Pass your request exactly as you would to OpenAI.

POST /v1/messages

Anthropic-compatible messages endpoint (coming soon).

Authentication

POST /auth/signup

Create account. Body: {"email", "password"}. Returns JWT + API key.

POST /auth/login

Log in. Body: {"email", "password"}. Returns JWT.

GET /auth/me

Get current user info. Requires JWT in Authorization header.

API Keys

POST /keys

Create a new API key. Body: {"name"}.

GET /keys

List all API keys for the current user.

DELETE /keys/:id

Revoke an API key.

Provider Keys

POST /providers

Register a provider API key (Claude/GPT). Body: {"provider", "api_key"}.

GET /providers

List registered providers.

DELETE /providers/:id

Remove a provider key.

Dashboard

GET /dashboard/summary

Get savings summary, KPIs, model usage breakdown.

GET /dashboard/usage

Get detailed request logs for charting.

GET /dashboard/invoice

Get current billing period invoice.

System

GET /health

Health check. Returns {"status": "ok"}.

Support

Questions? Issues? Reach out to us: