Request to API provider

💡
Before using this API please create API provider
Call the function paywall.makeRequest() or paywall.makeStreamRequest() to make request to created API provider. In search parameters specify paywall_id and test_mode (1 for testing, 0 for live mode).
const response = await paywall.makeRequest("https://onlineapp.pro/api/v1/api-gateway/999?paywall_id=197&test_mode=1", { method: 'POST', // Please check here your provider api request, it can be different body: JSON.stringify({ messages: [], }) })
for await (const chunk of paywall.makeStreamRequest(requestUrl, { method: 'POST', // Please check here your provider api request, it can be different body: JSON.stringify({ messages: [], stream: true }) })) { try { const lines = chunk .split('\n') .filter((line) => line.startsWith('data: ')); lines.forEach((line) => { const data = line.replace('data: ', '').trim(); try { const parsed = JSON.parse(data); // Please check here your provider api response, it can be different setAnswer((prev) => prev + parsed.choices[0].delta.content); } catch (error) { console.error('Failed to parse SSE data:', error); } }); } catch (error) { console.error('Failed to parse SSE data:', error); } }
💡
If the user is not authenticated, these methods return an error: access-denied or Unauthorized.
💡
If users' queries have run out, it will return a not-enough-queries error.