Chargeback Reporting to Internal Teams and Enterprise Customers: PDF, CSV, Invoice Generation
Engineering team burns $4K LLM monthly — which project, feature, engineer's code consumed it? How do you send an AI usage invoice to an enterprise customer? This lesson covers the anatomy of chargeback reporting automation.
Şükrü Yusuf KAYA
16 min read
Intermediate📊 Sayıları masaya koy
Maliyet hesabını yapmak güzel, ama paylaşılmazsa etkisi sıfır. Bu derste ölçtüğün maliyet verisinin doğru paydaşa doğru formatta nasıl ulaştığını görüyoruz.
Raporun Kime Gittiği Önemli#
| Audience | Format | İçerik |
|---|---|---|
| CFO | Aylık PDF | Total cost, trend, top features |
| Engineering manager | Slack weekly digest | Team usage, project breakdown |
| Product manager | Dashboard link | Feature ROI, per-experiment |
| Customer (B2B) | Usage invoice | Token detail, line items |
| Auditor | CSV export | Audit-grade per-call data |
Her birinin farklı bilgi seviyesi ve formatına ihtiyacı var.
CFO için Aylık PDF Raporu#
Aylık otomatik PDF. Şu yapıyı izle:
Sayfa 1: Özet#
- Aylık total cost
- M-o-M değişim
- Y-o-Y değişim
- Hedefin (varsa) yüzdesi
Sayfa 2: Provider breakdown#
- OpenAI: $X
- Anthropic: $Y
- Gemini: $Z
- Self-hosted: $W
Sayfa 3: Top 10 features#
- Smart Search: $4.200
- AI Summary: $3.100
- Agent Workflow: $2.700
- ...
Sayfa 4: Trends & alerts#
- Cache hit ratio trend
- Anormal artışlar (>%30 günlük)
- Budget aşımları
PDF üretimi#
Python ile WeasyPrint kullanarak HTML → PDF:
from weasyprint import HTML from jinja2 import Template def generate_monthly_report(month: str, data: dict): template = Template(open("templates/monthly.html").read()) html_content = template.render(month=month, data=data) HTML(string=html_content).write_pdf(f"reports/{month}-llm-cost.pdf")
Cron job'la her ayın 1'inde otomatik çalış, S3'e upload, CFO'ya email.
Engineering için Slack Weekly Digest#
Mühendisleri haftalık brief'le:
🤖 Haftalık LLM Cost Digest (Hafta 18, 2026) 💰 Toplam harcama: $4.230 (-%8 önceki haftaya göre ✅) 🏆 Top 5 features: 1. Smart Search $1.100 2. AI Summary $890 3. Agent Workflow $620 4. Code Assistant $450 5. Email Draft $310 ⚠️ Bu hafta dikkat: • Smart Search'te cache hit oranı %72 → %58 düştü (anomali) • o3 thinking token kullanımı %40 arttı (planlandı mı?) 📊 Detaylı dashboard: [link]
Slack post otomasyonu#
from slack_sdk import WebClient def post_weekly_digest(): data = fetch_weekly_metrics() blocks = build_slack_blocks(data) client = WebClient(token=SLACK_BOT_TOKEN) client.chat_postMessage( channel="#ai-cost-watch", blocks=blocks, ) # Cron: Her Pazartesi 09:00 TR saati
Kurumsal Müşteri Invoice'u#
B2B müşterine "AI feature usage" line item'ı içeren bir invoice gönderiyorsan, detaylı ve şeffaf olmalı.
Invoice yapısı#
ACME CORP — AI Usage Invoice Period: 2026-04-01 to 2026-04-30 Invoice #: AI-2026-04-ACME ────────────────────────────────────────── LINE ITEMS: ────────────────────────────────────────── Smart Search Feature Requests: 142,300 Total tokens: 12.4M Unit price (per 1K tokens): $0.008 Subtotal: $99.20 AI Summary Feature Requests: 8,200 Total tokens: 5.1M Unit price: $0.012 Subtotal: $61.20 Agent Workflow Sessions: 1,420 Total tokens: 18.6M Unit price: $0.020 Subtotal: $372.00 ────────────────────────────────────────── SUBTOTAL: $532.40 KDV (20%): $106.48 TOTAL: $638.88 ────────────────────────────────────────── Note: Pricing based on actual token usage with 20% margin over our wholesale LLM cost.
Pricing modeli#
Yukarıdaki örnek token-bazlı pass-through + margin modeli. Diğer seçenekler:
| Model | Pros | Cons |
|---|---|---|
| Flat-fee ($X/ay) | Predictable | Power user'da kayıp |
| Tiered (Y) | Balanced | Karmaşık |
| Token pass-through + margin | Şeffaf, kâr garanti | Müşteri için belirsizlik |
| Outcome-based ($X per resolved ticket) | Aligned incentives | Ölçüm zor |
Modül 16'da pricing model derinlemesine.
Auditor için CSV Export#
Compliance / audit için ham veri lazım:
SELECT ts, request_id, tenant_id, user_id, feature, model, provider, input_tokens, cached_input_tokens, output_tokens, cost_total_usd, latency_ms, status_code FROM llm_telemetry.requests WHERE tenant_id = '{tenant_id}' AND ts BETWEEN '{start}' AND '{end}' ORDER BY ts INTO OUTFILE '/exports/audit-{tenant}-{month}.csv' FORMAT CSVWithNames
Audit-friendly fields#
- request_id (idempotency)
- timestamp (exact)
- user_id + tenant_id (attribution)
- model + provider (reproducibility)
- token breakdown (verifiability)
- cost (financial)
- status (compliance)
Privacy considerations#
Prompt content'i default'ta export'a koyma — KVKK riski. Eğer audit isterse, ayrı redaction process'iyle yap.
Automation Stack — Tam Otomasyon#
Production'da chargeback automation:
[ClickHouse] ── Daily cron ──→ [Aggregation views] ↓ [Report generator] ↓ ┌──────────────────────┼──────────────────────┐ ↓ ↓ ↓ [Slack digest] [PDF generator] [Invoice creator] (weekly) (monthly) (monthly) ↓ ↓ [S3 archive] [Stripe API] ↓ ↓ [Email sender] [Customer email]
Cron schedules#
| Job | Schedule | Owner |
|---|---|---|
| Weekly Slack digest | Pazartesi 09:00 | Engineering |
| Monthly PDF (CFO) | Ayın 1'i 06:00 | Finance |
| Monthly invoice (B2B) | Ayın 1'i 10:00 | Billing |
| CSV exports (on-demand) | API endpoint | Audit team |
| Anomaly alerts | 5 dakikada bir | Engineering on-call |
🧪 Lab 4 — Hazırlık
Lab 4 hazırlığı: Mevcut Langfuse hesabında tags filtresi ile 5 feature'ın haftalık maliyetini gösteren bir simple report yarat. CSV export pattern'i ile başla. Bir hafta sonra geri dön, Modül 15'te tam dashboard'a evrilecek.
▶️ Sıradaki ders
4.5 — Abuse Detection: Prompt-Injection-Driven Cost Attacks. Bir kullanıcı sisteminize prompt injection ile saldırdığında maliyetini şişirebilir. Bu derste "cost-based attack vectors", tespit yöntemleri ve mitigation pattern'leri.
Frequently Asked Questions
Both. Token count for transparency (so customers can predict their usage), $ value for simplicity. Pro tip: add a 'usage breakdown' link on the invoice for those who want details. Module 16 covers customer psychology in detail.
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
Related Content
Module 0: Why Cost, Why Now?
The AI Cost Explosion: Why Token Prices Fell 96% from 2022 to 2026 — Yet Bills Grew 40×
Start LearningModule 0: Why Cost, Why Now?
Unit Economics Vocabulary: COGS, Gross Margin, $/User, Contribution Margin — 9 Financial Concepts Every AI Engineer Must Know
Start LearningModule 0: Why Cost, Why Now?