diff --git a/packages/inference/src/providers/fal-ai.ts b/packages/inference/src/providers/fal-ai.ts index 93d1b4e24d..d086105276 100644 --- a/packages/inference/src/providers/fal-ai.ts +++ b/packages/inference/src/providers/fal-ai.ts @@ -8,6 +8,14 @@ export const FAL_AI_SUPPORTED_MODEL_IDS: ProviderMapping = { "text-to-image": { "black-forest-labs/FLUX.1-schnell": "fal-ai/flux/schnell", "black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev", + "playgroundai/playground-v2.5-1024px-aesthetic": "fal-ai/playground-v25", + "ByteDance/SDXL-Lightning": "fal-ai/lightning-models", + "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS": "fal-ai/pixart-sigma", + "stabilityai/stable-diffusion-3-medium": "fal-ai/stable-diffusion-v3-medium", + "Warlord-K/Sana-1024": "fal-ai/sana", + "fal/AuraFlow-v0.2": "fal-ai/aura-flow", + "stabilityai/stable-diffusion-3.5-large": "fal-ai/stable-diffusion-v35-large", + "Kwai-Kolors/Kolors": "fal-ai/kolors", }, "automatic-speech-recognition": { "openai/whisper-large-v3": "fal-ai/whisper", diff --git a/packages/inference/test/HfInference.spec.ts b/packages/inference/test/HfInference.spec.ts index d2db78fd4c..7e09a1763a 100644 --- a/packages/inference/test/HfInference.spec.ts +++ b/packages/inference/test/HfInference.spec.ts @@ -2,7 +2,7 @@ import { expect, it, describe, assert } from "vitest"; import type { ChatCompletionStreamOutput } from "@huggingface/tasks"; -import { chatCompletion, HfInference } from "../src"; +import { chatCompletion, FAL_AI_SUPPORTED_MODEL_IDS, HfInference } from "../src"; import "./vcr"; import { readTestFile } from "./test-files"; @@ -775,25 +775,30 @@ describe.concurrent("HfInference", () => { () => { const client = new HfInference(env.HF_FAL_KEY); - it("textToImage", async () => { - const res = await client.textToImage({ - model: "black-forest-labs/FLUX.1-schnell", - provider: "fal-ai", - inputs: "black forest gateau cake spelling out the words FLUX SCHNELL, tasty, food photography, dynamic shot", + for (const model of Object.keys(FAL_AI_SUPPORTED_MODEL_IDS["text-to-image"] ?? {})) { + it(`textToImage - ${model}`, async () => { + const res = await client.textToImage({ + model, + provider: "fal-ai", + inputs: + "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.", + }); + expect(res).toBeInstanceOf(Blob); }); - expect(res).toBeInstanceOf(Blob); - }); + } - it("speechToText", async () => { - const res = await client.automaticSpeechRecognition({ - model: "openai/whisper-large-v3", - provider: "fal-ai", - data: new Blob([readTestFile("sample2.wav")], { type: "audio/x-wav" }), - }); - expect(res).toMatchObject({ - 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", + for (const model of Object.keys(FAL_AI_SUPPORTED_MODEL_IDS["automatic-speech-recognition"] ?? {})) { + it(`automaticSpeechRecognition - ${model}`, async () => { + const res = await client.automaticSpeechRecognition({ + model: model, + provider: "fal-ai", + data: new Blob([readTestFile("sample2.wav")], { type: "audio/x-wav" }), + }); + expect(res).toMatchObject({ + 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", + }); }); - }); + } }, TIMEOUT ); diff --git a/packages/inference/test/tapes.json b/packages/inference/test/tapes.json index 2c2454a836..d04ef96892 100644 --- a/packages/inference/test/tapes.json +++ b/packages/inference/test/tapes.json @@ -4417,5 +4417,400 @@ "content-type": "image/jpeg" } } + }, + "67b3d4f2d49138e39199dfa5f25c29ac8a50a3d698f05c28e2d38546f6c72559": { + "url": "https://fal.run/fal-ai/flux/schnell", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/panda/Z8oLxNTAj2krojA0xvcUl.png\",\"width\":1024,\"height\":768,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":0.350045086001046},\"seed\":233640447,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "f9d6f2a5ee5ad57cf1f856865ba372c725d292ff6a37cdf8c7a5b3c75c71ceb2": { + "url": "https://fal.run/fal-ai/lightning-models", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/lion/7UDNWraxHPAeq0I_bdWI-.jpeg\",\"width\":1024,\"height\":1024,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":1.0830712877213955},\"seed\":641424801031262500,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "9f91a71d1dbe5ec622cbab3d03d93989accf30d594c82dd60c1a9161fab3bfa7": { + "url": "https://fal.run/fal-ai/playground-v25", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/zebra/PNT83Bs9r1XMdUnC06wtr.jpeg\",\"width\":1024,\"height\":1024,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":2.149031490087509},\"seed\":10398461630160527000,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "9479f1185786a6966ed4b8bd5d9f51637aeb6807f96836f8389d4dd80b6c165b": { + "url": "https://fal.run/fal-ai/flux/dev", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/panda/DjCUrjd9XWB4HQWaBumzV.png\",\"width\":1024,\"height\":768,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":2.11526345461607},\"seed\":2213364957,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "0148bba75177a730f92ac510a9bc79da8344ac224aa60ac5689dc459f0f76fe3": { + "url": "https://fal.media/files/panda/Z8oLxNTAj2krojA0xvcUl.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "905656146879f0a7-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "41d01170eb2f0ac3244f7949b176bdf48120bd16d4d1c6b21dc354335a5caa6c": { + "url": "https://fal.media/files/lion/7UDNWraxHPAeq0I_bdWI-.jpeg", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "905656177fd49f0d-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "ff81384a7053c76b045331780569d6d11dd73f774e7da242e0ba7eba8edbddb4": { + "url": "https://fal.media/files/zebra/PNT83Bs9r1XMdUnC06wtr.jpeg", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "9056561e6bfe6988-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "66803eeacc0523443406c74ffe875fb022ebf5fd71cb3bd1d20be28691eae241": { + "url": "https://fal.media/files/panda/DjCUrjd9XWB4HQWaBumzV.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "9056561f1c0a6ffa-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "98283a4c77df520259f27e61d45406be1ab9c6cf40e67eda375a3f9873dc6346": { + "url": "https://fal.run/fal-ai/stable-diffusion-v3-medium", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/zebra/qI7r_ddDsCzyf5uuHTS3E.png\",\"width\":1024,\"height\":1024,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":2.069054855965078},\"seed\":1124357570561742500,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\",\"num_images\":1}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "9ee2e03a1a9fed2353bf678bb7b63aa742c0e1cb25c3e73479a650aca18ea568": { + "url": "https://fal.run/fal-ai/sana", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/koala/KKElSWj-qbgPU3fKhDHYa.png\",\"width\":3840,\"height\":2160,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":0.903161916998215},\"seed\":12085242580823972000,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "ef836d4f830d75959631d571b57470b19bf6855779d42b812a378fdbe420f6a2": { + "url": "https://fal.media/files/zebra/qI7r_ddDsCzyf5uuHTS3E.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "90565633eb60f0a7-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "891accf5590e7fdb2dfc628b6c2d42953b75fc4a09b1145e66de6a53edc07d84": { + "url": "https://fal.media/files/koala/KKElSWj-qbgPU3fKhDHYa.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "905656353cfb9f0d-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "59b7b7c1b3a23279a63433f61797579014b32b49124c0d7ce7144f3f1a9f6530": { + "url": "https://fal.run/fal-ai/stable-diffusion-v35-large", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/monkey/fDR6A058udCIyHelOIj-O.jpeg\",\"width\":1024,\"height\":768,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":9.080452139023691},\"seed\":16357541570974532000,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "82ee0d9b06d970057e0f48b46c019efb0fa571f2c038220950dab8fad88caf19": { + "url": "https://fal.media/files/monkey/fDR6A058udCIyHelOIj-O.jpeg", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "905656687aac22a5-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "f3cf9ae391e7e9ca38c9f7a67db6383fad9556dfdb93437b6da8b6d0bbbcc97f": { + "url": "https://fal.run/fal-ai/kolors", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/zebra/4h2t1IW2QlkpKSFk7-Zuz.png\",\"width\":1024,\"height\":1024,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":9.687951150815934},\"seed\":1571647811,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "b5fda4475fccc8aed93c0339c94360ad3bae12485676c7eecd57aa2fd7673186": { + "url": "https://fal.media/files/zebra/4h2t1IW2QlkpKSFk7-Zuz.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "905656803e7a22a5-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } + }, + "8031ef4feb2f23b89eb5c4abdabcaed7bcceea940ee2f54090acef0f7f1a002f": { + "url": "https://fal.run/fal-ai/aura-flow", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://v2.fal.media/files/92d4f92cf5314d2390d117f10511dcff_ad61629c86a24658acf829bf6a0d0e13.png\",\"content_type\":\"image/png\",\"file_name\":\"ad61629c86a24658acf829bf6a0d0e13.png\",\"file_size\":2061522,\"width\":1024,\"height\":1024}],\"seed\":2974735643,\"prompt\":\"an extreme close-up of a single tiger eye, viewed directly from a frontal perspective, showcases intricate details of the iris and pupil. the sharp focus emphasizes the eye's textured surface, with the intricate patterns of brown and gold colors on the iris and the black pupil seeming to pull the viewer in. natural lighting illuminates the eye, capturing authentic eye shine and depth, with a subtle emphasis on the sparkling yellow and orange hues that dance across the surface.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "a351e35c81f9a318371c38d78b7d5dc28725176662f228ea9afe1fbc41e750f4": { + "url": "https://v2.fal.media/files/92d4f92cf5314d2390d117f10511dcff_ad61629c86a24658acf829bf6a0d0e13.png", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "cache-control": "max-age=31536000", + "content-type": "image/png", + "fly-request-id": "01JJ43PMFZ4JBXTYYNJHB9HEXQ-cdg", + "server": "Fly/a3e18ae92 (2025-01-16)" + } + } + }, + "2aaf3addc0cb935724209a15cc9fa223cb3dbe3bd136541d5c9284ab66298fc3": { + "url": "https://fal.run/fal-ai/pixart-sigma", + "init": { + "headers": { + "Content-Type": "application/json" + }, + "method": "POST", + "body": "{\"prompt\":\"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.\",\"response_format\":\"base64\"}" + }, + "response": { + "body": "{\"images\":[{\"url\":\"https://fal.media/files/kangaroo/wtbBElnW7DO27a-PFypWh.jpeg\",\"width\":1024,\"height\":1024,\"content_type\":\"image/jpeg\"}],\"timings\":{\"inference\":6.405372703913599},\"seed\":1432522481,\"has_nsfw_concepts\":[false],\"prompt\":\"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.\"}", + "status": 200, + "statusText": "OK", + "headers": { + "connection": "keep-alive", + "content-type": "application/json", + "strict-transport-security": "max-age=31536000; includeSubDomains" + } + } + }, + "2fa17e1c710d0d172b8f6e48dcf718f311d473eceb40375fdda47d60b017be42": { + "url": "https://fal.media/files/kangaroo/wtbBElnW7DO27a-PFypWh.jpeg", + "init": {}, + "response": { + "body": "", + "status": 200, + "statusText": "OK", + "headers": { + "access-control-allow-headers": "*", + "access-control-allow-methods": "*", + "access-control-allow-origin": "*", + "access-control-max-age": "86400", + "cf-ray": "9056586a0f4bbb46-CDG", + "connection": "keep-alive", + "content-type": "image/jpeg", + "server": "cloudflare", + "vary": "Accept-Encoding" + } + } } } \ No newline at end of file