Skip to content

Instantly share code, notes, and snippets.

View cheneeheng's full-sized avatar
🎯
Focusing

EeHeng Chen cheneeheng

🎯
Focusing
  • Munich, Germany
  • 17:24 (UTC +02:00)
View GitHub Profile
#!/bin/bash
input=$(cat)
# --- Extract fields ---
MODEL=$(echo "$input" | jq -r '.model.id')
DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
#PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
# Force UTF-8 output so special characters render correctly
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# Read JSON from stdin
$data = [Console]::In.ReadToEnd() | ConvertFrom-Json
# --- Extract fields ---
$model = $data.model.id
$durationMs = if ($data.cost.total_duration_ms) { $data.cost.total_duration_ms } else { 0 }
$cost = if ($data.cost.total_cost_usd) { $data.cost.total_cost_usd } else { 0 }