Skip to content

Commit 1a07402

Browse files
gokayfemaykutkardasSBrandeis
authored
Add fal.ai inference endpoints (#1104)
Adds fal.ai inference endpoints --------- Co-authored-by: Aykut Kardaş <[email protected]> Co-authored-by: SBrandeis <[email protected]>
1 parent 44e9e02 commit 1a07402

File tree

3 files changed

+425
-17
lines changed

3 files changed

+425
-17
lines changed

packages/inference/src/providers/fal-ai.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ export const FAL_AI_SUPPORTED_MODEL_IDS: ProviderMapping<FalAiId> = {
88
"text-to-image": {
99
"black-forest-labs/FLUX.1-schnell": "fal-ai/flux/schnell",
1010
"black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev",
11+
"playgroundai/playground-v2.5-1024px-aesthetic": "fal-ai/playground-v25",
12+
"ByteDance/SDXL-Lightning": "fal-ai/lightning-models",
13+
"PixArt-alpha/PixArt-Sigma-XL-2-1024-MS": "fal-ai/pixart-sigma",
14+
"stabilityai/stable-diffusion-3-medium": "fal-ai/stable-diffusion-v3-medium",
15+
"Warlord-K/Sana-1024": "fal-ai/sana",
16+
"fal/AuraFlow-v0.2": "fal-ai/aura-flow",
17+
"stabilityai/stable-diffusion-3.5-large": "fal-ai/stable-diffusion-v35-large",
18+
"Kwai-Kolors/Kolors": "fal-ai/kolors",
1119
},
1220
"automatic-speech-recognition": {
1321
"openai/whisper-large-v3": "fal-ai/whisper",

packages/inference/test/HfInference.spec.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, it, describe, assert } from "vitest";
22

33
import type { ChatCompletionStreamOutput } from "@huggingface/tasks";
44

5-
import { chatCompletion, HfInference } from "../src";
5+
import { chatCompletion, FAL_AI_SUPPORTED_MODEL_IDS, HfInference } from "../src";
66
import "./vcr";
77
import { readTestFile } from "./test-files";
88

@@ -775,25 +775,30 @@ describe.concurrent("HfInference", () => {
775775
() => {
776776
const client = new HfInference(env.HF_FAL_KEY);
777777

778-
it("textToImage", async () => {
779-
const res = await client.textToImage({
780-
model: "black-forest-labs/FLUX.1-schnell",
781-
provider: "fal-ai",
782-
inputs: "black forest gateau cake spelling out the words FLUX SCHNELL, tasty, food photography, dynamic shot",
778+
for (const model of Object.keys(FAL_AI_SUPPORTED_MODEL_IDS["text-to-image"] ?? {})) {
779+
it(`textToImage - ${model}`, async () => {
780+
const res = await client.textToImage({
781+
model,
782+
provider: "fal-ai",
783+
inputs:
784+
"Extreme close-up of a single tiger eye, direct frontal view. Detailed iris and pupil. Sharp focus on eye texture and color. Natural lighting to capture authentic eye shine and depth.",
785+
});
786+
expect(res).toBeInstanceOf(Blob);
783787
});
784-
expect(res).toBeInstanceOf(Blob);
785-
});
788+
}
786789

787-
it("speechToText", async () => {
788-
const res = await client.automaticSpeechRecognition({
789-
model: "openai/whisper-large-v3",
790-
provider: "fal-ai",
791-
data: new Blob([readTestFile("sample2.wav")], { type: "audio/x-wav" }),
792-
});
793-
expect(res).toMatchObject({
794-
text: " he has grave doubts whether sir frederick leighton's work is really greek after all and can discover in it but little of rocky ithaca",
790+
for (const model of Object.keys(FAL_AI_SUPPORTED_MODEL_IDS["automatic-speech-recognition"] ?? {})) {
791+
it(`automaticSpeechRecognition - ${model}`, async () => {
792+
const res = await client.automaticSpeechRecognition({
793+
model: model,
794+
provider: "fal-ai",
795+
data: new Blob([readTestFile("sample2.wav")], { type: "audio/x-wav" }),
796+
});
797+
expect(res).toMatchObject({
798+
text: " he has grave doubts whether sir frederick leighton's work is really greek after all and can discover in it but little of rocky ithaca",
799+
});
795800
});
796-
});
801+
}
797802
},
798803
TIMEOUT
799804
);

0 commit comments

Comments
 (0)