Alireza1913 commited on
Commit
a0700be
·
verified ·
1 Parent(s): b84f70e

import gradio as gr
import os
from openai import OpenAI

client = OpenAI(
api_key=os.environ.get("ANTHROPIC_API_KEY", ""),
base_url="https://api.avalai.ir/v1"
)

API_KNOWLEDGE_BASE = """
You are an expert API architect and indie hacker advisor. You know every major API deeply:

PAYMENT: Stripe, Paddle, LemonSqueezy, PayPal, Razorpay
AI/ML: OpenAI, Anthropic Claude, Replicate, HuggingFace Inference, AssemblyAI, ElevenLabs, Stability AI
COMMUNICATION: Twilio (SMS/Voice), SendGrid (email), Resend, Mailgun, Vonage, WhatsApp Business
DATA/ENRICHMENT: Clearbit, Apollo.io, Hunter.io, Proxycurl, PeopleDataLabs
MAPS/LOCATION: Google Maps, Mapbox, HERE, OpenStreetMap/Nominatim
MEDIA: Cloudinary, Mux (video), Imgix, Transloadit
FINANCE/MARKET DATA: Alpha Vantage, Polygon.io, CoinGecko, Plaid, Finnhub
SEARCH: Algolia, Typesense, Elasticsearch, Meilisearch
AUTH: Auth0, Clerk, Supabase Auth, Firebase Auth
DATABASE/BACKEND: Supabase, Firebase, PlanetScale, Neon, Upstash
SCRAPING/CRAWLING: Apify, ScraperAPI, Browserless, Firecrawl
SOCIAL: Twitter/X API, Reddit API, LinkedIn API, Instagram Graph API
PRODUCTIVITY: Notion API, Airtable, Google Workspace, Microsoft Graph
E-COMMERCE: Shopify, WooCommerce, Printful (print-on-demand)
ANALYTICS: Mixpanel, PostHog, Amplitude, Plausible
"""

SYSTEM_PROMPT = API_KNOWLEDGE_BASE + """

When a user describes their product idea, you will recommend the perfect API stack.

Your response MUST follow this exact format:

## 🎯 Your Idea in One Line
(restate the idea clearly and concisely)

## 🔧 Recommended API Stack

For each API (recommend 3-5 total), use this format:

### [API Name] — [Role in the product]
- **What it does for you:** (one sentence)
- **Pricing:** (free tier + paid tier, be specific)
- **Docs:** (exact URL)
- **Why not alternatives:** (one sentence)
- **Integration difficulty:** Easy / Medium / Hard

## 💰 Total Monthly API Cost Estimate
(breakdown for 100 users / 1000 users / 10,000 users)

## ⚡ Build Order
(which API to integrate first, second, third — and why)

## 🚨 One Thing to Watch Out For
(the most common mistake with this stack)

Be specific, honest about pricing, and always mention free tiers.
"""

def get_stack_recommendation(idea, budget, technical_level, target_market):
if not idea.strip():
return "Please describe your product idea first."

if not client.api_key:
return "⚠️ ANTHROPIC_API_KEY is not set. Add it in Space Settings → Secrets."

user_message = f"""
My product idea: {idea}

My monthly API budget: {budget}
My technical level: {technical_level}
Target market: {target_market}

Please recommend the best API stack for this.
"""

try:
response = client.chat.completions.create(
model="claude-sonnet-4-6",
max_tokens=1500,
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message}
]
)
return response.choices[0].message.content
except Exception as e:
return f"❌ Error: {str(e)}"

def ask_followup(question, previous_recommendation):
if not question.strip():
return ""
if not previous_recommendation or previous_recommendation.startswith("Please") or previous_recommendation.startswith("⚠️"):
return "Please generate a stack recommendation first."

try:
response = client.chat.completions.create(
model="claude-sonnet-4-6",
max_tokens=800,
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"I got this API stack recommendation:\n\n{previous_recommendation}\n\nMy follow-up question: {question}"}
]
)
return response.choices[0].message.content
except Exception as e:
return f"❌ Error: {str(e)}"

