Next.js AI application with Unkey for billing credits
Simple AI image generation application. Contains example code of generating and refilling Unkey API keys in response to a Stripe payment link, and using the `remaining` field for measuring usage.
How to use Unkey to set up billing for your AI application
Example of a generative AI application using Unkey for billing.
- Includes example code to set up Stripe for payment links
- On payment, users are assigned an Unkey API key with the 'remaining' field set to 10, signifying 10 credits
- This cookie is attached to requests to an API route in /api/openai; this API route verifies the key (decrementing
remaining) and requests images from OpenAI.