22
231. Sign up for [Cerebras](https://cloud.cerebras.ai/)
242. Get a Cerebras API Key
253. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
26
27Once Cerebras is set up in your Val Town account, there are two ways to get started:
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
41});
42const response = await client.chat.completions.create({
54## Sample apps
55
56* **[Cerebras Searcher](https://www.val.town/v/stevekrouse/cerebras_searcher)** - a Perplexity clone that uses the SerpAPI to do RAG
57and summaries with Cerebras (*requires a SerpAPI key*)
58* **[Cerebras Coder](https://www.val.town/v/stevekrouse/cerebras_coder)** - an app that
59generates websites in a second with Cerebras
1// Use Web Crypto API for hashing instead of Deno's standard library
2async function hashSeed(seed: string): Promise<string> {
3 const encoder = new TextEncoder();
30 }
31
32 // Create a hash of the seed string using Web Crypto API
33 const hash = await hashSeed(useSeed);
34
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`
266 } catch (error) {
267 Toastify({
268 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
269 position: "center",
270 duration: 3000,
1046 };
1047 } else {
1048 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1049 const completion = await client.chat.completions.create({
1050 messages: [
1171 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1172 <title>CerebrasCoder</title>
1173 <link rel="preconnect" href="https://fonts.googleapis.com" />
1174 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1175 <link
1176 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"
1177 rel="stylesheet"
1178 />
1187 <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."">
1188 <meta property="og:type" content="website">
1189 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1190
1191
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`
22
231. Sign up for [Cerebras](https://cloud.cerebras.ai/)
242. Get a Cerebras API Key
253. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
26
27Once Cerebras is set up in your Val Town account, there are two ways to get started:
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
41});
42const response = await client.chat.completions.create({
54## Sample apps
55
56* **[Cerebras Searcher](https://www.val.town/v/stevekrouse/cerebras_searcher)** - a Perplexity clone that uses the SerpAPI to do RAG
57and summaries with Cerebras (*requires a SerpAPI key*)
58* **[Cerebras Coder](https://www.val.town/v/stevekrouse/cerebras_coder)** - an app that
59generates websites in a second with Cerebras
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",
92 });
93
101 return Response.json({ message: generatedMessage });
102 } catch (error) {
103 console.error("Error calling Cerebras API:", error);
104
105 if (error.status === 429) {
106 return Response.json({ error: "Cerebras API rate limit reached. Please try again later." }, { status: 429 });
107 } else {
108 return Response.json({ error: `API Error: ${error.message}` }, { status: 500 });
109 }
110 }
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("csk-n552ehwetvcnykdcwc3wyffn33kw8yfcwddj6vw9cdvyxkpr"),
91 baseURL: "https://api.cerebras.ai/v1",
92 });
93
101 return Response.json({ message: generatedMessage });
102 } catch (error) {
103 console.error("Error calling Cerebras API:", error);
104
105 if (error.status === 429) {
106 return Response.json({ error: "Cerebras API rate limit reached. Please try again later." }, { status: 429 });
107 } else {
108 return Response.json({ error: `API Error: ${error.message}` }, { status: 500 });
109 }
110 }
22
231. Sign up for [Cerebras](https://cloud.cerebras.ai/)
242. Get a Cerebras API Key
253. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
26
27Once Cerebras is set up in your Val Town account, there are two ways to get started:
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
41});
42const response = await client.chat.completions.create({
54## Sample apps
55
56* **[Cerebras Searcher](https://www.val.town/v/stevekrouse/cerebras_searcher)** - a Perplexity clone that uses the SerpAPI to do RAG
57and summaries with Cerebras (*requires a SerpAPI key*)
58* **[Cerebras Coder](https://www.val.town/v/stevekrouse/cerebras_coder)** - an app that
59generates websites in a second with Cerebras
22
231. Sign up for [Cerebras](https://cloud.cerebras.ai/)
242. Get a Cerebras API Key
253. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
26
27Once Cerebras is set up in your Val Town account, there are two ways to get started:
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
41});
42const response = await client.chat.completions.create({
54## Sample apps
55
56* **[Cerebras Searcher](https://www.val.town/v/stevekrouse/cerebras_searcher)** - a Perplexity clone that uses the SerpAPI to do RAG
57and summaries with Cerebras (*requires a SerpAPI key*)
58* **[Cerebras Coder](https://www.val.town/v/stevekrouse/cerebras_coder)** - an app that
59generates websites in a second with Cerebras