653}
654} catch (error) {
655const errMsg = `AI API Error: ${error.message}`;
656log.push({ agent: agentName, type: "error", message: errMsg });
657console.error(`${agentName} Error:`, error);
658return { error: "AI_API_ERROR", message: errMsg, details: error.toString() };
659}
660}
FetchBasicmain.tsx12 matches
1/**
2* Val.Town function to proxy Ticket Tailor Overview API
3* This provides the same functionality as the Vercel serverless function
4*
5* Environment variables needed:
6* - TICKET_TAILOR_API_KEY: Your Ticket Tailor API key
7*/
8export default async function handler(request: Request): Promise<Response> {
3839try {
40// Get API key from environment variable
41const apiKey = Deno.env.get("TICKET_TAILOR_API_KEY");
4243if (!apiKey) {
44return new Response(
45JSON.stringify({
46success: false,
47error: "API key not configured",
48}),
49{
5556// Create Basic Auth header (using btoa for base64 encoding)
57const authHeader = `Basic ${btoa(apiKey + ":")}`;
5859// Call Ticket Tailor Overview API
60const response = await fetch("https://api.tickettailor.com/v1/overview", {
61method: "GET",
62headers: {
68// Check if the request was successful
69if (!response.ok) {
70console.error(`Ticket Tailor API error: ${response.status} ${response.statusText}`);
71return new Response(
72JSON.stringify({
73success: false,
74error: `Ticket Tailor API error: ${response.status}`,
75details: response.statusText,
76}),
98);
99} catch (error) {
100console.error("API Error:", error);
101102return new Response(
12},
13{
14"prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15"title": "Weather App",
16"code":
cerebras_coderREADME.md2 matches
891. Sign up for [Cerebras](https://cloud.cerebras.ai/)
102. Get a Cerebras API Key
113. Save it in your project env variable called `CEREBRAS_API_KEY`
cerebras_coderindex.ts1 match
211} catch (error) {
212Toastify({
213text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
214position: "center",
215duration: 3000,
cerebras_coderindex.html3 matches
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>CerebrasCoder</title>
7<link rel="preconnect" href="https://fonts.googleapis.com" />
8<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9<link
10href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
11rel="stylesheet"
12/>
21<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22<meta property="og:type" content="website">
23<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
24
25
16};
17} else {
18const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19const completion = await client.chat.completions.create({
20messages: [
FetchBasicREADME.md1 match
1# Framer Fetch: Basic
23A basic example of an API endpoint to use with Framer Fetch.
3* controlling multiple Chromecast devices simultaneously.
4* The application logic is entirely on the client-side, interacting with a
5* user-provided backend REST API. This val only serves the static HTML, CSS,
6* and JavaScript files.
7*/
304// --- STATE ---
305const PORT = 8081;
306let apiBase = "";
307let services = [];
308let list = []; // Array of host strings
333const allControlButtons = [sendMediaBtn, playBtn, pauseBtn, stopBtn, closeBtn, addAllBtn, removeAllBtn];
334335// --- API HELPERS ---
336const apiCall = (endpoint, options = {}) => {
337if (!apiBase) return Promise.reject("API base not set");
338return fetch(`${apiBase}${endpoint}`, options);
339};
340341const getStatus = () => apiCall("/status");
342const getServices = () => apiCall("/services").then(res => res.ok ? res.json() : Promise.reject(res));
343const getList = () => apiCall("/list").then(res => res.ok ? res.json() : Promise.reject(res));
344const updateList = (hosts) => apiCall("/list", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(hosts) });
345const deleteFromList = (hosts) => apiCall("/list", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify(hosts) });
346347const postCommand = (endpoint, body = {}) => apiCall(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
348const sendMedia = (contentId, contentType) => postCommand("/media", { contentId, contentType });
349const stopPlayback = () => postCommand("/stop");
428if(servicesInterval) clearInterval(servicesInterval);
429430apiBase = `http://${host}:${PORT}`;
431hostInput.disabled = true;
432connectBtn.disabled = true;
YoutubeDownloaderyoutube.ts6 matches
23// In a real implementation, you would either:
24// 1. Use a separate service that has yt-dlp installed
25// 2. Use YouTube API + other tools for downloading
26// 3. Use a third-party service
27
7273/**
74* Gets video information (simulated - in real implementation would use YouTube API)
75*/
76private static async getVideoInfo(url: string): Promise<VideoInfo> {
77const videoId = this.extractVideoId(url);
78
79// In a real implementation, you would use YouTube Data API v3
80// For demo purposes, we'll return mock data
81return {
103message: "Video downloaded successfully",
104filename: `${videoInfo.title}.mp4`,
105downloadUrl: `/api/download/video/${this.extractVideoId(url)}`
106};
107}
125message: "Audio extracted successfully",
126filename: `${videoInfo.title}.mp3`,
127downloadUrl: `/api/download/audio/${this.extractVideoId(url)}`
128};
129}
140// 1. A server with yt-dlp installed (Python environment)
141// 2. File storage system (local filesystem, cloud storage, etc.)
142// 3. YouTube Data API key for video metadata
143// 4. Proper error handling and rate limiting
144// 5. Cleanup of temporary files