AI Chat with payment for request

Learn how to create an AI chat connected to OpenRouter (Claude AI) with trial requests after user login.
  1. Create paywall. Follow this guide:
  1. Create an API provider to handle tokenized requests:
  1. Enable and set up paywall tokenization:
  1. Now the paywall and API provider are ready.
 
We are planning to use three models of Claude AI: Sonnet, Opus, and Haiku. So, we have created three API providers, one for each model. You can get the API Provider settings for Claude 3 Haiku from the API Provider documentation. In our case, it’s OpenRouter Docs. Because we have different API pricing, we can choose different query price levels. We chose Standard for Haiku and Advanced for Sonnet and Opus. We also specified that 10,000 queries will be deposited into the user’s account after the subscription purchase, and 10 trial requests will be allowed after user login.
notion image
API Provider settings:
notion image

Let’s code