Kütüphane / Finans, Faturalar ve Muhasebe
Finans, Faturalar ve Muhasebe
AI token kullanımını Lago'da ölçün ve ön ödemeli kredi azaldığında uyarın
AI token kullanım verisini webhook ile alır, doğrular, olayı ön ödemeli cüzdanlara karşılık Lago'da kaydeder ve kalan kredi eşiğin altına düştüğünde uyaran bir makbuz döndürür.
Ne yapar
## Meter AI token usage in Lago and warn before credits run out ### How it works This workflow receives AI token usage through a webhook, validates and normalizes the payload, then estimates the Lago fees for the reported usage. For valid requests, it checks the customer’s prepaid wallet, calculates whether remaining credits are below a guardrail threshold, records the usage event in Lago, and returns a metering receipt. It branches the final response to warn when credits are running low, return a healthy receipt otherwise, or return a validation error for invalid input. ### Setup steps - Configure the webhook endpoint and any authentication or signing checks expected by the incoming AI usage producer. - Add Lago credentials in n8n and verify the Lago customer, billable metric, event code, plan, and prepaid wallet identifiers used by the Lago nodes. - Review the custom code nodes so the incoming payload fields, token quantities, customer IDs, and currency assumptions match your application. - Test both valid and invalid requests, plus low-credit and healthy-credit wallet scenarios, to confirm each webhook response path. ### Customization Adjust the credit guardrail threshold, response messages, Lago event metadata, and validation rules to match your pricing model and customer communication style.
Adımlar
- When AI Usage Posted
- Normalize AI Usage Data
- If AI Usage Valid
- Compute Usage Fees
- Total Estimated Fees
- Retrieve Prepaid Wallet
- Determine Credit Level
- Transmit Usage Event
- Create Metering Receipt
- Check Low Credit Alert
- Setup Low Credit Alert
- Send Low Credit Response
- Setup Healthy Credit Response
- Send Healthy Credit Response
Toplam 15 adım.
Benzer otomasyonlar
Finans, Faturalar ve MuhasebeLago tahsilat yeniden denemelerini Data Tables ve SMTP uyarıları ile sınırlı şekilde çalıştır25 adımSosyal Medya YayıncılığıUzun ömürlü Facebook kullanıcı veya sayfa erişim belirteçlerini alma23 adımİzleme, Operasyon ve OlaylarWhatsApp ve Telegram ajanları için yapay zeka token kullanımını izleme25 adımİzleme, Operasyon ve OlaylarGoogle Sheets'te Yapay Zekâ Token Kullanımını ve Maliyetini Takip Etme8 adım