Library / Code, Git & Developer Tools
Code, Git & Developer Tools
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.
What it does
## 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
The steps
- 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 steps in total.
Similar automations
CRM & Sales PipelineAudit sales follow-ups and billing with HighLevel, Stripe, Gemini and Slack19 stepsRAG & Knowledge BasesAnalyze Legal Billing with Claude RAG and Redis10 stepsData Sync & ETLSync Stripe payments into Pipedrive deals on a schedule11 stepsFinance, Invoices & AccountingReceive PayPal Billing Plan Activation Updates1 steps