Back to packages list

Vals using @fal-ai/serverless-client

Description from the NPM package:
The fal serverless JS/TS client
Runs every 15 min
Fork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/** @jsxImportSource https://esm.sh/react */
import fal from "npm:@fal-ai/serverless-client";
import { renderToString } from "npm:react-dom/server";
export default async function(interval: Interval) {
const result = await fal.subscribe("fal-ai/supir", {
input: {
image_url: "https://storage.googleapis.com/falserverless/gallery/NOCA_Mick-Thompson.resized.resized.jpg",
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
console.log(result.image.url);
console.log(
renderToString(
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>gorkem</h1>
<img src={result.image.url} />
</body>
</html>,
),
{
headers: { "Content-Type": "text/html" },
},
);
}

Stable Video Diffusion

link to val - https://www.val.town/v/fal/svd

Create valimport * as fal from "@fal-ai/serverless-client"; const result = await fal.subscribe("fal-ai/fast-svd", { input: { image_url: "https://storage.googleapis.com/falserverless/model_tests/svd/rocket.png" }, logs: true, onQueueUpdate: (update) => { if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, });

https://www.fal.ai/models/svd/playground

rocket.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import fal from "npm:@fal-ai/serverless-client";
export let sd_video = async (
image_url: string,
motion_bucket_id: number = 127,
cond_aug: number = 0.02,
steps: number = 20,
deep_cache: string = "minimum",
fps: number = 10,
): Promise<{ video: { url: string } }> => {
return await fal.subscribe("fal-ai/fast-svd", {
input: {
image_url: image_url,
motion_bucket_id: motion_bucket_id,
cond_aug: cond_aug,
steps: steps,
deep_cache: deep_cache,
fps: fps,
},
});
};

Creative Upscaler

link to val - https://www.val.town/v/fal/creative_upscaler

Usage

Create valconst upscaledImage = @fal.creative_upscaler("an owl", "https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png")

Usage

Create valimport fal from "npm:@fal-ai/serverless-client"; const result = await fal.subscribe("fal-ai/creative-upscaler", { input: { prompt: "an owl", image_url: "https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png", }, logs: true, onQueueUpdate: (update) => { if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, });

https://www.fal.ai/models/creative-upscaler

owl.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import fal from "npm:@fal-ai/serverless-client";
export let creativeUpscaler = async (
prompt: string,
image_url: string,
creativity: number = 0.5,
detail: number = 1,
shape_preservation: number = 1.5,
negative_prompt: string =
"blurry, low resolution, bad, ugly, low quality, pixelated, interpolated, compression artifacts, noisey, grainy",
seed: number = 42,
guidance_scale: number = 7.5,
num_inference_steps: number = 20,
enable_safety_checks: boolean = true,
): Promise<{ image: { url: string } }> => {
return await fal.subscribe("fal-ai/creative-upscaler", {
input: {
prompt: prompt,
image_url: image_url,
creativity: creativity,
detail: detail,
shape_preservation: shape_preservation,
negative_prompt: negative_prompt,
seed: seed,
guidance_scale: guidance_scale,
num_inference_steps: num_inference_steps,
enable_safety_checks: enable_safety_checks,
},
});
};

SDXL (fastest)

https://www.fal.ai/models/stable-diffusion-xl

link to val - https://www.val.town/v/fal/sdxl

Create valimport * as fal from "npm:@fal-ai/serverless-client"; const result = await fal.subscribe("fal-ai/fast-sdxl", { input: { prompt: "photo of a rhino dressed suit and tie sitting at a table in a bar with a bar stools, award winning photography, Elke vogelsang" }, logs: true, onQueueUpdate: (update) => { if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, });

cheetah.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import fal from "npm:@fal-ai/serverless-client";
export let sdxl = async (
prompt: string,
negative_prompt: string = "cartoon, illustration, animation. face. male, female",
image_size: string = "square_hd",
num_inference_steps: number = 25,
guidance_scale: number = 7.5,
num_images: number = 1,
loras: [string] = [],
): Promise<{ images: [{ url: string }] }> => {
return await fal.subscribe("fal-ai/fast-sdxl", {
input: {
prompt: prompt,
negative_prompt: negative_prompt,
image_size: image_size,
num_inference_steps: num_inference_steps,
guidance_scale: guidance_scale,
num_images: num_images,
loras: [],
},
});
};

fal/sdxl

This val is an example usage sdxl with fal.ai's javascript client.

https://www.fal.ai/models/stable-diffusion-xl

The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is done running, or if you want to get the logs as they are being generated.

Create valimport fal from "npm:@fal-ai/serverless-client"; const result = await fal.subscribe(FUNCTION_ID, { input: { seed: 176400, }, pollInterval: 5000, logs: true, onQueueUpdate: (update) => { console.log(update.status); if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, }); console.log(result.url);

The onQueueUpdate callback will be called every time the queue status changes. The update object contains the queue status data as documented on the status types section.

1
2
3
4
5
6
7
import fal from "npm:@fal-ai/serverless-client";
export let sdxl = async (input: { prompt: string }): Promise<{images: [{url: string}]}> => {
return await fal.subscribe("fal-ai/fast-sdxl", {
input: input,
});
};
1
Next