71. Sign up to Val Town (or replit, lovable, vercel, etc)
82. Vibe coding gets you super far in minutes
93. You need an API key for Browserbase, OpenAI, S3, etc...
104. You spend 5-45min creating an account, adding payment...
115. Only to find it's the wrong API! Try again!
17
18- Val Town Standard Library
19 - OpenAI
20 - Email
21 - Blob
288intelligence generates more capital. The loop compounds.
289
290This is the big loop that Anthropic and OpenAI and all frontier labs are running
291right now: use capital to build intelligence, use the resulting
292capital and intellgience to buy more compute, build even more intelligence.
2// GET / → serves the app
3// POST /translate → Whisper + Claude + TTS
4// Env vars: OPENAI_KEY, ANTHROPIC_KEY
5
6const VERSION = "v3.0";
819
820 if (req.method === "POST" && url.pathname === "/translate") {
821 const openaiKey = Deno.env.get("OPENAI_KEY");
822 const anthropicKey = Deno.env.get("ANTHROPIC_KEY");
823 if (!openaiKey || !anthropicKey) {
824 return Response.json({
825 error:
826 "Missing API keys. Add OPENAI_KEY and ANTHROPIC_KEY in Val Town Settings → Environment.",
827 }, { status: 500 });
828 }
852 wf.append("model", "whisper-1");
853 wf.append("language", whisperLang);
854 const wRes = await fetch("https://api.openai.com/v1/audio/transcriptions", {
855 method: "POST",
856 headers: { Authorization: "Bearer " + openaiKey },
857 body: wf,
858 });
900 const voice = voiceGender === "m" ? "onyx" : "nova";
901 try {
902 const tRes = await fetch("https://api.openai.com/v1/audio/speech", {
903 method: "POST",
904 headers: {
905 "Authorization": "Bearer " + openaiKey,
906 "Content-Type": "application/json",
907 },
79 ' * Testing : Playwright, Cypress, Jest, mobile test orchestration',
80 ' * Infra : Valtown, serverless, CI/CD, Docker, Kubernetes',
81 ' * AI/ML : OpenAI API, LangChain, vector databases, prompt eng.',
82 ' * Databases : PostgreSQL, MongoDB, Redis, SQLite',
83 ];
25 'api-gateway': mkDir({
26 'server.py': mkFile('from flask import Flask, jsonify\n\napp = Flask(__name__)\n\n@app.route("/health")\ndef health():\n return jsonify(status="ok")\n\nif __name__ == "__main__":\n app.run(port=5000)'),
27 'requirements.txt': mkFile('flask==3.0.0\nrequests==2.31.0\nopenai==1.12.0\npydantic==2.5.0'),
28 'README.md': mkFile('# API Gateway\n\nUnified interface for multiple LLM providers.\nSupports OpenAI, Anthropic, and local models.'),
29 }),
30 'terminal-portfolio': mkDir({
28 'api-gateway': mkDir({
29 'server.py': mkFile('from flask import Flask, jsonify\n\napp = Flask(__name__)\n\n@app.route("/health")\ndef health():\n return jsonify(status="ok")\n\nif __name__ == "__main__":\n app.run(port=5000)'),
30 'requirements.txt': mkFile('flask==3.0.0\nrequests==2.31.0\nopenai==1.12.0\npydantic==2.5.0'),
31 'README.md': mkFile('# API Gateway\n\nUnified interface for multiple LLM providers.\nSupports OpenAI, Anthropic, and local models.'),
32 }),
33 'terminal-portfolio': mkDir({
246 ' * Testing : Playwright, Cypress, Jest, mobile test orchestration',
247 ' * Infra : Valtown, serverless, CI/CD, Docker, Kubernetes',
248 ' * AI/ML : OpenAI API, LangChain, vector databases, prompt eng.',
249 ' * Databases : PostgreSQL, MongoDB, Redis, SQLite',
250 ];
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
9 }
10
11 const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
12 method: "POST",
13 headers: {
1[
2 ["aiforswes", ["AI"], "https://www.aiforswes.com/feed"],
3 ["openaiNews", ["AI"], "https://developers.openai.com/rss.xml"],
4 ["anthropicNews", ["AI"], "https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_anthropic_news.xml"],
5 ["aiNews", ["AI"], "https://news.smol.ai/rss.xml"],
9 ["gregBrockman", ["AI"], "https://blog.gregbrockman.com/feed"],
10 ["epochAI", ["AI"], "https://epoch.ai/atom.xml"],
11 ["openAIDeveloper", ["AI"], "https://developers.openai.com/rss.xml"],
12 ["simonWillison", ["AI", "programming"], "https://simonw.substack.com/feed"],
13 ["latestPatterns", ["AI", "programming"], "https://latentpatterns.com/blog/rss.xml"],
1import process from "node:process";
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 200;
74].filter(Boolean);
75
76function createPoeClient(apiKey: string): OpenAI {
77 return new OpenAI({
78 apiKey: apiKey || "YOUR_POE_API_KEY",
79 baseURL: "https://api.poe.com/v1",