[object Object]

← back to Whatsmystyle

tryon-worker: hook Gemini call into cost-tracker (logGemini)

63fc18900ebbb5fd16479e078ac19eb4c11d4d37 · 2026-05-13 08:25:23 -0700 · Steve

Every Gemini 2.5 Flash Image try-on call now logs to ~/.claude/cost-ledger.jsonl
with app='whatsmystyle' / note='tryon-worker'. Wraps the existing fetch — try/catch
keeps the worker resilient if the cost-tracker module is missing or errors.

Files touched

Diff

commit 63fc18900ebbb5fd16479e078ac19eb4c11d4d37
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed May 13 08:25:23 2026 -0700

    tryon-worker: hook Gemini call into cost-tracker (logGemini)
    
    Every Gemini 2.5 Flash Image try-on call now logs to ~/.claude/cost-ledger.jsonl
    with app='whatsmystyle' / note='tryon-worker'. Wraps the existing fetch — try/catch
    keeps the worker resilient if the cost-tracker module is missing or errors.
---
 scripts/tryon-worker.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/tryon-worker.js b/scripts/tryon-worker.js
index 772ad15..7b94df4 100644
--- a/scripts/tryon-worker.js
+++ b/scripts/tryon-worker.js
@@ -53,6 +53,10 @@ async function gemini(personImgBuf, garmentImgBuf, instruction) {
   });
   if (!r.ok) throw new Error(`Gemini ${r.status}: ${await r.text()}`);
   const j = await r.json();
+  try {
+    const { logGemini } = require(require('os').homedir() + '/.claude/skills/cost-tracker/scripts/log-gemini.js');
+    logGemini(j, { app: 'whatsmystyle', note: 'tryon-worker', model: 'gemini-2.5-flash-image' });
+  } catch {}
   const part = j.candidates?.[0]?.content?.parts?.find(p => p.inline_data || p.inlineData);
   const data = part?.inline_data?.data || part?.inlineData?.data;
   if (!data) {

← 4904ff4 closet vision — wire launchd drain + cap to 1 item per singl  ·  back to Whatsmystyle  ·  avatar-build: hook Gemini call into cost-tracker 92b9319 →