This API only works with Paywall tokenization enabled.
Before using this API please create API provider
When the API provider request returns
not-enough-queries
, call paywall.renew()
. This function opens the paywall even if the user’s subscription status is active but the query count is 0. This function returns a promise that is resolved when the user pays or rejected if the user closes the paywall.try { for await (const chunk of paywall.makeStreamRequest(requestUrl, { method: 'POST', body: JSON.stringify({ messages: newMessages, stream: true }) })) { // Response processing.. } } catch (error) { if (error === 'not-enough-queries') { try { // Open an paywall to ask user renew subscription await paywall.renew(); // Get user balances after success payment await paywall.getUser(); } catch(error) { // User closed paywall and did not pay } } else if (error === 'Unauthorized' || error === 'access-denied') { await paywall.open(); } }
Â
Read more:
Â