Shaankar39 commited on
Commit
387d030
Β·
verified Β·
1 Parent(s): ed6c66c

Add examples/: connector docs, OpenAPI for new endpoints, Hub listing copy, Stripe test script

Browse files
examples/README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RevAI β€” POST request examples
2
+
3
+ All POST endpoints require header `Content-Type: application/json` (except
4
+ `/v1/analyze/call*`, which is multipart). Gateway also injects auth headers.
5
+
6
+ ## /v1/predict/churn (JSON)
7
+ {"data":[{"customer_id":"C1","tenure_days":45,"days_since_last_login":18,"login_frequency_7d":1,"payment_delays_90d":2,"support_tickets_last_30d":4,"contract_type":"Month-to-Month","nps_score":3,"feature_adoption_score":45,"avg_session_minutes":8}]}
8
+
9
+ ## /v1/predict/lead (JSON)
10
+ {"data":[{"lead_id":"L1","demo_requested":1,"budget_confirmed":1,"engagement_score":80,"source":"referral"}]}
11
+
12
+ ## /v1/train (JSON, >=50 rows) -> see train_body.json
13
+ {"data":[ ...>=50 rows, each with feature cols + a 0/1 label col... ],
14
+ "target_column":"churned","model_type":"churn","model_name":"my-model"}
15
+
16
+ ## /v1/analyze/call (multipart/form-data, NOT json)
17
+ Fields:
18
+ file = <audio file: .mp3 .wav .m4a .mp4 .ogg .webm>
19
+ openai_api_key = sk-... (caller supplies their own OpenAI key for Whisper)
20
+ curl example:
21
+ curl -X POST https://revai1.p.rapidapi.com/v1/analyze/call \
22
+ -H "X-RapidAPI-Host: revai1.p.rapidapi.com" \
23
+ -H "X-RapidAPI-Key: <KEY>" \
24
+ -F "file=@call.mp3" \
25
+ -F "openai_api_key=sk-..."
26
+
27
+ ## /v1/predict/csv (multipart β€” upload a spreadsheet, no JSON needed)
28
+ The friction-killer. One column per signal, one row per customer/lead.
29
+ Fields:
30
+ file = your .csv export (see sample_customers.csv)
31
+ model_type = churn | lead (default churn)
32
+ model_id = <optional trained model id>
33
+ curl:
34
+ curl -X POST https://revai1.p.rapidapi.com/v1/predict/csv \
35
+ -H "X-RapidAPI-Host: revai1.p.rapidapi.com" -H "X-RapidAPI-Key: <KEY>" \
36
+ -F "file=@customers.csv" -F "model_type=churn"
37
+ Blank cells are fine (we use sensible defaults). Returns the same scored
38
+ JSON as /v1/predict/churn β€” score, risk level, and the reasons.
39
+
40
+ NOTE: RapidAPI's gateway only forwards endpoints you've DEFINED in the API.
41
+ Add /v1/predict/csv to the RapidAPI endpoint list or the gateway returns 404.
42
+
43
+ ## /v1/connect/stripe (JSON β€” paste a read-only Stripe key, auto-score customers)
44
+ No data prep at all. We pull the caller's recent Stripe customers and derive
45
+ churn signals from billing: tenure, payment delays (90d), subscription status
46
+ (past_due / canceled fire strong rules), contract type, monthly spend.
47
+ The key is used in-memory and NEVER stored. RevAI pays Stripe nothing.
48
+ Body:
49
+ {"stripe_key":"rk_live_...", "limit":100, "model_type":"churn", "model_id":null}
50
+ curl:
51
+ curl -X POST https://revai1.p.rapidapi.com/v1/connect/stripe \
52
+ -H "X-RapidAPI-Host: revai1.p.rapidapi.com" -H "X-RapidAPI-Key: <KEY>" \
53
+ -H "Content-Type: application/json" \
54
+ -d '{"stripe_key":"rk_live_...","limit":100}'
55
+ Tell customers to use a RESTRICTED key (read-only: Customers, Invoices,
56
+ Subscriptions). Returns the same scored JSON as /v1/predict/churn.
57
+
58
+ NOTE: like every endpoint, add /v1/connect/stripe to your RapidAPI endpoint
59
+ list or the gateway returns 404.
60
+
61
+ ## /v1/predict/smart (JSON β€” UNIVERSAL connector, send ANY column names)
62
+ The real friction-killer. You don't need our exact field names. Send your rows
63
+ as-is; we auto-detect columns (last_seen -> days_since_last_login, signup_date
64
+ -> tenure_days, plan -> contract_type, ...) and even derive durations from
65
+ dates. Response includes a `field_mapping` report (matched / missing / ignored)
66
+ so it's fully transparent.
67
+ Body:
68
+ {"data":[{"account_id":"ACME","signup_date":"2024-01-10","last_seen":"2026-05-10",
69
+ "plan":"Monthly","missed_payments":3,"nps":2}],
70
+ "model_type":"churn",
71
+ "mapping": {"tenure_days":"signup_date"} // OPTIONAL explicit overrides
72
+ }
73
+ Auto-derives: signup/created dates -> tenure_days; last-login dates ->
74
+ days_since_last_login; pipeline-entry dates -> days_in_pipeline.
75
+ This is the recommended entry point for most customers β€” it makes Stripe/CSV/
76
+ HubSpot/raw exports all "just work".
examples/hub_listing_docs.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RevAI β€” Hub Listing copy (paste into RapidAPI description / endpoint docs)
2
+
3
+ > Explainable churn prediction & lead scoring. Send your customer data β€” by
4
+ > spreadsheet, raw JSON, or a one-click Stripe connect β€” and get a risk score
5
+ > **with the reasons behind it**, plus optional custom models trained on your
6
+ > own data.
7
+
8
+ ## Quick start (most users): /v1/predict/smart
9
+ Send rows with **whatever column names you already have** β€” we auto-map them.
10
+ All POSTs require `Content-Type: application/json`.
11
+
12
+ ```
13
+ POST /v1/predict/smart
14
+ Content-Type: application/json
15
+
16
+ {"data":[
17
+ {"account_id":"ACME","signup_date":"2024-01-10","last_seen":"2026-05-10",
18
+ "plan":"Monthly","missed_payments":3,"nps":2}
19
+ ],"model_type":"churn"}
20
+ ```
21
+ Returns each row scored (0–100), a risk level, the **reasons**, and a
22
+ `field_mapping` report showing which of your columns mapped to which signal.
23
+
24
+ ## Upload a spreadsheet: /v1/predict/csv (multipart)
25
+ ```
26
+ POST /v1/predict/csv (multipart/form-data)
27
+ file=@customers.csv model_type=churn
28
+ ```
29
+
30
+ ## Connect Stripe: /v1/connect/stripe
31
+ Paste a **restricted, read-only** Stripe key; we derive churn signals from
32
+ billing (tenure, payment delays, subscription status). Key is never stored.
33
+ ```
34
+ POST /v1/connect/stripe
35
+ Content-Type: application/json
36
+ {"stripe_key":"rk_live_...","limit":100,"model_type":"churn"}
37
+ ```
38
+
39
+ ## Classic (exact fields): /v1/predict/churn and /v1/predict/lead
40
+ ```
41
+ POST /v1/predict/churn
42
+ Content-Type: application/json
43
+ {"data":[{"customer_id":"C1","tenure_days":45,"days_since_last_login":18,
44
+ "login_frequency_7d":1,"payment_delays_90d":2,"support_tickets_last_30d":4,
45
+ "contract_type":"Month-to-Month","nps_score":3,"feature_adoption_score":45,
46
+ "avg_session_minutes":8}]}
47
+ ```
48
+ ```
49
+ POST /v1/predict/lead
50
+ Content-Type: application/json
51
+ {"data":[{"lead_id":"L1","demo_requested":1,"budget_confirmed":1,
52
+ "engagement_score":80,"source":"referral"}]}
53
+ ```
54
+
55
+ ## Train a custom model: /v1/train (β‰₯50 labeled rows)
56
+ ```
57
+ POST /v1/train
58
+ Content-Type: application/json
59
+ {"data":[ /* β‰₯50 rows, each with features + a 0/1 label */ ],
60
+ "target_column":"churned","model_type":"churn","model_name":"my-model"}
61
+ ```
62
+ Then pass the returned `model_id` to any predict endpoint to use your model.
63
+
64
+ ## Analyze a support call: /v1/analyze/call (multipart)
65
+ ```
66
+ POST /v1/analyze/call (multipart/form-data)
67
+ file=@call.mp3 openai_api_key=sk-... # you supply your own OpenAI key
68
+ ```
69
+
70
+ ---
71
+ **Common mistake:** a POST with no body returns `422 Field required`. That's
72
+ expected β€” the API needs your data. Always send the JSON body (and the
73
+ `Content-Type: application/json` header).
examples/new_endpoints.openapi.json ADDED
@@ -0,0 +1,469 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "RevAI API \u2014 new connector endpoints",
5
+ "version": "1.0.0"
6
+ },
7
+ "servers": [
8
+ {
9
+ "url": "https://shaankar39-revai-api.hf.space"
10
+ }
11
+ ],
12
+ "paths": {
13
+ "/v1/predict/smart": {
14
+ "post": {
15
+ "tags": [
16
+ "Prediction"
17
+ ],
18
+ "summary": "Predict Smart",
19
+ "description": "Universal connector \u2014 send rows with ANY column names. We auto-map them\nto RevAI's signals (and derive durations from dates), then score. The\nresponse includes a `field_mapping` report of what was matched/missed.",
20
+ "operationId": "predict_smart_v1_predict_smart_post",
21
+ "requestBody": {
22
+ "content": {
23
+ "application/json": {
24
+ "schema": {
25
+ "$ref": "#/components/schemas/SmartPredictInput"
26
+ }
27
+ }
28
+ },
29
+ "required": true
30
+ },
31
+ "responses": {
32
+ "200": {
33
+ "description": "Successful Response",
34
+ "content": {
35
+ "application/json": {
36
+ "schema": {
37
+ "$ref": "#/components/schemas/PredictionResponse"
38
+ }
39
+ }
40
+ }
41
+ },
42
+ "422": {
43
+ "description": "Validation Error",
44
+ "content": {
45
+ "application/json": {
46
+ "schema": {
47
+ "$ref": "#/components/schemas/HTTPValidationError"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "security": [
54
+ {
55
+ "APIKeyHeader": []
56
+ }
57
+ ]
58
+ }
59
+ },
60
+ "/v1/predict/csv": {
61
+ "post": {
62
+ "tags": [
63
+ "Prediction"
64
+ ],
65
+ "summary": "Predict Csv",
66
+ "description": "Upload a CSV instead of hand-building JSON. One column per signal,\none row per customer/lead \u2014 we parse it and score every row.",
67
+ "operationId": "predict_csv_v1_predict_csv_post",
68
+ "requestBody": {
69
+ "content": {
70
+ "multipart/form-data": {
71
+ "schema": {
72
+ "$ref": "#/components/schemas/Body_predict_csv_v1_predict_csv_post"
73
+ }
74
+ }
75
+ },
76
+ "required": true
77
+ },
78
+ "responses": {
79
+ "200": {
80
+ "description": "Successful Response",
81
+ "content": {
82
+ "application/json": {
83
+ "schema": {
84
+ "$ref": "#/components/schemas/PredictionResponse"
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "422": {
90
+ "description": "Validation Error",
91
+ "content": {
92
+ "application/json": {
93
+ "schema": {
94
+ "$ref": "#/components/schemas/HTTPValidationError"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "security": [
101
+ {
102
+ "APIKeyHeader": []
103
+ }
104
+ ]
105
+ }
106
+ },
107
+ "/v1/connect/stripe": {
108
+ "post": {
109
+ "tags": [
110
+ "connectors"
111
+ ],
112
+ "summary": "Connect Stripe",
113
+ "description": "Paste a read-only Stripe key \u2192 we pull your recent customers, derive\nbilling-based churn signals (tenure, payment delays, subscription status,\ncontract type), and score them. The key is used in-memory and never stored.",
114
+ "operationId": "connect_stripe_v1_connect_stripe_post",
115
+ "requestBody": {
116
+ "content": {
117
+ "application/json": {
118
+ "schema": {
119
+ "$ref": "#/components/schemas/StripeConnectInput"
120
+ }
121
+ }
122
+ },
123
+ "required": true
124
+ },
125
+ "responses": {
126
+ "200": {
127
+ "description": "Successful Response",
128
+ "content": {
129
+ "application/json": {
130
+ "schema": {
131
+ "$ref": "#/components/schemas/PredictionResponse"
132
+ }
133
+ }
134
+ }
135
+ },
136
+ "422": {
137
+ "description": "Validation Error",
138
+ "content": {
139
+ "application/json": {
140
+ "schema": {
141
+ "$ref": "#/components/schemas/HTTPValidationError"
142
+ }
143
+ }
144
+ }
145
+ }
146
+ },
147
+ "security": [
148
+ {
149
+ "APIKeyHeader": []
150
+ }
151
+ ]
152
+ }
153
+ }
154
+ },
155
+ "components": {
156
+ "schemas": {
157
+ "Body_predict_csv_v1_predict_csv_post": {
158
+ "properties": {
159
+ "file": {
160
+ "type": "string",
161
+ "contentMediaType": "application/octet-stream",
162
+ "title": "File",
163
+ "description": "CSV export of your customers/leads"
164
+ },
165
+ "model_type": {
166
+ "type": "string",
167
+ "title": "Model Type",
168
+ "description": "'churn' or 'lead'",
169
+ "default": "churn"
170
+ },
171
+ "model_id": {
172
+ "type": "string",
173
+ "title": "Model Id",
174
+ "description": "Optional trained model ID"
175
+ }
176
+ },
177
+ "type": "object",
178
+ "required": [
179
+ "file"
180
+ ],
181
+ "title": "Body_predict_csv_v1_predict_csv_post"
182
+ },
183
+ "HTTPValidationError": {
184
+ "properties": {
185
+ "detail": {
186
+ "items": {
187
+ "$ref": "#/components/schemas/ValidationError"
188
+ },
189
+ "type": "array",
190
+ "title": "Detail"
191
+ }
192
+ },
193
+ "type": "object",
194
+ "title": "HTTPValidationError"
195
+ },
196
+ "PredictionResponse": {
197
+ "properties": {
198
+ "predictions": {
199
+ "items": {
200
+ "$ref": "#/components/schemas/SinglePrediction"
201
+ },
202
+ "type": "array",
203
+ "title": "Predictions"
204
+ },
205
+ "model_used": {
206
+ "type": "string",
207
+ "title": "Model Used"
208
+ },
209
+ "usage": {
210
+ "additionalProperties": true,
211
+ "type": "object",
212
+ "title": "Usage"
213
+ },
214
+ "benchmark": {
215
+ "anyOf": [
216
+ {
217
+ "additionalProperties": true,
218
+ "type": "object"
219
+ },
220
+ {
221
+ "type": "null"
222
+ }
223
+ ],
224
+ "title": "Benchmark"
225
+ },
226
+ "field_mapping": {
227
+ "anyOf": [
228
+ {
229
+ "additionalProperties": true,
230
+ "type": "object"
231
+ },
232
+ {
233
+ "type": "null"
234
+ }
235
+ ],
236
+ "title": "Field Mapping"
237
+ }
238
+ },
239
+ "type": "object",
240
+ "required": [
241
+ "predictions",
242
+ "model_used",
243
+ "usage"
244
+ ],
245
+ "title": "PredictionResponse"
246
+ },
247
+ "RiskFactor": {
248
+ "properties": {
249
+ "rule": {
250
+ "type": "string",
251
+ "title": "Rule"
252
+ },
253
+ "points": {
254
+ "type": "integer",
255
+ "title": "Points"
256
+ },
257
+ "detail": {
258
+ "type": "string",
259
+ "title": "Detail"
260
+ }
261
+ },
262
+ "type": "object",
263
+ "required": [
264
+ "rule",
265
+ "points",
266
+ "detail"
267
+ ],
268
+ "title": "RiskFactor"
269
+ },
270
+ "SinglePrediction": {
271
+ "properties": {
272
+ "index": {
273
+ "type": "integer",
274
+ "title": "Index"
275
+ },
276
+ "score": {
277
+ "type": "number",
278
+ "title": "Score"
279
+ },
280
+ "risk_level": {
281
+ "type": "string",
282
+ "title": "Risk Level"
283
+ },
284
+ "recommended_action": {
285
+ "anyOf": [
286
+ {
287
+ "type": "string"
288
+ },
289
+ {
290
+ "type": "null"
291
+ }
292
+ ],
293
+ "title": "Recommended Action"
294
+ },
295
+ "risk_factors": {
296
+ "items": {
297
+ "$ref": "#/components/schemas/RiskFactor"
298
+ },
299
+ "type": "array",
300
+ "title": "Risk Factors",
301
+ "default": []
302
+ },
303
+ "scoring_mode": {
304
+ "type": "string",
305
+ "title": "Scoring Mode"
306
+ },
307
+ "customer_id": {
308
+ "anyOf": [
309
+ {
310
+ "type": "string"
311
+ },
312
+ {
313
+ "type": "null"
314
+ }
315
+ ],
316
+ "title": "Customer Id"
317
+ },
318
+ "input_fields": {
319
+ "additionalProperties": true,
320
+ "type": "object",
321
+ "title": "Input Fields",
322
+ "default": {}
323
+ }
324
+ },
325
+ "type": "object",
326
+ "required": [
327
+ "index",
328
+ "score",
329
+ "risk_level",
330
+ "scoring_mode"
331
+ ],
332
+ "title": "SinglePrediction"
333
+ },
334
+ "SmartPredictInput": {
335
+ "properties": {
336
+ "data": {
337
+ "items": {
338
+ "additionalProperties": true,
339
+ "type": "object"
340
+ },
341
+ "type": "array",
342
+ "maxItems": 1000,
343
+ "minItems": 1,
344
+ "title": "Data",
345
+ "description": "Your rows with WHATEVER column names you already have"
346
+ },
347
+ "mapping": {
348
+ "anyOf": [
349
+ {
350
+ "additionalProperties": {
351
+ "type": "string"
352
+ },
353
+ "type": "object"
354
+ },
355
+ {
356
+ "type": "null"
357
+ }
358
+ ],
359
+ "title": "Mapping",
360
+ "description": "Optional {canonical_signal: your_column} overrides; auto-detected otherwise"
361
+ },
362
+ "model_type": {
363
+ "type": "string",
364
+ "title": "Model Type",
365
+ "description": "'churn' or 'lead'",
366
+ "default": "churn"
367
+ },
368
+ "model_id": {
369
+ "anyOf": [
370
+ {
371
+ "type": "string"
372
+ },
373
+ {
374
+ "type": "null"
375
+ }
376
+ ],
377
+ "title": "Model Id",
378
+ "description": "Optional trained model ID"
379
+ }
380
+ },
381
+ "type": "object",
382
+ "required": [
383
+ "data"
384
+ ],
385
+ "title": "SmartPredictInput"
386
+ },
387
+ "StripeConnectInput": {
388
+ "properties": {
389
+ "stripe_key": {
390
+ "type": "string",
391
+ "title": "Stripe Key",
392
+ "description": "Your restricted, read-only Stripe key (rk_live_\u2026 or sk_\u2026)"
393
+ },
394
+ "limit": {
395
+ "type": "integer",
396
+ "maximum": 100.0,
397
+ "minimum": 1.0,
398
+ "title": "Limit",
399
+ "description": "How many recent customers to score",
400
+ "default": 100
401
+ },
402
+ "model_type": {
403
+ "type": "string",
404
+ "title": "Model Type",
405
+ "description": "'churn' or 'lead'",
406
+ "default": "churn"
407
+ },
408
+ "model_id": {
409
+ "anyOf": [
410
+ {
411
+ "type": "string"
412
+ },
413
+ {
414
+ "type": "null"
415
+ }
416
+ ],
417
+ "title": "Model Id",
418
+ "description": "Optional trained model ID"
419
+ }
420
+ },
421
+ "type": "object",
422
+ "required": [
423
+ "stripe_key"
424
+ ],
425
+ "title": "StripeConnectInput"
426
+ },
427
+ "ValidationError": {
428
+ "properties": {
429
+ "loc": {
430
+ "items": {
431
+ "anyOf": [
432
+ {
433
+ "type": "string"
434
+ },
435
+ {
436
+ "type": "integer"
437
+ }
438
+ ]
439
+ },
440
+ "type": "array",
441
+ "title": "Location"
442
+ },
443
+ "msg": {
444
+ "type": "string",
445
+ "title": "Message"
446
+ },
447
+ "type": {
448
+ "type": "string",
449
+ "title": "Error Type"
450
+ },
451
+ "input": {
452
+ "title": "Input"
453
+ },
454
+ "ctx": {
455
+ "type": "object",
456
+ "title": "Context"
457
+ }
458
+ },
459
+ "type": "object",
460
+ "required": [
461
+ "loc",
462
+ "msg",
463
+ "type"
464
+ ],
465
+ "title": "ValidationError"
466
+ }
467
+ }
468
+ }
469
+ }
examples/rapidapi_setup.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RapidAPI β€” add the 3 new connector endpoints
2
+
3
+ The gateway only forwards endpoints defined in your RapidAPI API. Add these so
4
+ buyers can reach them. Two ways:
5
+
6
+ ## Option A (fastest): re-import the OpenAPI
7
+ RapidAPI Provider β†’ your API β†’ **Definitions / Import** β†’ import from URL:
8
+ https://shaankar39-revai-api.hf.space/openapi.json
9
+ This already contains ALL endpoints (old + new). Or upload the trimmed file
10
+ `new_endpoints.openapi.json` (just the 3 new ones).
11
+
12
+ ## Option B: add each manually
13
+ Provider β†’ your API β†’ **Endpoints β†’ Create REST Endpoint**.
14
+
15
+ ### 1) Universal connector (recommended default)
16
+ - Name: Predict Smart
17
+ - Method: **POST**
18
+ - Path: **/v1/predict/smart**
19
+ - Header: `Content-Type: application/json`
20
+ - Body (JSON):
21
+ {"data":[{"account_id":"ACME","signup_date":"2024-01-10","last_seen":"2026-05-10","plan":"Monthly","missed_payments":3,"nps":2}],"model_type":"churn"}
22
+
23
+ ### 2) CSV upload
24
+ - Name: Predict CSV
25
+ - Method: **POST**
26
+ - Path: **/v1/predict/csv**
27
+ - Body type: **multipart/form-data**, fields:
28
+ file (type: file) β€” the customer's CSV
29
+ model_type (type: text) β€” "churn" or "lead"
30
+ model_id (type: text, optional)
31
+
32
+ ### 3) Stripe connector
33
+ - Name: Connect Stripe
34
+ - Method: **POST**
35
+ - Path: **/v1/connect/stripe**
36
+ - Header: `Content-Type: application/json`
37
+ - Body (JSON):
38
+ {"stripe_key":"rk_live_...","limit":100,"model_type":"churn"}
39
+
40
+ After adding, hit **Send** on each in Studio to confirm 200 (the smart/csv ones
41
+ work immediately; stripe needs a real read-only key).
examples/sample_customers.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ customer_id,tenure_days,days_since_last_login,login_frequency_7d,payment_delays_90d,support_tickets_last_30d,contract_type,nps_score,feature_adoption_score,avg_session_minutes
2
+ C1,45,18,1,2,4,Month-to-Month,3,45,8
3
+ C2,720,1,12,0,0,Annual,9,88,40
4
+ C3,30,25,0,3,6,Month-to-Month,2,20,3
examples/test_stripe.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Smoke-test the Stripe connector with YOUR Stripe test key.
3
+ # Usage: ./test_stripe.sh rk_test_xxx [limit]
4
+ #
5
+ # Use a RESTRICTED, READ-ONLY test-mode key (Stripe Dashboard β†’ Developers β†’
6
+ # API keys β†’ Create restricted key β†’ read access: Customers, Invoices,
7
+ # Subscriptions). Make sure your Stripe TEST account has a couple of customers.
8
+ # The key is sent to the live Space over HTTPS, used in-memory, and not stored.
9
+
10
+ set -euo pipefail
11
+ KEY="${1:?Pass your Stripe test key: ./test_stripe.sh rk_test_xxx [limit]}"
12
+ LIMIT="${2:-25}"
13
+ BASE="https://shaankar39-revai-api.hf.space"
14
+
15
+ # These two headers simulate the RapidAPI gateway. For a real gateway call,
16
+ # use your RapidAPI key against revai1.p.rapidapi.com instead.
17
+ curl -s -m60 \
18
+ -H "X-RapidAPI-User: stripe-smoke" \
19
+ -H "X-RapidAPI-Proxy-Secret: ${REVAI_PROXY_SECRET:?export REVAI_PROXY_SECRET=<your gateway proxy secret>}" \
20
+ -H "Content-Type: application/json" \
21
+ -X POST "$BASE/v1/connect/stripe" \
22
+ -d "{\"stripe_key\":\"$KEY\",\"limit\":$LIMIT,\"model_type\":\"churn\"}" \
23
+ | python3 -m json.tool
examples/train_body.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"data": [{"tenure_days": 761, "days_since_last_login": 1, "login_frequency_7d": 6, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 73, "avg_session_minutes": 53, "churned": 0}, {"tenure_days": 610, "days_since_last_login": 1, "login_frequency_7d": 9, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 70, "avg_session_minutes": 21, "churned": 0}, {"tenure_days": 14, "days_since_last_login": 21, "login_frequency_7d": 2, "payment_delays_90d": 5, "support_tickets_last_30d": 4, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 14, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 526, "days_since_last_login": 0, "login_frequency_7d": 17, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 87, "avg_session_minutes": 49, "churned": 0}, {"tenure_days": 29, "days_since_last_login": 25, "login_frequency_7d": 0, "payment_delays_90d": 3, "support_tickets_last_30d": 5, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 27, "avg_session_minutes": 6, "churned": 1}, {"tenure_days": 33, "days_since_last_login": 23, "login_frequency_7d": 2, "payment_delays_90d": 2, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 30, "avg_session_minutes": 1, "churned": 1}, {"tenure_days": 678, "days_since_last_login": 1, "login_frequency_7d": 17, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 75, "avg_session_minutes": 34, "churned": 0}, {"tenure_days": 486, "days_since_last_login": 3, "login_frequency_7d": 10, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 81, "avg_session_minutes": 48, "churned": 0}, {"tenure_days": 54, "days_since_last_login": 17, "login_frequency_7d": 1, "payment_delays_90d": 5, "support_tickets_last_30d": 6, "contract_type": "Month-to-Month", "nps_score": 3, "feature_adoption_score": 22, "avg_session_minutes": 1, "churned": 1}, {"tenure_days": 64, "days_since_last_login": 22, "login_frequency_7d": 1, "payment_delays_90d": 5, "support_tickets_last_30d": 4, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 13, "avg_session_minutes": 5, "churned": 1}, {"tenure_days": 630, "days_since_last_login": 1, "login_frequency_7d": 14, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 70, "avg_session_minutes": 48, "churned": 0}, {"tenure_days": 615, "days_since_last_login": 1, "login_frequency_7d": 14, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Two-Year", "nps_score": 9, "feature_adoption_score": 72, "avg_session_minutes": 37, "churned": 0}, {"tenure_days": 240, "days_since_last_login": 1, "login_frequency_7d": 10, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 96, "avg_session_minutes": 36, "churned": 0}, {"tenure_days": 362, "days_since_last_login": 1, "login_frequency_7d": 8, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 98, "avg_session_minutes": 49, "churned": 0}, {"tenure_days": 264, "days_since_last_login": 3, "login_frequency_7d": 11, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 9, "feature_adoption_score": 84, "avg_session_minutes": 52, "churned": 0}, {"tenure_days": 871, "days_since_last_login": 1, "login_frequency_7d": 15, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Two-Year", "nps_score": 9, "feature_adoption_score": 74, "avg_session_minutes": 55, "churned": 0}, {"tenure_days": 323, "days_since_last_login": 0, "login_frequency_7d": 11, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 71, "avg_session_minutes": 35, "churned": 0}, {"tenure_days": 32, "days_since_last_login": 24, "login_frequency_7d": 2, "payment_delays_90d": 2, "support_tickets_last_30d": 6, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 16, "avg_session_minutes": 3, "churned": 1}, {"tenure_days": 746, "days_since_last_login": 3, "login_frequency_7d": 14, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 98, "avg_session_minutes": 36, "churned": 0}, {"tenure_days": 772, "days_since_last_login": 1, "login_frequency_7d": 19, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 73, "avg_session_minutes": 45, "churned": 0}, {"tenure_days": 19, "days_since_last_login": 30, "login_frequency_7d": 1, "payment_delays_90d": 4, "support_tickets_last_30d": 6, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 13, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 14, "days_since_last_login": 17, "login_frequency_7d": 2, "payment_delays_90d": 3, "support_tickets_last_30d": 6, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 23, "avg_session_minutes": 3, "churned": 1}, {"tenure_days": 876, "days_since_last_login": 0, "login_frequency_7d": 20, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Two-Year", "nps_score": 8, "feature_adoption_score": 85, "avg_session_minutes": 31, "churned": 0}, {"tenure_days": 652, "days_since_last_login": 2, "login_frequency_7d": 7, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 76, "avg_session_minutes": 39, "churned": 0}, {"tenure_days": 44, "days_since_last_login": 20, "login_frequency_7d": 1, "payment_delays_90d": 2, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 29, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 265, "days_since_last_login": 0, "login_frequency_7d": 20, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 78, "avg_session_minutes": 37, "churned": 0}, {"tenure_days": 466, "days_since_last_login": 0, "login_frequency_7d": 15, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 97, "avg_session_minutes": 27, "churned": 0}, {"tenure_days": 47, "days_since_last_login": 17, "login_frequency_7d": 2, "payment_delays_90d": 3, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 23, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 365, "days_since_last_login": 3, "login_frequency_7d": 14, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 76, "avg_session_minutes": 42, "churned": 0}, {"tenure_days": 258, "days_since_last_login": 1, "login_frequency_7d": 12, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 90, "avg_session_minutes": 25, "churned": 0}, {"tenure_days": 39, "days_since_last_login": 44, "login_frequency_7d": 1, "payment_delays_90d": 4, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 13, "avg_session_minutes": 6, "churned": 1}, {"tenure_days": 17, "days_since_last_login": 35, "login_frequency_7d": 2, "payment_delays_90d": 2, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 28, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 651, "days_since_last_login": 0, "login_frequency_7d": 12, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 79, "avg_session_minutes": 52, "churned": 0}, {"tenure_days": 387, "days_since_last_login": 0, "login_frequency_7d": 18, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 85, "avg_session_minutes": 59, "churned": 0}, {"tenure_days": 557, "days_since_last_login": 2, "login_frequency_7d": 7, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 85, "avg_session_minutes": 32, "churned": 0}, {"tenure_days": 54, "days_since_last_login": 30, "login_frequency_7d": 2, "payment_delays_90d": 4, "support_tickets_last_30d": 4, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 34, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 52, "days_since_last_login": 28, "login_frequency_7d": 0, "payment_delays_90d": 5, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 18, "avg_session_minutes": 3, "churned": 1}, {"tenure_days": 53, "days_since_last_login": 42, "login_frequency_7d": 1, "payment_delays_90d": 5, "support_tickets_last_30d": 8, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 10, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 325, "days_since_last_login": 1, "login_frequency_7d": 17, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 98, "avg_session_minutes": 28, "churned": 0}, {"tenure_days": 262, "days_since_last_login": 2, "login_frequency_7d": 20, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Two-Year", "nps_score": 10, "feature_adoption_score": 96, "avg_session_minutes": 53, "churned": 0}, {"tenure_days": 499, "days_since_last_login": 1, "login_frequency_7d": 18, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 83, "avg_session_minutes": 28, "churned": 0}, {"tenure_days": 10, "days_since_last_login": 23, "login_frequency_7d": 1, "payment_delays_90d": 4, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 20, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 70, "days_since_last_login": 31, "login_frequency_7d": 1, "payment_delays_90d": 2, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 30, "avg_session_minutes": 5, "churned": 1}, {"tenure_days": 31, "days_since_last_login": 36, "login_frequency_7d": 2, "payment_delays_90d": 5, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 3, "feature_adoption_score": 12, "avg_session_minutes": 1, "churned": 1}, {"tenure_days": 50, "days_since_last_login": 17, "login_frequency_7d": 2, "payment_delays_90d": 5, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 11, "avg_session_minutes": 5, "churned": 1}, {"tenure_days": 35, "days_since_last_login": 31, "login_frequency_7d": 0, "payment_delays_90d": 5, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 2, "feature_adoption_score": 32, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 36, "days_since_last_login": 16, "login_frequency_7d": 2, "payment_delays_90d": 2, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 35, "avg_session_minutes": 3, "churned": 1}, {"tenure_days": 39, "days_since_last_login": 43, "login_frequency_7d": 1, "payment_delays_90d": 4, "support_tickets_last_30d": 4, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 32, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 18, "days_since_last_login": 29, "login_frequency_7d": 1, "payment_delays_90d": 5, "support_tickets_last_30d": 6, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 15, "avg_session_minutes": 4, "churned": 1}, {"tenure_days": 395, "days_since_last_login": 2, "login_frequency_7d": 6, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Two-Year", "nps_score": 9, "feature_adoption_score": 87, "avg_session_minutes": 21, "churned": 0}, {"tenure_days": 545, "days_since_last_login": 1, "login_frequency_7d": 13, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 10, "feature_adoption_score": 81, "avg_session_minutes": 25, "churned": 0}, {"tenure_days": 14, "days_since_last_login": 29, "login_frequency_7d": 0, "payment_delays_90d": 5, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 13, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 15, "days_since_last_login": 33, "login_frequency_7d": 2, "payment_delays_90d": 5, "support_tickets_last_30d": 5, "contract_type": "Month-to-Month", "nps_score": 3, "feature_adoption_score": 19, "avg_session_minutes": 5, "churned": 1}, {"tenure_days": 342, "days_since_last_login": 3, "login_frequency_7d": 19, "payment_delays_90d": 0, "support_tickets_last_30d": 0, "contract_type": "Annual", "nps_score": 8, "feature_adoption_score": 78, "avg_session_minutes": 33, "churned": 0}, {"tenure_days": 32, "days_since_last_login": 38, "login_frequency_7d": 0, "payment_delays_90d": 3, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 14, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 31, "days_since_last_login": 30, "login_frequency_7d": 1, "payment_delays_90d": 3, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 0, "feature_adoption_score": 16, "avg_session_minutes": 5, "churned": 1}, {"tenure_days": 644, "days_since_last_login": 2, "login_frequency_7d": 7, "payment_delays_90d": 0, "support_tickets_last_30d": 1, "contract_type": "Annual", "nps_score": 9, "feature_adoption_score": 93, "avg_session_minutes": 25, "churned": 0}, {"tenure_days": 40, "days_since_last_login": 39, "login_frequency_7d": 0, "payment_delays_90d": 3, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 24, "avg_session_minutes": 2, "churned": 1}, {"tenure_days": 30, "days_since_last_login": 23, "login_frequency_7d": 1, "payment_delays_90d": 2, "support_tickets_last_30d": 3, "contract_type": "Month-to-Month", "nps_score": 4, "feature_adoption_score": 13, "avg_session_minutes": 3, "churned": 1}, {"tenure_days": 44, "days_since_last_login": 35, "login_frequency_7d": 2, "payment_delays_90d": 3, "support_tickets_last_30d": 7, "contract_type": "Month-to-Month", "nps_score": 1, "feature_adoption_score": 35, "avg_session_minutes": 2, "churned": 1}], "target_column": "churned", "model_type": "churn", "model_name": "churn-demo-v1"}