Fal 프로바이더
Fal 프로바이더
Fal AI를 AI SDK에서 쓸 수 있게 해주는 프로바이더예요. Fal은 디퓨전(diffusion) 모델 실행에 최적화된, 경쟁사보다 최대 4배 빠른 추론 속도를 제공하는 생성형 미디어 플랫폼이에요.
출처: 문서
본문
Fal AI는 개발자를 위한 생성형 미디어 플랫폼으로, 매우 빠른 추론 능력을 제공해요. 이 플랫폼은 디퓨전 모델 실행에 최적화된 성능을 제공하며, 경쟁사보다 최대 4배 빠른 속도를 내요.
설정 (Setup)
Fal 프로바이더는 @ai-sdk/fal 모듈로 제공돼요. 다음과 같이 설치할 수 있어요:
프로바이더 인스턴스 (Provider Instance)
@ai-sdk/fal에서 기본 프로바이더 인스턴스 fal을 불러올 수 있어요:
import { fal } from '@ai-sdk/fal';
커스터마이즈가 필요하다면 createFal을 불러와 원하는 설정으로 프로바이더 인스턴스를 만들 수 있어요:
import { createFal } from '@ai-sdk/fal';
const fal = createFal({
apiKey: *** // optional, defaults to FAL_API_KEY environment variable, falling back to FAL_KEY
baseURL: 'custom-url', // optional
headers: {
/* custom headers */
}, // optional
});
Fal 프로바이더 인스턴스를 커스터마이즈할 때 사용할 수 있는 선택적 설정은 다음과 같아요:
-
baseURL string
API 호출에 다른 URL 접두사를 사용해요. 예를 들어 프록시 서버를 쓸 때 유용해요. 기본 접두사는
https://fal.run이에요. -
apiKey string
Authorization헤더로 보내는 API 키예요. 기본값은FAL_API_KEY환경 변수이며, 없으면FAL_KEY로 대체돼요. -
headers Record<string,string>
요청에 포함할 커스텀 헤더예요.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
커스텀 fetch 구현이에요. 요청을 가로채는 미들웨어로 쓸 수도 있고, 예를 들어 테스트용으로 커스텀 fetch 구현을 제공할 수도 있어요.
이미지 모델 (Image Models)
.image() 팩토리 메서드로 Fal 이미지 모델을 만들 수 있어요.
AI SDK에서 이미지 생성에 대해 더 알고 싶다면 generateImage()를 참고하세요.
기본 사용법 (Basic Usage)
import { fal } from '@ai-sdk/fal';
import { generateImage } from 'ai';
import fs from 'fs';
const { image, providerMetadata } = await generateImage({
model: fal.image('fal-ai/flux/dev'),
prompt: 'A serene mountain landscape at sunset',
});
const filename = `image-${Date.now()}.png`;
fs.writeFileSync(filename, image.uint8Array);
console.log(`Image saved to ${filename}`);
Fal 이미지 모델은 이미지와 요청에 대한 추가 정보를 반환할 수 있어요.
각 이미지에 대해 설정될 수 있는 속성의 예시는 다음과 같아요:
providerMetadata.fal.images[0].nsfw; // boolean, image is not safe for work
providerMetadata.fal.images[0].width; // number, image width
providerMetadata.fal.images[0].height; // number, image height
providerMetadata.fal.images[0].contentType; // string, mime type of the image
모델 기능 (Model Capabilities)
Fal은 다양한 사용 사례에 최적화된 많은 모델을 제공해요. 다음은 인기 있는 몇 가지 예시예요. 전체 모델 목록은 Fal AI 검색 페이지를 참고하세요.
| Model | Description |
|---|---|
fal-ai/flux/dev |
FLUX.1 [dev] model for high-quality image generation |
fal-ai/flux-pro/kontext |
FLUX.1 Kontext [pro] handles both text and reference images as inputs, enabling targeted edits and complex transformations |
fal-ai/flux-pro/kontext/max |
FLUX.1 Kontext [max] with improved prompt adherence and typography generation |
fal-ai/flux-lora |
Super fast endpoint for FLUX.1 with LoRA support |
fal-ai/ideogram/character |
Generate consistent character appearances across multiple images. Maintain facial features, proportions, and distinctive traits |
fal-ai/qwen-image |
Qwen-Image foundation model with significant advances in complex text rendering and precise image editing |
fal-ai/omnigen-v2 |
Unified image generation model for Image Editing, Personalized Image Generation, Virtual Try-On, Multi Person Generation and more |
fal-ai/bytedance/dreamina/v3.1/text-to-image |
Dreamina showcases superior picture effects with improvements in aesthetics, precise and diverse styles, and rich details |
fal-ai/recraft/v3/text-to-image |
SOTA in image generation with vector art and brand style capabilities |
fal-ai/wan/v2.2-a14b/text-to-image |
High-resolution, photorealistic images with fine-grained detail |
Fal 모델은 다음 종횡비를 지원해요:
- 1:1 (정사각형 HD)
- 16:9 (가로)
- 9:16 (세로)
- 4:3 (가로)
- 3:4 (세로)
- 16:10 (1280x800)
- 10:16 (800x1280)
- 21:9 (2560x1080)
- 9:21 (1080x2560)
Fal 모델의 주요 특징은 다음과 같아요:
- 경쟁사보다 최대 4배 빠른 추론 속도
- Fal Inference Engine™으로 최적화됨
- 실시간 인프라 지원
- 사용량 기반(pay-per-use) 요금제로 비용 효율적인 확장
- 모델 개인화를 위한 LoRA 학습 기능
이미지 수정 (Modify Image)
텍스트 프롬프트로 기존 이미지를 변형해요.
await generateImage({
model: fal.image('fal-ai/flux-pro/kontext/max'),
prompt: {
text: 'Put a donut next to the flour.',
images: [
'https://v3.fal.media/files/rabbit/rmgBxhwGYb2d3pl3x9sKf_output.png',
],
},
});
이미지는 base64로 인코딩된 문자열, Uint8Array, ArrayBuffer 또는 Buffer로도 전달할 수 있어요.
마스크도 전달할 수 있어요:
await generateImage({
model: fal.image('fal-ai/flux-pro/kontext/max'),
prompt: {
text: 'Put a donut next to the flour.',
images: [imageBuffer],
mask: maskBuffer,
},
});
프로바이더 옵션 (Provider Options)
Fal 이미지 모델은 providerOptions.fal 객체를 통해 유연한 프로바이더 옵션을 지원해요. 특정 Fal 모델 API가 지원하는 모든 파라미터를 전달할 수 있어요. 일반적인 옵션은 다음과 같아요:
- imageUrl - 이미지 간(image-to-image) 생성을 위한 참조 이미지 URL (사용 중단됨, 대신
prompt.images사용) - strength - 출력이 입력 이미지와 얼마나 다른지 조절해요
- guidanceScale - 프롬프트에 대한 준수도를 조절해요 (범위: 1-20)
- numInferenceSteps - 디노이징 스텝 수 (범위: 1-50)
- enableSafetyChecker - 안전 필터링 활성화/비활성화
- outputFormat - 출력 형식: 'jpeg' 또는 'png'
- syncMode - 응답을 반환하기 전에 완료를 기다려요
- acceleration - 생성 속도: 'none', 'regular' 또는 'high'
- safetyTolerance - 콘텐츠 안전 필터링 수준 (1-6, 1이 가장 엄격함)
- useMultipleImages - true로 설정하면 여러 입력 이미지를 여러 이미지를 지원하는 모델(예: fal-ai/flux-2/edit)의
image_urls배열로 변환해요
모델별 파라미터는 Fal AI 모델 문서를 참고하세요.
고급 기능 (Advanced Features)
Fal 플랫폼은 여러 고급 기능을 제공해요:
- 프라이빗 모델 추론: 자체 디퓨전 트랜스포머 모델을 최대 50% 더 빠른 추론으로 실행
- LoRA 학습: 5분 안에 모델 학습 및 개인화
- 실시간 인프라: 빠른 추론 시간으로 새로운 사용자 경험 활성화
- 확장 가능한 아키텍처: 필요할 때 수천 개의 GPU로 확장
Fal의 기능과 특징에 대한 자세한 내용은 Fal AI 문서를 참고하세요.
음성 인식 모델 (Transcription Models)
.transcription() 팩토리 메서드로 Fal 음성 인식 API를 호출하는 모델을 만들 수 있어요.
첫 번째 인자는 fal-ai/ 접두사가 없는 모델 id예요. 예를 들면 wizper죠.
const model = fal.transcription('wizper');
providerOptions 인자로 프로바이더별 추가 옵션을 전달할 수도 있어요. 예를 들어 batchSize 옵션을 주면 병렬로 처리되는 오디오 청크 수가 늘어나요.
import { transcribe } from 'ai';
import { fal, type FalTranscriptionModelOptions } from '@ai-sdk/fal';
import { readFile } from 'fs/promises';
const result = await transcribe({
model: fal.transcription('wizper'),
audio: await readFile('audio.mp3'),
providerOptions: {
fal: { batchSize: 10 } satisfies FalTranscriptionModelOptions,
},
});
다음 프로바이더 옵션들을 사용할 수 있어요:
-
language string 오디오 파일의 언어예요. 기본값은 'en'이에요. null로 설정하면 언어가 자동으로 감지돼요. 'en', 'fr', 'zh' 같은 ISO 언어 코드를 받아요. 선택 사항이에요.
-
diarize boolean 오디오 파일을 화자별로 분리(다른 화자 식별)할지 여부예요. 기본값은 true예요. 선택 사항이에요.
-
chunkLevel string 반환할 청크의 수준이에요. 'segment' 또는 'word' 중 하나예요. 기본값: "segment" 선택 사항이에요.
-
version string 사용할 모델의 버전이에요. 모든 모델은 Whisper large 변형이에요. 기본값: "3" 선택 사항이에요.
-
batchSize number 처리를 위한 배치 크기예요. 기본값: 64 선택 사항이에요.
-
numSpeakers number 오디오 파일의 화자 수예요. 제공하지 않으면 화자 수가 자동으로 감지돼요. 선택 사항이에요.
모델 기능 (Model Capabilities)
| Model | Transcription | Duration | Segments | Language |
|---|---|---|---|---|
whisper |
||||
wizper |
음성 모델 (Speech Models)
.speech() 팩토리 메서드로 Fal 텍스트-음성(text-to-speech) 엔드포인트를 호출하는 모델을 만들 수 있어요.
기본 사용법 (Basic Usage)
import { generateSpeech } from 'ai';
import { fal } from '@ai-sdk/fal';
const result = await generateSpeech({
model: fal.speech('fal-ai/minimax/speech-02-hd'),
text: 'Hello from the AI SDK!',
});
모델 기능 (Model Capabilities)
| Model | Description |
|---|---|
fal-ai/minimax/voice-clone |
Clone a voice from a sample audio and generate speech from text prompts |
fal-ai/minimax/voice-design |
Design a personalized voice from a text description and generate speech from text prompts |
fal-ai/dia-tts/voice-clone |
Clone dialog voices from a sample audio and generate dialogs from text prompts |
fal-ai/minimax/speech-02-hd |
Generate speech from text prompts and different voices |
fal-ai/minimax/speech-02-turbo |
Generate fast speech from text prompts and different voices |
fal-ai/dia-tts |
Directly generates realistic dialogue from transcripts with audio conditioning for emotion control. Produces natural nonverbals like laughter and throat clearing |
resemble-ai/chatterboxhd/text-to-speech |
Generate expressive, natural speech with Resemble AI's Chatterbox. Features unique emotion control, instant voice cloning from short audio, and built-in watermarking |
프로바이더 옵션 (Provider Options)
모델에 따라 providerOptions.fal로 프로바이더별 옵션을 전달해요:
-
voice_setting object
voice_id(string): 미리 정의된 음성 IDspeed(number): 0.5–2.0vol(number): 0–10pitch(number): -12–12emotion(enum): happy | sad | angry | fearful | disgusted | surprised | neutralenglish_normalization(boolean)
-
audio_setting object 모델별 오디오 구성 설정이에요.
-
language_boost enum Chinese | Chinese,Yue | English | Arabic | Russian | Spanish | French | Portuguese | German | Turkish | Dutch | Ukrainian | Vietnamese | Indonesian | Japanese | Italian | Korean | Thai | Polish | Romanian | Greek | Czech | Finnish | Hindi | auto
-
pronunciation_dict object 특정 단어에 대한 커스텀 발음 사전이에요.
모델별 파라미터(예: audio_url, prompt, preview_text, ref_audio_url, ref_text)는 providerOptions.fal 아래에 직접 전달할 수 있으며 Fal API로 전달돼요.
더 알아보기 (Learn more)
- AI Gateway
- xAI Grok
- OpenAI
- Azure OpenAI
- Anthropic
- Open Responses
- Claude Platform on AWS
- Amazon Bedrock
- Groq
- Fal
- AssemblyAI
- GMI Cloud
- TypeSafe
- DeepInfra
- Deepgram
- Black Forest Labs
- Gladia
- Hume
- Google Vertex AI
- Rev.ai
- Baseten
- Hugging Face
- QuiverAI
- Fish Audio
- Mistral AI
- Z.AI
- Together.ai
- Cohere
- Fireworks
- Voyage AI
- DeepSeek
- Moonshot AI
- Alibaba
- MiniMax
- Cerebras
- Replicate
- Prodia
- Perplexity
- Luma
- ByteDance
- Kling AI
- ElevenLabs
- Cartesia