Skip to content

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
İç Ekiplere ve Kurumsal Müşterilere Chargeback Raporlama: PDF, CSV, Invoice Generation
📊 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#

AudienceFormatİçerik
CFOAylık PDFTotal cost, trend, top features
Engineering managerSlack weekly digestTeam usage, project breakdown
Product managerDashboard linkFeature ROI, per-experiment
Customer (B2B)Usage invoiceToken detail, line items
AuditorCSV exportAudit-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
  • ...
  • 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:
ModelProsCons
Flat-fee ($X/ay)PredictablePower user'da kayıp
Tiered (XuptoNrequests,thenX up to N requests, then Y)BalancedKarmaşık
Token pass-through + marginŞeffaf, kâr garantiMüş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#

JobScheduleOwner
Weekly Slack digestPazartesi 09:00Engineering
Monthly PDF (CFO)Ayın 1'i 06:00Finance
Monthly invoice (B2B)Ayın 1'i 10:00Billing
CSV exports (on-demand)API endpointAudit team
Anomaly alerts5 dakikada birEngineering 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