EXAMPLES = [
["A Notion-like note taking app with AI summarization", "$50/month", "Intermediate", "Students and researchers"],
["An SMS marketing platform for small restaurants", "$30/month", "Beginner", "Local restaurant owners"],
["A job board that auto-matches candidates with AI", "$100/month", "Advanced", "Tech recruiters"],
["A podcast transcription and highlight tool", "$20/month", "Beginner", "Podcasters"],
["A crypto portfolio tracker with price alerts", "$0 (free only)", "Intermediate", "Retail crypto investors"],
]

css = """
.gradio-container { max-width: 900px !important; margin: auto; }
footer { display: none !important; }
"""

with gr.Blocks(css=css, title="API Stack Finder") as demo:
gr.Markdown("""
# 🔧 API Stack Finder
**Describe your product idea → Get the perfect API stack, pricing breakdown, and build order**

Powered by Claude (Anthropic) — No more guessing which APIs to use.
""")

with gr.Row():
with gr.Column(scale=3):
idea_input = gr.Textbox(
label="Describe your product idea",
placeholder="e.g. A platform where freelancers can sell their services and get paid instantly via Stripe...",
lines=4
)
with gr.Column(scale=1):
budget_input = gr.Dropdown(
choices=["$0 (free only)", "$10/month", "$30/month", "$50/month", "$100/month", "$500/month", "Unlimited"],
value="$30/month",
label="Monthly API budget"
)
level_input = gr.Dropdown(
choices=["Beginner", "Intermediate", "Advanced"],
value="Intermediate",
label="Your technical level"
)
market_input = gr.Textbox(
label="Target market",
placeholder="e.g. Small business owners in Europe",
value="General consumers"
)

gr.Markdown("**Try an example:**")
with gr.Row():
for ex in EXAMPLES:
gr.Button(ex[0][:35] + "...", size="sm").click(
lambda e=ex: (e[0], e[1], e[2], e[3]),
outputs=[idea_input, budget_input, level_input, market_input]
)

submit_btn = gr.Button("🔍 Find My API Stack", variant="primary", size="lg")

recommendation_output = gr.Markdown(
value="*Your API stack recommendation will appear here...*",
label="Recommended Stack"
)

gr.Markdown("---")
gr.Markdown("### 💬 Ask a follow-up question")
with gr.Row():
followup_input = gr.Textbox(
label="Follow-up",
placeholder="e.g. Is there a cheaper alternative to Twilio? / How do I handle auth without Auth0?",
scale=4
)
followup_btn = gr.Button("Ask", scale=1, variant="secondary")

followup_output = gr.Markdown()

submit_btn.click(
get_stack_recommendation,
inputs=[idea_input, budget_input, level_input, market_input],
outputs=recommendation_output
)

followup_btn.click(
ask_followup,
inputs=[followup_input, recommendation_output],
outputs=followup_output
)

gr.Markdown("""
---
Built with [Gradio](https://gradio.app) + [Claude](https://anthropic.com) ·
[View on HuggingFace](https://huggingface.co/spaces/Alireza1913/Monetizable_API_Finder)
""")

if __name__ == "__main__":
demo.launch()

Files changed (1) hide show
  1. app.py +0 -407
