162
163const css = `
164@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Playfair+Display:wght@600&display=swap');
165
166:root {
7 return;
8 }
9 const resp = await fetch("https://api.perplexity.ai/chat/completions", {
10 method: "POST",
11 headers: {
12 "accept": "application/json",
13 "content-type": "application/json",
14 "authorization": `Bearer ${Deno.env.get("PERPLEXITY_API_KEY")}`,
15 },
16 body: JSON.stringify({
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="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"
1155 rel="stylesheet"
1156 />
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="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"
1155 rel="stylesheet"
1156 />
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
16 try {
17 // 调用另一个接口
18 const apiUrl = "https://api.gooddriver.ai/share/project/statistics"; // 替换为目标接口的 URL
19 const apiResponse = await fetch(apiUrl, {
20 method: "GET", // 根据目标接口的需求调整请求方法
21 headers: {
25
26 // 检查目标接口的响应状态
27 if (!apiResponse.ok) {
28 return new Response(
29 JSON.stringify({
30 code: apiResponse.status,
31 msg: "Failed to fetch data from external API",
32 }),
33 { headers, status: apiResponse.status },
34 );
35 }
36
37 // 解析目标接口的响应数据
38 const responseData = await apiResponse.json();
39
40 // 数据处理逻辑
1# Framer Fetch: Basic
2
3A basic example of an API endpoint to use with Framer Fetch.
26
27const anthropic = createAnthropic({
28 // apiKey = Deno.env.get("ANTHROPIC_API_KEY");
29 apiKey: Deno.env.get("ANTHROPIC_API_KEY_COVERSHEET")
30});
31
32const openai = createOpenAI({
33 // apiKey = Deno.env.get("OPENAI_API_KEY");
34 apiKey: Deno.env.get("OPENAI_API_KEY_COVERSHEET")
35});
36
37
38const groq = createOpenAI({
39 baseURL: 'https://api.groq.com/openai/v1',
40 apiKey: Deno.env.get("GROQ_API_KEY"),
41});
42
43const perplexity = createOpenAI({
44 apiKey: Deno.env.get("PERPLEXITY_API_KEY") ?? '',
45 baseURL: 'https://api.perplexity.ai/',
46});
47
48const googleProvider = createGoogleGenerativeAI({
49 apiKey: Deno.env.get("GOOGLE_GENERATIVE_AI_API_KEY"),
50});
51
214 if (toolResults && toolResults.length > 0) {
215 // we have to do this bc the AI SDK doesn't seem to let you carry over function calling results,
216 // so we pretend to be the user instead of using the official role: tool API, which breaks everything
217 for (const toolResult of toolResults) {
218 options.messages.push({
512 return c.json(response);
513 } catch (error) {
514 console.error('API error:', error);
515 return c.text('Error occurred.', 500);
516 }
542 return c.json(response);
543 } catch (error) {
544 console.error('API error:', error);
545 return c.text('Error occurred.', 500);
546 }
21 defaultPermission?: boolean;
22}) => {
23 const base = new URL("https://discord.com/api/v10/");
24 const commandsUrl = new URL(`applications/${appID}/commands`, base);
25 return fetch(commandsUrl.toString(), {