chore(deploy): prefer a dedicated API key over the shared OAuth token

The OAuth token shares one rate budget across everything on the subscription
(incl. interactive Claude Code sessions), so citti's translation is almost
always throttled while coding — hence the page staying German. Template now
emits ANTHROPIC_API_KEY from citti/anthropic_api_key when set (its own rate
budget, no contention), else the OAuth token. Only one var is written so an
empty key can't shadow the token.
This commit is contained in:
Henrik Jess Nielsen
2026-10-30 12:19:45 +01:00
parent 67ffc07a04
commit c5e4a326e0

View File

@@ -97,15 +97,21 @@ job "citti" {
HOST = "0.0.0.0" HOST = "0.0.0.0"
} }
# Claude OAuth token for DA translation + AI offer matching. Set as # Claude credential for DA translation + AI offer matching.
# ANTHROPIC_AUTH_TOKEN (the SDK reads it as a Bearer token); the app adds # Prefer a dedicated API key (citti/anthropic_api_key) — its own rate
# the required anthropic-beta: oauth-2025-04-20 header. We deliberately do # budget, so citti doesn't compete with interactive Claude Code sessions
# NOT set ANTHROPIC_API_KEY — even an empty value would shadow the token. # on the same subscription. Else fall back to the OAuth token, set as
# keyOrDefault keeps it empty (not a deploy failure) if the KV is unset — # ANTHROPIC_AUTH_TOKEN (the app adds the oauth-2025-04-20 beta header).
# offers then stay German with heuristic matching. # Only ONE var is written: an empty ANTHROPIC_API_KEY would shadow the
# token, so we never emit it unless the key actually exists. If neither
# is set the token var is empty and offers stay German (heuristic match).
template { template {
data = <<EOT data = <<EOT
{{ if keyExists "citti/anthropic_api_key" -}}
ANTHROPIC_API_KEY={{ key "citti/anthropic_api_key" }}
{{- else -}}
ANTHROPIC_AUTH_TOKEN={{ keyOrDefault "citti/claude_oauth_token" "" }} ANTHROPIC_AUTH_TOKEN={{ keyOrDefault "citti/claude_oauth_token" "" }}
{{- end }}
EOT EOT
destination = "secrets/app.env" destination = "secrets/app.env"
env = true env = true