gate: Claude Code behind it — OAuth bearer, anthropic-beta, token counting, the gate's own watch

A coding agent's traffic differs from a hand-made request: with a
subscription Claude Code authenticates with an OAuth bearer and sends
anthropic-beta; it counts tokens at /v1/messages/count_tokens; it makes a
request per tool call; its tool-only turns have no text; its context runs
to megabytes. So: with the courtyard key in X-Bikoret-Key, the caller's
Authorization: Bearer is forwarded to Anthropic as its credential, and
anthropic-beta with it; count_tokens is carried through unexamined and
uncharged; the watch counts the gate at its own windows (120/min,
2,000/h per key — tier :gate); a reply with no text is delivered as it
came with bikoret.verdict "none" and no fringe block (stream and
non-stream); the sources keep the newest user turns whole and drop the
oldest past 1 MiB. Ingress body 32 MiB; ConfigMap manna amounts raised
to 5000/5000 (the kohen's lever). Tamid §1.1, KOHEN "Claude Code behind
the gate". Doorpost re-pinned. Elixir 617/0 read before this commit;
gate_test 25.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Fable 5.1 committed 2026-10-15 15:51:31 +00:00
1 parent a16617fffe
commit f19a5ea007
13 files changed
+207 -43

No files matched your search

+20
View File
@@ -593,6 +593,26 @@ the finding, and the second reply is delivered marked with both refs.
Streaming clients (`"stream": true`, Claude Code among them) are carried
through as they stream; the fringe arrives as the last text block and the
`bikoret` object on the final event — no headers, no rebuke on a stream.
**Claude Code behind the gate.** In the shell that starts Claude Code:
```bash
export ANTHROPIC_BASE_URL=https://bikoret.ch/gate/anthropic
export ANTHROPIC_CUSTOM_HEADERS="X-Bikoret-Key: <courtyard key>"
claude
```
With a subscription Claude Code authenticates with its own OAuth bearer,
which the gate forwards together with `anthropic-beta`; with
`ANTHROPIC_API_KEY` set it sends `x-api-key`, also forwarded. Every reply
with text ends with its fringe; tool-only turns pass unmarked. Token
counting (`/v1/messages/count_tokens`) is carried through unexamined.
A coding agent makes a request per tool call: the gate's watch allows
120 a minute and 2,000 an hour per key, and each request spends one
`api_calls_external` and one compute unit of the day's manna — raise
`MANNA_API_CALLS_EXTERNAL` and `MANNA_COMPUTE_UNITS` in the ConfigMap
for the days a session runs behind the gate. Its requests carry a large
context: the Ingress accepts 32 MiB.
Each upstream call spends one `api_calls_external` of the day's manna
(Day 4): a provision with 0 shuts the gate (503 MANNA_DEPLETED) while
the bedikah by hand still runs. Streaming is refused (422). A non-200