app.py DELETED
@@ -1,407 +0,0 @@
1
- import gradio as gr
2
- import os
3
- from anthropic import Anthropic
4
-
5
- client = Anthropic(import gradio as gr
6
- import os
7
- from openai import OpenAI
8
-
9
- client = OpenAI(
10
- api_key=os.environ.get("ANTHROPIC_API_KEY", ""),
11
- base_url="https://api.avalai.ir/v1"
12
- )
13
-
14
- API_KNOWLEDGE_BASE = """
15
- You are an expert API architect and indie hacker advisor. You know every major API deeply:
16
-
17
- PAYMENT: Stripe, Paddle, LemonSqueezy, PayPal, Razorpay
18
- AI/ML: OpenAI, Anthropic Claude, Replicate, HuggingFace Inference, AssemblyAI, ElevenLabs, Stability AI
19
- COMMUNICATION: Twilio (SMS/Voice), SendGrid (email), Resend, Mailgun, Vonage, WhatsApp Business
20
- DATA/ENRICHMENT: Clearbit, Apollo.io, Hunter.io, Proxycurl, PeopleDataLabs
21
- MAPS/LOCATION: Google Maps, Mapbox, HERE, OpenStreetMap/Nominatim
22
- MEDIA: Cloudinary, Mux (video), Imgix, Transloadit
23
- FINANCE/MARKET DATA: Alpha Vantage, Polygon.io, CoinGecko, Plaid, Finnhub
24
- SEARCH: Algolia, Typesense, Elasticsearch, Meilisearch
25
- AUTH: Auth0, Clerk, Supabase Auth, Firebase Auth
26
- DATABASE/BACKEND: Supabase, Firebase, PlanetScale, Neon, Upstash
27
- SCRAPING/CRAWLING: Apify, ScraperAPI, Browserless, Firecrawl
28
- SOCIAL: Twitter/X API, Reddit API, LinkedIn API, Instagram Graph API
29
- PRODUCTIVITY: Notion API, Airtable, Google Workspace, Microsoft Graph
30
- E-COMMERCE: Shopify, WooCommerce, Printful (print-on-demand)
31
- ANALYTICS: Mixpanel, PostHog, Amplitude, Plausible
32
- """
33
-
34
- SYSTEM_PROMPT = API_KNOWLEDGE_BASE + """
35
-
36
- When a user describes their product idea, you will recommend the perfect API stack.
37
-
38
- Your response MUST follow this exact format:
39
-
40
- ## 🎯 Your Idea in One Line
41
- (restate the idea clearly and concisely)
42
-
43
- ## 🔧 Recommended API Stack
44
-
45
- For each API (recommend 3-5 total), use this format:
46
-
47
- ### [API Name] — [Role in the product]
48
- - **What it does for you:** (one sentence)
49
- - **Pricing:** (free tier + paid tier, be specific)
50
- - **Docs:** (exact URL)
51
- - **Why not alternatives:** (one sentence)
52
- - **Integration difficulty:** Easy / Medium / Hard
53
-
54
- ## 💰 Total Monthly API Cost Estimate
55
- (breakdown for 100 users / 1000 users / 10,000 users)
56
-
57
- ## ⚡ Build Order
58
- (which API to integrate first, second, third — and why)
59
-
60
- ## 🚨 One Thing to Watch Out For
61
- (the most common mistake with this stack)
62
-
63
- Be specific, honest about pricing, and always mention free tiers.
64
- """
65
-
66
- def get_stack_recommendation(idea, budget, technical_level, target_market):
67
- if not idea.strip():
68
- return "Please describe your product idea first."
69
-
70
- if not client.api_key:
71
- return "⚠️ ANTHROPIC_API_KEY is not set. Add it in Space Settings → Secrets."
72
-
73
- user_message = f"""
74
- My product idea: {idea}
75
-
76
- My monthly API budget: {budget}
77
- My technical level: {technical_level}
78
- Target market: {target_market}
79
-
80
- Please recommend the best API stack for this.
81
- """
82
-
83
- try:
84
- response = client.chat.completions.create(
85
- model="claude-sonnet-4-6",
86
- max_tokens=1500,
87
- messages=[
88
- {"role": "system", "content": SYSTEM_PROMPT},
89
- {"role": "user", "content": user_message}
90
- ]
91
- )
92
- return response.choices[0].message.content
93
- except Exception as e:
94
- return f"❌ Error: {str(e)}"
95
-
96
- def ask_followup(question, previous_recommendation):
97
- if not question.strip():
98
- return ""
99
- if not previous_recommendation or previous_recommendation.startswith("Please") or previous_recommendation.startswith("⚠️"):
100
- return "Please generate a stack recommendation first."
101
-
102
- try:
103
- response = client.chat.completions.create(
104
- model="claude-sonnet-4-6",
105
- max_tokens=800,
106
- messages=[
107
- {"role": "system", "content": SYSTEM_PROMPT},
108
- {"role": "user", "content": f"I got this API stack recommendation:
109
-
110
- {previous_recommendation}
111
-
112
- My follow-up question: {question}"}
113
- ]
114
- )
115
- return response.choices[0].message.content
116
- except Exception as e:
117
- return f"❌ Error: {str(e)}"
118
-
119
- EXAMPLES = [
120
- ["A Notion-like note taking app with AI summarization", "$50/month", "Intermediate", "Students and researchers"],
121
- ["An SMS marketing platform for small restaurants", "$30/month", "Beginner", "Local restaurant owners"],
122
- ["A job board that auto-matches candidates with AI", "$100/month", "Advanced", "Tech recruiters"],
123
- ["A podcast transcription and highlight tool", "$20/month", "Beginner", "Podcasters"],
124
- ["A crypto portfolio tracker with price alerts", "$0 (free only)", "Intermediate", "Retail crypto investors"],
125
- ]
126
-
127
- css = """
128
- .gradio-container { max-width: 900px !important; margin: auto; }
129
- footer { display: none !important; }
130
- """
131
-
132
- with gr.Blocks(css=css, title="API Stack Finder") as demo:
133
- gr.Markdown("""
134
- # 🔧 API Stack Finder
135
- **Describe your product idea → Get the perfect API stack, pricing breakdown, and build order**
136
-
137
- Powered by Claude (Anthropic) — No more guessing which APIs to use.
138
- """)
139
-
140
- with gr.Row():
141
- with gr.Column(scale=3):
142
- idea_input = gr.Textbox(
143
- label="Describe your product idea",
144
- placeholder="e.g. A platform where freelancers can sell their services and get paid instantly via Stripe...",
145
- lines=4
146
- )
147
- with gr.Column(scale=1):
148
- budget_input = gr.Dropdown(
149
- choices=["$0 (free only)", "$10/month", "$30/month", "$50/month", "$100/month", "$500/month", "Unlimited"],
150
- value="$30/month",
151
- label="Monthly API budget"
152
- )
153
- level_input = gr.Dropdown(
154
- choices=["Beginner", "Intermediate", "Advanced"],
155
- value="Intermediate",
156
- label="Your technical level"
157
- )
158
- market_input = gr.Textbox(
159
- label="Target market",
160
- placeholder="e.g. Small business owners in Europe",
161
- value="General consumers"
162
- )
163
-
164
- gr.Markdown("**Try an example:**")
165
- with gr.Row():
166
- for ex in EXAMPLES:
167
- gr.Button(ex[0][:35] + "...", size="sm").click(
168
- lambda e=ex: (e[0], e[1], e[2], e[3]),
169
- outputs=[idea_input, budget_input, level_input, market_input]
170
- )
171
-
172
- submit_btn = gr.Button("🔍 Find My API Stack", variant="primary", size="lg")
173
-
174
- recommendation_output = gr.Markdown(
175
- value="*Your API stack recommendation will appear here...*",
176
- label="Recommended Stack"
177
- )
178
-
179
- gr.Markdown("---")
180
- gr.Markdown("### 💬 Ask a follow-up question")
181
- with gr.Row():
182
- followup_input = gr.Textbox(
183
- label="Follow-up",
184
- placeholder="e.g. Is there a cheaper alternative to Twilio? / How do I handle auth without Auth0?",
185
- scale=4
186
- )
187
- followup_btn = gr.Button("Ask", scale=1, variant="secondary")
188
-
189
- followup_output = gr.Markdown()
190
-
191
- submit_btn.click(
192
- get_stack_recommendation,
193
- inputs=[idea_input, budget_input, level_input, market_input],
194
- outputs=recommendation_output
195
- )
196
-
197
- followup_btn.click(
198
- ask_followup,
199
- inputs=[followup_input, recommendation_output],
200
- outputs=followup_output
201
- )
202
-
203
- gr.Markdown("""
204
- ---
205
- Built with [Gradio](https://gradio.app) + [Claude](https://anthropic.com) ·
206
- [View on HuggingFace](https://huggingface.co/spaces/Alireza1913/Monetizable_API_Finder)
207
- """)
208
-
209
- if __name__ == "__main__":
210
- demo.launch()
211
- api_key=os.environ.get("ANTHROPIC_API_KEY", ""),
212
- base_url="https://api.avalai.ir"
213
- )
214
- API_KNOWLEDGE_BASE = """
215
- You are an expert API architect and indie hacker advisor. You know every major API deeply:
216
-
217
- PAYMENT: Stripe, Paddle, LemonSqueezy, PayPal, Razorpay
218
- AI/ML: OpenAI, Anthropic Claude, Replicate, HuggingFace Inference, AssemblyAI, ElevenLabs, Stability AI
219
- COMMUNICATION: Twilio (SMS/Voice), SendGrid (email), Resend, Mailgun, Vonage, WhatsApp Business
220
- DATA/ENRICHMENT: Clearbit, Apollo.io, Hunter.io, Proxycurl, PeopleDataLabs
221
- MAPS/LOCATION: Google Maps, Mapbox, HERE, OpenStreetMap/Nominatim
222
- MEDIA: Cloudinary, Mux (video), Imgix, Transloadit
223
- FINANCE/MARKET DATA: Alpha Vantage, Polygon.io, CoinGecko, Plaid, Finnhub
224
- SEARCH: Algolia, Typesense, Elasticsearch, Meilisearch
225
- AUTH: Auth0, Clerk, Supabase Auth, Firebase Auth
226
- DATABASE/BACKEND: Supabase, Firebase, PlanetScale, Neon, Upstash
227
- SCRAPING/CRAWLING: Apify, ScraperAPI, Browserless, Firecrawl
228
- SOCIAL: Twitter/X API, Reddit API, LinkedIn API, Instagram Graph API
229
- PRODUCTIVITY: Notion API, Airtable, Google Workspace, Microsoft Graph
230
- E-COMMERCE: Shopify, WooCommerce, Printful (print-on-demand)
231
- ANALYTICS: Mixpanel, PostHog, Amplitude, Plausible
232
- """
233
-
234
- SYSTEM_PROMPT = API_KNOWLEDGE_BASE + """
235
-
236
- When a user describes their product idea, you will recommend the perfect API stack.
237
-
238
- Your response MUST follow this exact format:
239
-
240
- ## 🎯 Your Idea in One Line
241
- (restate the idea clearly and concisely)
242
-
243
- ## 🔧 Recommended API Stack
244
-
245
- For each API (recommend 3-5 total), use this format:
246
-
247
- ### [API Name] — [Role in the product]
248
- - **What it does for you:** (one sentence)
249
- - **Pricing:** (free tier + paid tier, be specific)
250
- - **Docs:** (exact URL)
251
- - **Why not alternatives:** (one sentence)
252
- - **Integration difficulty:** Easy / Medium / Hard
253
-
254
- ## 💰 Total Monthly API Cost Estimate
255
- (breakdown for 100 users / 1000 users / 10,000 users)
256
-
257
- ## ⚡ Build Order
258
- (which API to integrate first, second, third — and why)
259
-
260
- ## 🚨 One Thing to Watch Out For
261
- (the most common mistake with this stack)
262
-
263
- Be specific, honest about pricing, and always mention free tiers.
264
- """
265
-
266
- def get_stack_recommendation(idea, budget, technical_level, target_market):
267
- if not idea.strip():
268
- return "Please describe your product idea first."
269
-
270
- if not client.api_key:
271
- return "⚠️ ANTHROPIC_API_KEY is not set. Add it in Space Settings → Secrets."
272
-
273
- user_message = f"""
274
- My product idea: {idea}
275
-
276
- My monthly API budget: {budget}
277
- My technical level: {technical_level}
278
- Target market: {target_market}
279
-
280
- Please recommend the best API stack for this.
281
- """
282
-
283
- try:
284
- response = client.messages.create(
285
- model="claude-sonnet-4-6",
286
- max_tokens=1500,
287
- system=SYSTEM_PROMPT,
288
- messages=[{"role": "user", "content": user_message}]
289
- )
290
- return response.content[0].text
291
- except Exception as e:
292
- return f"❌ Error: {str(e)}"
293
-
294
- def ask_followup(question, previous_recommendation):
295
- if not question.strip():
296
- return ""
297
- if not previous_recommendation or previous_recommendation.startswith("Please") or previous_recommendation.startswith("⚠️"):
298
- return "Please generate a stack recommendation first."
299
-
300
- try:
301
- response = client.messages.create(
302
- model="claude-sonnet-4-6",
303
- max_tokens=800,
304
- system=SYSTEM_PROMPT,
305
- messages=[
306
- {
307
- "role": "user",
308
- "content": f"I got this API stack recommendation:\n\n{previous_recommendation}\n\nMy follow-up question: {question}"
309
- }
310
- ]
311
- )
312
- return response.content[0].text
313
- except Exception as e:
314
- return f"❌ Error: {str(e)}"
315
-
316
- EXAMPLES = [
317
- ["A Notion-like note taking app with AI summarization", "$50/month", "Intermediate", "Students and researchers"],
318
- ["An SMS marketing platform for small restaurants", "$30/month", "Beginner", "Local restaurant owners"],
319
- ["A job board that auto-matches candidates with AI", "$100/month", "Advanced", "Tech recruiters"],
320
- ["A podcast transcription and highlight tool", "$20/month", "Beginner", "Podcasters"],
321
- ["A crypto portfolio tracker with price alerts", "$0 (free only)", "Intermediate", "Retail crypto investors"],
322
- ]
323
-
324
- css = """
325
- .gradio-container { max-width: 900px !important; margin: auto; }
326
- footer { display: none !important; }
327
- """
328
-
329
- with gr.Blocks(css=css, title="API Stack Finder") as demo:
330
- gr.Markdown("""
331
- # 🔧 API Stack Finder
332
- **Describe your product idea → Get the perfect API stack, pricing breakdown, and build order**
333
-
334
- Powered by Claude (Anthropic) — No more guessing which APIs to use.
335
- """)
336
-
337
- with gr.Row():
338
- with gr.Column(scale=3):
339
- idea_input = gr.Textbox(
340
- label="Describe your product idea",
341
- placeholder="e.g. A platform where freelancers can sell their services and get paid instantly via Stripe...",
342
- lines=4
343
- )
344
- with gr.Column(scale=1):
345
- budget_input = gr.Dropdown(
346
- choices=["$0 (free only)", "$10/month", "$30/month", "$50/month", "$100/month", "$500/month", "Unlimited"],
347
- value="$30/month",
348
- label="Monthly API budget"
349
- )
350
- level_input = gr.Dropdown(
351
- choices=["Beginner", "Intermediate", "Advanced"],
352
- value="Intermediate",
353
- label="Your technical level"
354
- )
355
- market_input = gr.Textbox(
356
- label="Target market",
357
- placeholder="e.g. Small business owners in Europe",
358
- value="General consumers"
359
- )
360
-
361
- gr.Markdown("**Try an example:**")
362
- with gr.Row():
363
- for ex in EXAMPLES:
364
- gr.Button(ex[0][:35] + "...", size="sm").click(
365
- lambda e=ex: (e[0], e[1], e[2], e[3]),
366
- outputs=[idea_input, budget_input, level_input, market_input]
367
- )
368
-
369
- submit_btn = gr.Button("🔍 Find My API Stack", variant="primary", size="lg")
370
-
371
- recommendation_output = gr.Markdown(
372
- value="*Your API stack recommendation will appear here...*",
373
- label="Recommended Stack"
374
- )
375
-
376
- gr.Markdown("---")
377
- gr.Markdown("### 💬 Ask a follow-up question")
378
- with gr.Row():
379
- followup_input = gr.Textbox(
380
- label="Follow-up",
381
- placeholder="e.g. Is there a cheaper alternative to Twilio? / How do I handle auth without Auth0?",
382
- scale=4
383
- )
384
- followup_btn = gr.Button("Ask", scale=1, variant="secondary")
385
-
386
- followup_output = gr.Markdown()
387
-
388
- submit_btn.click(
389
- get_stack_recommendation,
390
- inputs=[idea_input, budget_input, level_input, market_input],
391
- outputs=recommendation_output
392
- )
393
-
394
- followup_btn.click(
395
- ask_followup,
396
- inputs=[followup_input, recommendation_output],
397
- outputs=followup_output
398
- )
399
-
400
- gr.Markdown("""
401
- ---
402
- Built with [Gradio](https://gradio.app) + [Claude](https://anthropic.com) ·
403
- [View on HuggingFace](https://huggingface.co/spaces/Alireza1913/Monetizable_API_Finder)
404
- """)
405
-
406
- if __name__ == "__main__":
407
- demo.launch()