Caching Requests
If you are using Python and you don't have access to the SliceX AI Batch Predictor or SliceX AI Medley, in order to speed up requests faster you can use the Requests-Cache package.
Here is an example:
Caching Requests with Python
import requests_cache
session = requests_cache.CachedSession('demo_cache')
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_SLICEX_AI_API_KEY',
}
for TEXT_TO_CLASSIFY in TEXT_COLLECTION:
body = {
'query': TEXT_TO_CLASSIFY,
}
response = session.post(
'https://api.slicex.ai/predictor/language/pre-trained/customer-review',
headers=headers,
json=body,
)