Tracking AI Spend Per Project With Session Tags
Freelancers and agencies using AI coding agents on client projects face a practical billing question: how much AI cost belongs to each client? Without a way to label sessions by project, AI expenses become overhead that erodes margins. With session tags, they become a pass-through cost or a line item in project estimates.
The Attribution Problem
AI provider billing dashboards show total usage, not per-project breakdowns. Your Anthropic bill says you spent $340 this month. It does not say you spent $180 on the e-commerce client, $120 on the fintech client, and $40 on internal tooling.
Manual attribution means tracking every session start and end, noting the project, and cross-referencing with billing data. This is tedious and error-prone, especially when you switch between projects multiple times per day.
How Styrby Handles This: Tags and Project Paths
Styrby stores two pieces of context for every session: the working directory (project path, auto-detected from where you launched the agent) and tags (a flexible text array you control). Together, these let you attribute costs to clients or projects after the fact.
# Working in /home/dev/clients/acme-ecommerce
styrby connect --agent claude
# → Project path auto-detected: /home/dev/clients/acme-ecommerce
# Add tags for client attribution
styrby connect --agent claude --tags "acme, ecommerce, client-work"Every token cost from that session carries those tags. When you switch to a different project directory and start a new session, the new path is recorded automatically.
Filtering Sessions by Tag
The session history page lets you filter by tags, agent type, date range, and cost. To see all work for a specific client:
| Session | Tags | Agent | Cost | Date |
|---|---|---|---|---|
| Refactor auth module | acme, ecommerce | Claude | $4.30 | Mar 18 |
| Add payment webhooks | acme, ecommerce | Codex | $2.15 | Mar 19 |
| Fix cart edge cases | acme, ecommerce | Claude | $6.80 | Mar 20 |
Filter by the "acme" tag and you can see every session, its cost, and its agent. Add up the costs for that client and you have your attribution number.
Export for Invoicing
Cost data exports to CSV or JSON for inclusion in invoices or expense reports:
# Export monthly costs filtered by tag
styrby costs export --tag acme \
--period 2026-03 \
--format csv \
--output acme-march-2026.csv
# Export all sessions for the month
styrby costs export --period 2026-03 --format jsonThe CSV export includes: date, tags, project path, agent, model, input tokens, output tokens, cache tokens, and total cost. This level of detail lets clients see exactly what they are paying for, which builds trust.
Setting Budget Alerts
When you know a client project has a fixed AI budget, set an alert so you get notified before you exceed it:
# Set a monthly budget alert
styrby budget set \
--period monthly --limit 250 \
--notify-at 80 --stop-at 100Budget alerts apply globally or per agent. Combined with session tags, you can monitor your total spend and then use tag-based filtering to see how much of that spend belongs to each client.
Billing Strategies
How freelancers and agencies handle AI costs varies:
- Pass-through at cost. Bill the exact AI spend to the client. Transparent, but some clients push back on variable costs they do not fully understand.
- Pass-through with markup. Bill AI spend plus 15-25%. Covers your Styrby subscription and the overhead of managing the tools.
- Included in hourly rate. Increase your hourly rate by $5-10 to cover average AI costs. Simpler for clients, but you absorb the risk of expensive sessions.
- Fixed AI budget per project. Estimate AI costs during project scoping and include a line item. Use budget alerts to stay within the estimate.
Regardless of strategy, tagging sessions by client gives you the data you need. You cannot make informed billing decisions without knowing what each engagement actually costs.
When This Matters Most
Cost attribution becomes critical when AI costs are a meaningful percentage of project revenue. If you charge $5,000 for a project and AI costs are $50, tracking is a nice-to-have. If AI costs are $500, that is 10% of revenue and you need to manage it actively.
As AI agents get more capable and developers use them more heavily, per-engagement AI costs will continue to grow. The developers who tag and track this now will have the data and processes in place when it matters even more.
Ready to manage your AI agents from one place?
Styrby gives you cost tracking, remote permissions, and session replay across five agents.