Compare commits
4
Commits
41b8560f46
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
192d906dbf | ||
|
|
24dbd313cf | ||
|
|
61964cd217 | ||
|
|
2e1e35d7fb |
No files matched your search
@@ -26,5 +26,5 @@
|
|||||||
],
|
],
|
||||||
"mediaLinks": [],
|
"mediaLinks": [],
|
||||||
"changelog": "Initial package for inference.coop",
|
"changelog": "Initial package for inference.coop",
|
||||||
"dockerImage": "registry.inference.coop/code/litellm:20261127-18aa7c7"
|
"dockerImage": "registry.inference.coop/code/litellm:20261128-24dbd31"
|
||||||
}
|
}
|
||||||
@@ -233,15 +233,36 @@ LibreChat (chat) does **not** talk to this gateway directly — it routes throug
|
|||||||
- `co-op/docs` — documentation, including the member-facing model list
|
- `co-op/docs` — documentation, including the member-facing model list
|
||||||
- `co-op/design-assets` — logos, fonts, brand materials
|
- `co-op/design-assets` — logos, fonts, brand materials
|
||||||
|
|
||||||
## Scheduled tasks (scheduler addon)
|
## Audio keep-alive
|
||||||
|
|
||||||
The gateway pings the Tinfoil audio models every 10 minutes (`audio_keepalive.py`,
|
The gateway pings the Tinfoil TTS model every 30 minutes (`audio_keepalive.py`,
|
||||||
declared in `CloudronManifest.json` → `addons.scheduler`) to keep the TEE audio
|
started by the loop in `start.sh`) to keep the TEE audio enclave warm — voice
|
||||||
enclave warm — voice mode then skips the ~24s cold-start after idle. TTS-only:
|
mode then skips the ~24s cold-start after idle. TTS-only: an STT ping would cost
|
||||||
an STT ping would cost $0.01/request (~$52/mo at 6/hr) versus $0.002 for TTS.
|
$0.01/request (~$52/mo at 6/hr) versus $0.002 for TTS — about **$0.096/day
|
||||||
|
(~$2.88/mo)**.
|
||||||
|
|
||||||
The script reads the master key from `/app/data/.master_key` (written by
|
The 30-minute interval is measured, not assumed: an idle sweep on 2026-11-28
|
||||||
`start.sh`); the `LITELLM_MASTER_KEY` env var is only exported into the litellm
|
(gaps 5–60 min through this gateway) found warm latency (0.38–0.99s) through
|
||||||
process, not scheduler tasks. Verify after deploys: `cloudron exec --app <id>
|
45 minutes idle and no cold-start cliff. The earlier 15-minute cadence cost
|
||||||
-- python3 /app/code/audio_keepalive.py` should exit 0 silently, and the deploy
|
~$5.76/mo for warmth that was already there; 30 min halves it and stays inside
|
||||||
log must show `setupAddons: ... scheduler ... audio_keepalive`.
|
the proven-warm window. Re-run that sweep if the provider's behaviour changes —
|
||||||
|
the script and probe notes live in this repo's history.
|
||||||
|
|
||||||
|
**Billing is the point of the key split.** The ping authenticates with the
|
||||||
|
keepalive team's own key, read from `/app/data/.keepalive_key`: team
|
||||||
|
`agent:audio-keepalive`, model-scoped to `tinfoil/voxtral-tts`, budget $10/30d.
|
||||||
|
That is what puts the cost on the panel's own-spend line. The master key
|
||||||
|
(`/app/data/.master_key`, written by `start.sh`) remains only a fallback: its
|
||||||
|
requests log `team_id = ''`, which no alias resolves, so ~$0.19/day of real
|
||||||
|
spend was invisible to the panel, the digest and the spend guard until
|
||||||
|
2026-11-28. If the key file is missing the script warns once and still warms.
|
||||||
|
|
||||||
|
Recreate on a fresh data volume (from inside the container, master key from
|
||||||
|
`/app/data/.master_key`): `POST /team/new {"team_alias": "agent:audio-keepalive",
|
||||||
|
"max_budget": 10, "budget_duration": "30d"}` then `POST /key/generate {"team_id":
|
||||||
|
<id>, "models": ["tinfoil/voxtral-tts"], "key_alias": "audio-keepalive"}`, writing
|
||||||
|
the returned key to `/app/data/.keepalive_key`.
|
||||||
|
|
||||||
|
Verify after deploys: `cloudron exec --app <id> -- python3 /app/code/audio_keepalive.py`
|
||||||
|
exits 0 silently, and a fresh `$0.002` SpendLogs row appears under
|
||||||
|
`agent:audio-keepalive` within 30 minutes.
|
||||||
+43
-13
@@ -3,32 +3,62 @@
|
|||||||
so voice mode doesn't pay the ~24s cold-start after idle.
|
so voice mode doesn't pay the ~24s cold-start after idle.
|
||||||
|
|
||||||
Runs INSIDE the gateway container, invoked by the keep-alive loop in
|
Runs INSIDE the gateway container, invoked by the keep-alive loop in
|
||||||
start.sh (every 15 min; the Cloudron scheduler task was removed
|
start.sh (every 30 min; the Cloudron scheduler task was removed
|
||||||
2026-11-09 so the loop is the only warm path). Reads the master key from
|
2026-11-09 so the loop is the only warm path). TTS-only (STT pings cost
|
||||||
env or /app/data/.master_key. TTS-only (STT pings cost
|
|
||||||
$0.01/request each; TTS $0.002 — see docs, keep-alive economics). Silent on
|
$0.01/request each; TTS $0.002 — see docs, keep-alive economics). Silent on
|
||||||
success; prints + exits non-zero on failure so keepalive.log captures it.
|
success; prints + exits non-zero on failure so keepalive.log captures it.
|
||||||
|
|
||||||
|
BILLING: the ping uses the keepalive team's own key (/app/data/.keepalive_key,
|
||||||
|
team agent:audio-keepalive, model-scoped to tinfoil/voxtral-tts). Anything sent
|
||||||
|
with the master key writes SpendLogs rows with team_id '' — no alias, so no
|
||||||
|
panel, digest or guard can attribute the spend. The master key stays as a
|
||||||
|
fallback for warmth if the team key is missing, and that fallback warns once.
|
||||||
"""
|
"""
|
||||||
import json, os, urllib.request, urllib.error, sys
|
import json, os, urllib.request, urllib.error, sys
|
||||||
|
|
||||||
PORT = os.environ.get("PORT", "4000")
|
PORT = os.environ.get("PORT", "4000")
|
||||||
|
|
||||||
def master_key():
|
def _read(path):
|
||||||
"""The gateway's start.sh generates the master key into /app/data/.master_key
|
|
||||||
and exports LITELLM_MASTER_KEY for the litellm process — scheduler tasks run
|
|
||||||
in a separate process tree, so read the key file directly."""
|
|
||||||
key = os.environ.get("LITELLM_MASTER_KEY", "")
|
|
||||||
if key:
|
|
||||||
return key
|
|
||||||
try:
|
try:
|
||||||
with open("/app/data/.master_key") as f:
|
with open(path) as f:
|
||||||
return f.read().strip()
|
return f.read().strip()
|
||||||
except OSError:
|
except OSError:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
KEY = master_key()
|
|
||||||
|
def warn_once(msg):
|
||||||
|
"""keepalive.log must only grow on failures; a standing config warning would
|
||||||
|
repeat every 30 min. Note it once per container generation instead."""
|
||||||
|
marker = "/app/data/.keepalive_warned"
|
||||||
|
if os.path.exists(marker):
|
||||||
|
return
|
||||||
|
print(msg, file=sys.stderr)
|
||||||
|
try:
|
||||||
|
open(marker, "w").close()
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def master_key():
|
||||||
|
"""The gateway's start.sh generates the master key into /app/data/.master_key
|
||||||
|
and exports LITELLM_MASTER_KEY for the litellm process — scheduler tasks run
|
||||||
|
in a separate process tree, so read the key file directly."""
|
||||||
|
return os.environ.get("LITELLM_MASTER_KEY", "") or _read("/app/data/.master_key")
|
||||||
|
|
||||||
|
def keepalive_key():
|
||||||
|
"""The team key, so warm pings bill to agent:audio-keepalive and show on the
|
||||||
|
co-op's own-spend line. Master key is the fallback (unattributed rows)."""
|
||||||
|
key = os.environ.get("LITELLM_KEEPALIVE_KEY", "") or _read("/app/data/.keepalive_key")
|
||||||
|
if key:
|
||||||
|
return key
|
||||||
|
warn_once("keepalive: /app/data/.keepalive_key missing - falling back to the "
|
||||||
|
"master key; these pings will have no team and bill unattributed")
|
||||||
|
return master_key()
|
||||||
|
|
||||||
|
|
||||||
|
KEY = keepalive_key()
|
||||||
if not KEY:
|
if not KEY:
|
||||||
print("keepalive: no master key (env or /app/data/.master_key)", file=sys.stderr)
|
print("keepalive: no key (keepalive file, env or master key)", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
fail = 0
|
fail = 0
|
||||||
|
|||||||
@@ -284,16 +284,22 @@ echo "Tinfoil proxy is up on 127.0.0.1:3301"
|
|||||||
# could not be proven to reach 127.0.0.1:4000 and /app/data, and two warm
|
# could not be proven to reach 127.0.0.1:4000 and /app/data, and two warm
|
||||||
# paths billed twice for the same ping. The warm path is owned HERE — the
|
# paths billed twice for the same ping. The warm path is owned HERE — the
|
||||||
# app container, where the network namespace, the master key and the
|
# app container, where the network namespace, the master key and the
|
||||||
# sidecar are all proven. Every 15 minutes ping tinfoil/voxtral-tts
|
# sidecar are all proven. Every 30 minutes ping tinfoil/voxtral-tts
|
||||||
# ($0.002/request) so voice mode skips the ~24s Tinfoil cold-start after
|
# ($0.002/request) so voice mode skips the ~24s Tinfoil cold-start after
|
||||||
# idle. audio_keepalive.py is silent on success and prints on failure, so
|
# idle. 30 min (not 15) because a measured idle sweep on 2026-11-28 found
|
||||||
|
# warm latency through 45 minutes idle — no cold-start cliff — so the
|
||||||
|
# 15-minute cadence was buying nothing and cost ~$5.76/mo; 30 min halves
|
||||||
|
# it to ~$2.88/mo while staying inside the proven-warm window. The script
|
||||||
|
# uses the keepalive team's key (/app/data/.keepalive_key) so the spend
|
||||||
|
# bills to agent:audio-keepalive instead of landing in SpendLogs with no
|
||||||
|
# team. audio_keepalive.py is silent on success and prints on failure, so
|
||||||
# /app/data/keepalive.log only ever grows on failure.
|
# /app/data/keepalive.log only ever grows on failure.
|
||||||
(
|
(
|
||||||
while true; do
|
while true; do
|
||||||
python3 /app/code/audio_keepalive.py >> /app/data/keepalive.log 2>&1 || true
|
python3 /app/code/audio_keepalive.py >> /app/data/keepalive.log 2>&1 || true
|
||||||
sleep 900
|
sleep 1800
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
echo "Audio keep-alive loop started (every 900s)"
|
echo "Audio keep-alive loop started (every 1800s)"
|
||||||
|
|
||||||
exec litellm --config "$CONFIG_FILE" --port 4000 --host 0.0.0.0
|
exec litellm --config "$CONFIG_FILE" --port 4000 --host 0.0.0.0
|
||||||
Reference in new issue
Block a user