Search

ask_ai_example
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { askAI } from "https://esm.town/v/pomdtr/ask_ai";
await askAI("Send me an email with a random joke");

exa
@yawnxyz
// console.log(await search('banana'))
Script
const exa = new Exa(Deno.env.get("EXA_API_KEY"));
export const exaSearch = async ({ query, type, useAutoprompt, numResults, text, summary=true, highlights }) => {
const result = await exa.searchAndContents(
query,
type: type || "auto" || "neural",
useAutoprompt: useAutoprompt || true,
numResults: 10,
highlights: highlights || {
numSentences: 3,
highlightsPerUrl: 1,
aiBasicExample
@kora
Using Vercel AI SDK
Script
Using Vercel AI SDK
import { ModelProvider, modelProvider } from "https://esm.town/v/yawnxyz/ai";
// basic text generation
let response = await modelProvider.gen({
prompt: "hello, who am I speaking to?",
provider: "google",
} as any);
console.log("res:", response);

cerebras_coder
@stevekrouse
Moved to https://www.val.town/x/stevekrouse/cerebras_coder
HTTP
Moved to https://www.val.town/x/stevekrouse/cerebras_coder
export default () =>
Response.redirect(
"https://cerebrascoder.com/",

hello
@backspaces
An interactive, runnable TypeScript val by backspaces
Script
import * as util from "https://code.agentscript.org/src/utils.js";
const model = new Model();
await model.startup();
model.setup();
console.log("Running for 500 steps.");
util.repeat(500, model.step);
const sample = util.sampleModel(model);
console.log(sample);
mockToApi
@nbbaier
This val demonstrates the creation of an API with a programmatically generated set of data instead of an existing Val Town lowdb instance.
HTTP
This val demonstrates the [creation of an API](https://www.val.town/v/nbbaier/dbToAPI) with a programmatically generated set of data instead of an existing Val Town [lowdb](https://www.val.town/v/pomdtr/lowdb) instance.
const mock = () => {
const data = { users: [], posts: [], random: {} };
for (let i = 0; i < 25; i++) {
const user: string = faker.person.fullName(); // Rowan Nikolaus
const userSplit: string[] = user.split(" ");
const email: string = userSplit[0].endsWith(".")
? userSplit[1].toLowerCase() + "." + userSplit[2].toLowerCase() + "@"
+ faker.internet.domainName()
: userSplit[0].toLowerCase() + "." + user.split(" ")[1].toLowerCase() + "@"
generativeFill
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const replicate = new Replicate({
auth: Deno.env.get("REPLICATE_API_KEY"),
export default serve({
async *handleMessage(req) {
const lastMsg = req.query.at(-1);
if (lastMsg && lastMsg.attachments.length !== 2) {
yield events.replace("No image recieved");
yield html;
yield events.done();
return;
braintrustSDK
@charmaine
Braintrust SDK Braintrust is a platform for evaluating and shipping AI products. To learn more about Braintrust or sign up for free,
visit the website or check out the docs . The SDKs include utilities to: Log experiments and datasets to Braintrust Run evaluations (via the Eval framework) This template shows you how to use the Braintrust SDK. This starter template was ported from this one on GitHub . To run it: Click Fork on this val Get your Braintrust API key at https://www.braintrust.dev/app/settings?subroute=api-keys Add it to your project Environment Variables as BRAINTRUST_API_KEY Click Run on the tutorial val
Script
# Braintrust SDK
[Braintrust](https://www.braintrust.dev/) is a platform for evaluating and shipping AI products. To learn more about Braintrust or sign up for free,
visit the [website](https://www.braintrust.dev/) or check out the [docs](https://www.braintrust.dev/docs).
The SDKs include utilities to:
- Log experiments and datasets to Braintrust
- Run evaluations (via the `Eval` framework)
Eval("Say Hi Bot", {
data: () => {
return [
input: "Foo",
justATest
@charmaine
An interactive, runnable TypeScript val by charmaine
Script
Eval("Say Hi Bot", {
data: () => {
return [
input: "Foo",
expected: "Hi Foo",
input: "Bar",
expected: "Hello Bar",
]; // Replace with your eval dataset
task: (input) => {
return "Hi " + input; // Replace with your LLM call
fiberplane
@nbbaier
An interactive, runnable TypeScript val by nbbaier
HTTP
extendZodWithOpenApi(z);
const app = new Hono();
const nameValidation = z.object({
name: z
.string()
.optional()
.openapi({ example: "Steven", description: "User Name", ref: "name" }),
app.get(
describeRoute({
description: "Say hello to the user",
emeraldCrocodile
@burkaygur
An interactive, runnable TypeScript val by burkaygur
Script
import * as fal from "npm:@fal-ai/serverless-client";
fal.config({
// Can also be auto-configured using environment variables:
credentials: Deno.env.get("FAL_KEY"),
const prompt = "a cute and happy dog";
const result: any = await fal.run("fal-ai/fast-lightning-sdxl", { input: { prompt } });
console.log(result.images[0].url);
daringBronzeSnail
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
export default serve({
async *handleMessage(req) {
yield "hello";
await sleep(1000);
yield events.replace("goodbye");
await sleep(1000);
yield events.error({
allow_retry: true,
text: "ooops!",
yield events.done();
testplaywright
@alexdphan
// Import Playwright using the Deno-compatible URL
Script
// Import Playwright using the Deno-compatible URL
// import { chromium } from "https://esm.sh/playwright-core";
console.info("Launching browser...");
// Use Deno.env to get the API key
const apiKey = Deno.env.get("BROWSERBASE_API_KEY");
if (!apiKey) {
console.error("BROWSERBASE_API_KEY environment variable is not set");
Deno.exit(1);
try {
const browser = await chromium.connectOverCDP(
arenaApiExample
@deblina
Are.na API Example of using the are.na API to get the contents of an Are.na board - specifically my fun board that showcases websites with that "glossy black style." All you need is fetch to make this happen!
Script
# Are.na API
Example of using the [are.na](https://dev.are.na/documentation/channels#Block43472) API to get the contents of an Are.na board - specifically my fun board that showcases websites with that "glossy black style."
All you need is [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to make this happen!
import { fetch } from "https://esm.town/v/std/fetch";
export let arenaApiExample = (async () => {
const resp = await fetch(
"http://api.are.na/v2/channels/project-logs",
const json = await resp.json();
console.log(json);
return json;

tempsimplegptexample
@vlad
// Example of action that doesn't accept any input, but returns something
HTTP
* INITIALIZE API
const api = new GptApi({
url: "https://vlad-tempsimplegptexample.web.val.run",
title: "Some API",
description: "API for something",
version: "1.0.0",
// Example of action that doesn't accept any input, but returns something
const ResponseCommandSchema = z.object({
feedback: z.string().describe("Feedback regarding submitted action"),
data: z.string().optional().describe("Additional data related to the given command"),