Vercel Fal IntegrationMarketplace
Learn how to integrate Fal with Vercel.Fal enables the development of real-time AI applications with a focus on rapid inference speeds, achieving response times under ~120ms. Specializing in diffusion models, Fal has no cold starts and a pay-for-what-you-use pricing model.
You can use the Vercel and Fal integration to power a variety of AI applications, including:
- Text-to-image applications: Use Fal to integrate real-time text-to-image generation in applications, enabling users to create complex visual content from textual descriptions instantly
- Real-time image processing: Use Fal for applications requiring instantaneous image analysis and modification, such as real-time filters, enhancements, or object recognition in streaming video
- Depth maps creation: Use Fal's AI models for generating depth maps from images, supporting applications in 3D modeling, augmented reality, or advanced photography editing, where understanding the spatial relationships in images is crucial
Fal provides a diverse range of AI models designed for high-performance tasks in image and text processing.
Stable Diffusion XL
Type: Image
Run SDXL at the speed of light
Creative Upscaler
Type: Image
Create creative upscaled images.
Stable Diffusion XL
Type: Image
Run SDXL at the speed of light
The Vercel Fal integration can be accessed through the AI tab on your Vercel dashboard.
To follow this guide, you'll need the following:
- An existing Vercel project
- The latest version of Vercel CLI
pnpm i -g vercel@latest
- Navigate to the AI tab in your Vercel dashboard
- Select Fal from the list of providers, and press Add
- Review the provider information, and press Add Provider
- You can now select which projects the provider will have access to. You can choose from All Projects or Specific Projects
- If you select Specific Projects, you'll be prompted to select the projects you want to connect to the provider. The list will display projects associated with your scoped team
- Multiple projects can be selected during this step
- Select the Connect to Project button
- You'll be redirected to the provider's website to complete the connection process
- Once the connection is complete, you'll be redirected back to the Vercel dashboard, and the provider integration dashboard page. From here you can manage your provider settings, view usage, and more
- Pull the environment variables into your project using Vercel CLI
terminal
vercel env pull .env.development.local
- Install the providers package
pnpm i @fal-ai/serverless-client
- Connect your project using the code below:
app/api/fal/proxy/route.ts// app/api/fal/proxy/route.tsimport { route } from '@fal-ai/serverless-proxy/nextjs';export const { GET, POST } = route;
- Add the provider to your page using the code below:
app/sdxl/page.tsx// app/sdxl/page.tsximport * as fal from '@fal-ai/serverless-client';import { useMemo, useState } from 'react';fal.config({// see the route.ts for the proxy setupproxyUrl: '/api/fal/proxy',});type Image = {url: string;file_name: string;file_size: number;};type Result = {images: Image[];};const DEFAULT_PROMPT ='an astronaut riding a horse on mars, hd, dramatic lighting, detailed';function Page() {const [prompt, setPrompt] = useState<string>(DEFAULT_PROMPT);const [loading, setLoading] = useState(false);const [error, setError] = useState<Error | null>(null);const [result, setResult] = useState<Result | null>(null);const image = useMemo(() => {if (!result) {return null;}return result.images[0];}, [result]);const reset = () => {setLoading(false);setError(null);setResult(null);};const generateImage = async () => {reset();setLoading(true);try {const result: Result = await fal.subscribe('fal-ai/fast-sdxl', {input: {prompt,},});setResult(result);} catch (error: any) {setError(error);} finally {setLoading(false);}};return (<main><div><label htmlFor="prompt">Prompt</label><inputid="prompt"name="prompt"placeholder="Imagine..."value={prompt}autoComplete="off"onChange={(e) => setPrompt(e.target.value)}onBlur={(e) => setPrompt(e.target.value.trim())}/></div><buttononClick={(e) => {e.preventDefault();generateImage();}}disabled={loading}>{loading ? 'Generating...' : 'Generate Image'}</button>{error && <div>{error.message}</div>}<div><div>{image && (// eslint-disable-next-line @next/next/no-img-element<img src={image.url} alt="" />)}</div></div></main>);}export default Page;
Was this helpful?