{% extends "base.html" %} {% block title %}{% if is_new %}Key Created{% else %}Token Rotated{% endif %} — Tourniquet{% endblock %} {% block content %} {% set proxy_url = request.url.scheme ~ "://" ~ request.url.netloc %} {% set ds = default_shell | default("bash") %}
{% if is_new %}

Key created: {{ key_name }}

{% else %}

Token rotated: {{ key_name }}

{% endif %}

⚠️ This token is shown once only. Copy it now — it cannot be recovered.

{{ token }}

🔒 Only the bcrypt hash of this token is stored in the local SQLite DB. Even Tourniquet can't recover the plaintext — that's why we show it once.

Use it now — pick your tool

Each block below already has your token + the Tourniquet URL filled in. Click Copy, paste, and you're routing through Tourniquet.

Shell — bash / zsh
export ANTHROPIC_BASE_URL={{ proxy_url }}
export ANTHROPIC_API_KEY={{ token }}

Add these two lines to ~/.zshrc or ~/.bashrc to make them persist, or paste before launching an agent.

Shell — PowerShell
$env:ANTHROPIC_BASE_URL = "{{ proxy_url }}"
$env:ANTHROPIC_API_KEY  = "{{ token }}"

To persist across sessions, add to your $PROFILE file.

Shell — cmd.exe
set ANTHROPIC_BASE_URL={{ proxy_url }}
set ANTHROPIC_API_KEY={{ token }}

Use setx instead of set to persist to user environment permanently.

Quick smoke test (curl bash/zsh, ~1 cent)
curl -s -N -X POST {{ proxy_url }}/v1/messages \
  -H "authorization: Bearer {{ token }}" \
  -H "content-type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model":"claude-haiku-4-5-20251001","max_tokens":50,"messages":[{"role":"user","content":"say hi in 5 words"}]}'
Quick smoke test (curl PowerShell, ~1 cent)
curl.exe -s -X POST {{ proxy_url }}/v1/messages `
  -H "authorization: Bearer {{ token }}" `
  -H "content-type: application/json" `
  -H "anthropic-version: 2023-06-01" `
  -d '{"model":"claude-haiku-4-5-20251001","max_tokens":50,"messages":[{"role":"user","content":"say hi in 5 words"}]}'

curl.exe ships with Windows 10+. Use backtick (`) for line continuation in PowerShell.

Python SDK (anthropic)
import anthropic

client = anthropic.Anthropic(
    api_key="{{ token }}",
    base_url="{{ proxy_url }}",
)

resp = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=100,
    messages=[{"role": "user", "content": "hi"}],
)
print(resp.content[0].text)
Node / TypeScript SDK (@anthropic-ai/sdk)
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: "{{ token }}",
  baseURL: "{{ proxy_url }}",
});

const resp = await client.messages.create({
  model: "claude-haiku-4-5-20251001",
  max_tokens: 100,
  messages: [{ role: "user", content: "hi" }],
});
console.log(resp.content[0].text);
Claude Code CLI — bash/zsh
export ANTHROPIC_BASE_URL={{ proxy_url }}
export ANTHROPIC_API_KEY={{ token }}
claude

Any claude session in this shell now routes through Tourniquet. Heads-up: switches Claude Code from subscription to API metered billing. The cap protects you from runaway, but usage still costs money. unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY to revert.

Claude Code CLI — PowerShell
$env:ANTHROPIC_BASE_URL = "{{ proxy_url }}"
$env:ANTHROPIC_API_KEY  = "{{ token }}"
claude

To revert: Remove-Item Env:ANTHROPIC_BASE_URL, Env:ANTHROPIC_API_KEY

Claude Code CLI — cmd.exe
set ANTHROPIC_BASE_URL={{ proxy_url }}
set ANTHROPIC_API_KEY={{ token }}
claude

To revert: set ANTHROPIC_BASE_URL= and set ANTHROPIC_API_KEY= (empty assignment unsets).

OJW Swarm (or any agent script) — bash/zsh
export ANTHROPIC_BASE_URL={{ proxy_url }}
export ANTHROPIC_API_KEY={{ token }}

Paste at the top of your launcher script, or add to the env block of your systemd / launchd unit.

OJW Swarm (or any agent script) — PowerShell
$env:ANTHROPIC_BASE_URL = "{{ proxy_url }}"
$env:ANTHROPIC_API_KEY  = "{{ token }}"
OJW Swarm (or any agent script) — cmd.exe
set ANTHROPIC_BASE_URL={{ proxy_url }}
set ANTHROPIC_API_KEY={{ token }}
Safety net: if Tourniquet ever crashes or you need to escape, unset the env vars and your agents fall back to direct Anthropic.
bash/zsh: unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY
PowerShell: Remove-Item Env:ANTHROPIC_BASE_URL, Env:ANTHROPIC_API_KEY
cmd.exe: set ANTHROPIC_BASE_URL= & set ANTHROPIC_API_KEY=
Go to dashboard
{% endblock %}