Weekly Fireworks AI spend recap to Slack and Sheets

By General Input

Every Monday at 9am, log last week's Fireworks AI usage to a Google Sheet and post a top-spend summary to Slack with a week-over-week change.

Integrations

  • Fireworks AI
  • Google Sheets
  • Slack

Type

Deterministic Code

Categories

  • Finance
  • Operations

Build me a deterministic weekly Fireworks AI spend recap as a code workflow. It should run every Monday at 9am in the workspace timezone via a cron trigger, with no manual steps.

Workflow inputs I want exposed: (1) slack_channel — the Slack channel to post the recap in, default #ai-spend; (2) spend_threshold_usd — the weekly total spend above which the message gets flagged with a 🚨 emoji; (3) sheet_id and sheet_tab — the Google Sheet and tab that stores the weekly history, default tab name "Fireworks Weekly Usage"; (4) top_n_models — how many models to highlight in the Slack message, default 3.

Step 1: Call the Fireworks AI "Get Billing Usage" operation for the last 7 days (week ending the previous Sunday in workspace timezone), grouped by model. I want rows that include model name, request count, prompt tokens, completion tokens, and rated cost in USD.

Step 2: Before writing anything new, call the Google Sheets "Get Values" operation on the history tab to read the previous week's total rated cost. Use the most recent week_ending_date row(s) already in the sheet. If the sheet is empty, treat the previous total as null so the workflow handles the very first run cleanly.

Step 3: Use the Google Sheets "Append Values" operation to append one row per model returned in step 1 to the "Fireworks Weekly Usage" tab. Column layout: week_ending_date, model, request_count, prompt_tokens, completion_tokens, rated_cost_usd. Pin this column order — the workflow author must not reshuffle it because step 2 reads it back.

Step 4: In code, compute the summary for Slack: total rated cost this week, the top N models by rated cost (default 3) with their cost and share of total, and the absolute + percent week-over-week change in total cost using the value from step 2 (omit the delta line entirely if the previous total is null). Set a flag boolean = (total cost > spend_threshold_usd).

Step 5: Format a short Slack message (mrkdwn, a few lines, no walls of text). Header line should include the week-ending date and total spend, prefixed with 🚨 if the flag is true. Then a "Top models" section listing the top N as `model — $cost (share%)`. Then a "vs last week" line with the signed dollar and percent change, or omit it on the first run. Send via the Slack "Send a Message" operation to {{slack_channel}}.

Constraints: every step is a known node with structured inputs (fireworks-ai Get Billing Usage, google-sheets Get Values + Append Values, slack Send a Message). No LLM nodes, no agent steps — this is a deterministic code workflow. Fail loudly if Fireworks returns no usage rows for the week so we notice silent breakage instead of posting an empty recap.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageWin back LiveChat visitors whose chats went unansweredLet support send one-off Loops emails without an engineerStop cold emails to anyone with a live deal in PipedriveiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seats