Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=api&page=515&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 10995 results for "api"(1744ms)

logmeindb1 match

@maxm•Updated 2 months ago
25
26 async login(email: string, config: Config | undefined): Promise<string> {
27 const resp = await fetch("https://api.val.town/v1/me", {
28 headers: {
29 "Authorization": `Bearer ${Deno.env.get("valtown")}`,

gptMemoryManagerREADME.md20 matches

@cadence•Updated 2 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section

gptMemoryManagermain.tsx24 matches

@cadence•Updated 2 months ago
1import * as uuid from "https://deno.land/std/uuid/mod.ts";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "npm:hono@3";
5
6export const handleMemoryApiRequest = async (
7 req: Request,
8 apiName: string,
9 contactEmail: string,
10 lastPolicyUpdate: string,
11 blobKeyPrefix: string,
12 apiKeyPrefix: string,
13) => {
14 // ==== HELPERS ====
27
28 const verifyRequest = (c): { memoriesKey: string; error: any } => {
29 // Verify API key coming as a Bearer header
30 const authHeader = c.req.headers.get("Authorization");
31 if (!authHeader || !authHeader.startsWith("Basic ")) {
43 return { memoriesKey: "", error: c.text("Forbidden", 403) };
44 }
45 const expectedKey = Deno.env.get(apiKeyPrefix + key) ?? null;
46 if (token !== expectedKey) {
47 console.error("Invalid API KEY header");
48 return { memoriesKey: "", error: c.text("Forbidden", 403) };
49 }
51 };
52
53 // API
54
55 const app = new Hono();
209 // PRIVACY POLICY
210 app.get("/privacy", async (c) => {
211 const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
212 c.header("Content-Type", "text/html");
213 return c.html(policy);
214 });
215
216 app.get("/openapi", async (c) => {
217 const specification = `
218{
219 "openapi": "3.1.0",
220 "info": {
221 "title": "Memories API",
222 "description": "API for managing and storing long-term memories.",
223 "version": "1.0.0"
224 },
225 "servers": [
226 {
227 "url": "<APIURL>"
228 }
229 ],
238 },
239 "401": {
240 "description": "Unauthorized - Missing or invalid API key."
241 },
242 "403": {
243 "description": "Forbidden - Invalid API key."
244 }
245 },
272 },
273 "401": {
274 "description": "Unauthorized - Missing or invalid API key."
275 },
276 "403": {
277 "description": "Forbidden - Invalid API key."
278 }
279 },
328 },
329 "401": {
330 "description": "Unauthorized - Missing or invalid API key."
331 },
332 "403": {
333 "description": "Forbidden - Invalid API key."
334 }
335 },
375 },
376 "401": {
377 "description": "Unauthorized - Missing or invalid API key."
378 },
379 "403": {
380 "description": "Forbidden - Invalid API key."
381 }
382 },
406 },
407 "401": {
408 "description": "Unauthorized - Missing or invalid API key."
409 },
410 "403": {
411 "description": "Forbidden - Invalid API key."
412 }
413 },

gptmemoryREADME.md20 matches

@cadence•Updated 2 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section

gptmemorymain.tsx32 matches

@cadence•Updated 2 months ago
1import * as uuid from "https://deno.land/std/uuid/mod.ts";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "npm:hono@3";
5
6export const handleMemoryApiRequest = async (
7 req: Request,
8 apiName: string,
9 contactEmail: string,
10 lastPolicyUpdate: string,
11 blobKeyPrefix: string,
12 apiKeyPrefix: string,
13) => {
14 // ==== HELPERS ====
51
52 const verifyRequest = (c): { memoriesKey: string; error: any } => {
53 // Verify API key coming as a Bearer header
54 const authHeader = c.req.headers.get("Authorization");
55 if (!authHeader || !authHeader.startsWith("Basic ")) {
67 return { memoriesKey: "", error: c.text("Forbidden", 403) };
68 }
69 const expectedKey = Deno.env.get(apiKeyPrefix + key) ?? null;
70 if (token !== expectedKey) {
71 console.error("Invalid API KEY header");
72 return { memoriesKey: "", error: c.text("Forbidden", 403) };
73 }
75 };
76
77 // API
78
79 const app = new Hono();
405 // PRIVACY POLICY
406 app.get("/privacy", async (c) => {
407 const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
408 c.header("Content-Type", "text/html");
409 return c.html(policy);
410 });
411
412 app.get("/openapi", async (c) => {
413 const specification = `
414{
415 "openapi": "3.1.0",
416 "info": {
417 "title": "Memories and Conversations API",
418 "description": "API for managing and storing long-term memories, AI conversations, and file attachments.",
419 "version": "1.2.0"
420 },
421 "servers": [
422 {
423 "url": "<APIURL>"
424 }
425 ],
434 },
435 "401": {
436 "description": "Unauthorized - Missing or invalid API key."
437 },
438 "403": {
439 "description": "Forbidden - Invalid API key."
440 }
441 },
468 },
469 "401": {
470 "description": "Unauthorized - Missing or invalid API key."
471 },
472 "403": {
473 "description": "Forbidden - Invalid API key."
474 }
475 },
524 },
525 "401": {
526 "description": "Unauthorized - Missing or invalid API key."
527 },
528 "403": {
529 "description": "Forbidden - Invalid API key."
530 }
531 },
571 },
572 "401": {
573 "description": "Unauthorized - Missing or invalid API key."
574 },
575 "403": {
576 "description": "Forbidden - Invalid API key."
577 }
578 },
602 },
603 "401": {
604 "description": "Unauthorized - Missing or invalid API key."
605 },
606 "403": {
607 "description": "Forbidden - Invalid API key."
608 },
609 "404": {
641 },
642 "401": {
643 "description": "Unauthorized - Missing or invalid API key."
644 },
645 "403": {
646 "description": "Forbidden - Invalid API key."
647 }
648 },
674 },
675 "401": {
676 "description": "Unauthorized - Missing or invalid API key."
677 },
678 "403": {
679 "description": "Forbidden - Invalid API key."
680 },
681 "404": {
728 },
729 "401": {
730 "description": "Unauthorized - Missing or invalid API key."
731 },
732 "403": {
733 "description": "Forbidden - Invalid API key."
734 },
735 "404": {
781 },
782 "401": {
783 "description": "Unauthorized - Missing or invalid API key."
784 },
785 "403": {
786 "description": "Forbidden - Invalid API key."
787 },
788 "404": {

handleMemoryApiRequestREADME.md20 matches

@cadence•Updated 2 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section

handleMemoryApiRequestmain.tsx24 matches

@cadence•Updated 2 months ago
1import * as uuid from "https://deno.land/std/uuid/mod.ts";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "npm:hono@3";
5
6export const handleMemoryApiRequest = async (
7 req: Request,
8 apiName: string,
9 contactEmail: string,
10 lastPolicyUpdate: string,
11 blobKeyPrefix: string,
12 apiKeyPrefix: string,
13) => {
14 // ==== HELPERS ====
27
28 const verifyRequest = (c): { memoriesKey: string; error: any } => {
29 // Verify API key coming as a Bearer header
30 const authHeader = c.req.headers.get("Authorization");
31 if (!authHeader || !authHeader.startsWith("Basic ")) {
43 return { memoriesKey: "", error: c.text("Forbidden", 403) };
44 }
45 const expectedKey = Deno.env.get(apiKeyPrefix + key) ?? null;
46 if (token !== expectedKey) {
47 console.error("Invalid API KEY header");
48 return { memoriesKey: "", error: c.text("Forbidden", 403) };
49 }
51 };
52
53 // API
54
55 const app = new Hono();
209 // PRIVACY POLICY
210 app.get("/privacy", async (c) => {
211 const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
212 c.header("Content-Type", "text/html");
213 return c.html(policy);
214 });
215
216 app.get("/openapi", async (c) => {
217 const specification = `
218{
219 "openapi": "3.1.0",
220 "info": {
221 "title": "Memories API",
222 "description": "API for managing and storing long-term memories.",
223 "version": "1.0.0"
224 },
225 "servers": [
226 {
227 "url": "<APIURL>"
228 }
229 ],
238 },
239 "401": {
240 "description": "Unauthorized - Missing or invalid API key."
241 },
242 "403": {
243 "description": "Forbidden - Invalid API key."
244 }
245 },
272 },
273 "401": {
274 "description": "Unauthorized - Missing or invalid API key."
275 },
276 "403": {
277 "description": "Forbidden - Invalid API key."
278 }
279 },
328 },
329 "401": {
330 "description": "Unauthorized - Missing or invalid API key."
331 },
332 "403": {
333 "description": "Forbidden - Invalid API key."
334 }
335 },
375 },
376 "401": {
377 "description": "Unauthorized - Missing or invalid API key."
378 },
379 "403": {
380 "description": "Forbidden - Invalid API key."
381 }
382 },
406 },
407 "401": {
408 "description": "Unauthorized - Missing or invalid API key."
409 },
410 "403": {
411 "description": "Forbidden - Invalid API key."
412 }
413 },

NeuralCanvasmain.tsx4 matches

@toowired•Updated 2 months ago
1import App from 'https://esm.town/v/@username/NeuralCanvas/App';
2import styles from 'https://esm.town/v/@username/NeuralCanvas/styles';
3import { handleApiRequest } from 'https://esm.town/v/@username/NeuralCanvas/api';
4
5export default async function server(request: Request): Promise<Response> {
6 const url = new URL(request.url);
7
8 if (url.pathname.startsWith('/api/')) {
9 return handleApiRequest(request);
10 }
11
16 <meta name="viewport" content="width=device-width, initial-scale=1">
17 <meta name="description" content="Discover and purchase unique AI-generated artworks at NeuralCanvas">
18 <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
19 <style>${styles}</style>
20 </head>

cerebras_coderREADME.md2 matches

@Narayan•Updated 2 months ago
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`

cerebras_codermain.tsx5 matches

@Narayan•Updated 2 months ago
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

daily-advice-app1 file match

@dcm31•Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 3 days ago
apiv1
papimark21