Библиотека / Код, Git и инструменты разработчика
Код, Git и инструменты разработчика
Generate AI text and images with Claude and Stripe metered billing
When an API call/webhook arrives, it automates developer work with Claude using Stripe.
Что делает
## AI SaaS Backend (Content Generation + Stripe Billing) A single n8n workflow that acts as the backend for an AI content-generation SaaS. A client app POSTs an API key + generation request to the webhook. n8n resolves the API key to a Stripe customer, checks the customer has an active subscription and hasn't exceeded their plan's usage limit, calls Claude to generate text or image content, records a Stripe usage record against the customer's metered subscription item, and returns the generated content (or a clear error) to the caller synchronously. ### How to set up 1. Import this workflow into n8n 2. Add credentials: Stripe API, Anthropic API (header auth, x-api-key) 3. Edit Set - Config: stripeUsagePriceId (the metered Price your subscription item uses), anthropicModel, planLimits (JSON map of Stripe price/plan id -> monthly generation limit), imageGenEndpoint (if using an external image API instead of Claude) 4. Point your app's API-key lookup at Stripe Customer metadata (this workflow expects customer.metadata.apiKey to match the incoming key) or swap in your own key store 5. Activate the workflow; the webhook URL is your API endpoint ### Requirements - Stripe API access (customers, subscriptions, subscription items, usage records) - Anthropic API access (Claude) for text generation; an image API for image generation ### How to customize - Swap the API-key -> customer lookup for a dedicated auth/DB service if you don't want to store keys in Stripe metadata - Replace the in-memory-per-run usage check with a real usage table (Postgres/Airtable) if you need cross-run accuracy beyond Stripe's own metered usage - Add a queue (instead of synchronous webhook response) for slow image generations - Extend planLimits per price id as you add new pricing tiers
Шаги
- Webhook - Generation Request
- Set - Config
- HTTP Request - Stripe: Find Customer By API Key
- JS - Resolve Customer
- IF - Customer Found
- HTTP Request - Stripe: Get Active Subscription
- JS - Parse Subscription
- HTTP Request - Stripe: Get Current Period Usage
- JS - Check Entitlement
- IF - Entitlement OK
- Switch - Content Type
- HTTP Request - Claude: Generate Text Content
- JS - Parse Text Result
- HTTP Request - Generate Image Content
Всего шагов: 21.
Похожие автоматизации
CRM и воронка продажАудит follow-up продаж и биллинга с HighLevel, Stripe, Gemini и SlackШагов: 19RAG и базы знанийАнализ юридических счетов с Claude RAG и RedisШагов: 10Синхронизация данных и ETLСинхронизация платежей Stripe со сделками Pipedrive по расписаниюШагов: 11Финансы, счета и бухгалтерияПолучение обновлений об активации тарифного плана PayPalШагов: 1