Open Source · MIT License

One function.
1,929 AI models.

A unified TypeScript library that gives you access to AI models across fal-ai, Replicate, and WaveSpeed through a single generate() call. Zero dependencies. Full type safety.

example.ts
import { generate, listModels } from 'getaiapi'

// Generate an image
const image = await generate({
  model: 'flux-schnell',
  prompt: 'a cat wearing sunglasses'
})
console.log(image.outputs[0].url)

// Generate a video
const video = await generate({
  model: 'veo3.1',
  prompt: 'a timelapse of a flower blooming'
})

// Discover models by category
const models = listModels({ category: 'text-to-video' })
// => 308 video generation models
1,929 AI Models
3 Providers
16 Categories
0 Dependencies

Everything you need, nothing you don't

Stop juggling SDKs. One import, one function, every AI model.

Unified API

One generate() function handles image generation, video creation, audio synthesis, upscaling, and more across all providers.

Zero Dependencies

Uses native fetch for all provider communication. No bloated dependency trees or version conflicts.

Type-Safe

Full TypeScript support with strict type checking and comprehensive type definitions for every model and parameter.

Smart Discovery

Browse, filter, and search models by category, provider, or keyword. Only shows models for which you have valid API keys.

Typed Error Handling

Custom error classes like AuthError, ModelNotFoundError, and RateLimitError give you precise control over failure scenarios.

Multi-Provider

Seamlessly switch between fal-ai, Replicate, and WaveSpeed without changing your code. Same input, same output shape.

Up and running in 60 seconds

Install, configure your API keys, and start generating.

1

Install the package

# npm
$ npm install getaiapi

# yarn
$ yarn add getaiapi

# pnpm
$ pnpm add getaiapi
2

Set your API keys

# .env — only set keys for
# providers you want to use

# fal-ai (1,199 models)
FAL_KEY="your-fal-key"

# Replicate (687 models)
REPLICATE_API_TOKEN="your-token"

# WaveSpeed (43 models)
WAVESPEED_API_KEY="your-key"
3

Generate anything

import { generate } from 'getaiapi'

const result = await generate({
  model: 'flux-schnell',
  prompt: 'a sunset over mountains'
})

console.log(result.outputs[0].url)
// => https://...generated-image.png

One function for every modality

Images, videos, audio, 3D models, upscaling, background removal — all through generate().

Text to Video

Generate videos from text prompts

const video = await generate({
  model: 'veo3.1',
  prompt: 'a timelapse of a flower blooming in a garden'
})

Image to Video

Animate still images with AI

const video = await generate({
  model: 'kling-v3-pro',
  image: 'https://example.com/scene.jpg',
  prompt: 'camera slowly pans right',
  options: { duration: '5' }
})

Image Editing

Edit images with natural language

const edited = await generate({
  model: 'gpt-image-1.5-edit',
  image: 'https://example.com/photo.jpg',
  prompt: 'add a rainbow in the sky'
})

Text to Speech

Convert text to natural speech

const speech = await generate({
  model: 'elevenlabs-v3',
  prompt: 'Hello, welcome to our app.',
  options: { voice_id: 'rachel' }
})

Upscale Image

Enhance resolution with AI upscaling

const upscaled = await generate({
  model: 'topaz-upscale-image',
  image: 'https://example.com/low-res.jpg'
})

Remove Background

Isolate subjects from any image

const cutout = await generate({
  model: 'birefnet-v2',
  image: 'https://example.com/portrait.jpg'
})

Simple, predictable interfaces

Every request follows the same shape. Every response is consistent, regardless of provider.

GenerateRequest

Input parameters for the generate() function

type GenerateRequest = {
  model: string          // model name or alias
  prompt?: string        // text prompt
  image?: string | File  // input image
  audio?: string | File  // input audio
  video?: string | File  // input video
  negative_prompt?: string
  count?: number        // number of outputs
  size?: string | { width, height }
  seed?: number         // reproducibility
  guidance?: number     // guidance scale
  steps?: number        // inference steps
  strength?: number     // denoising strength
  format?: 'png' | 'jpeg' | 'webp' | ...
  quality?: number
  safety?: boolean
  options?: Record<string, unknown>
}

GenerateResponse

Unified output from any provider

type GenerateResponse = {
  id: string
  model: string
  provider: string
  status: 'completed' | 'failed'
  outputs: OutputItem[]
  metadata: {
    seed?: number
    inference_time_ms?: number
    cost?: number
    safety_flagged?: boolean
  }
}

type OutputItem = {
  type: 'image' | 'video' | 'audio' | ...
  url: string
  content_type: string
  size_bytes?: number
}

Find the right model instantly

Browse, filter, and search across all 1,929 models. Results are automatically scoped to providers where you have valid keys.

discovery.ts
import { listModels, getModel } from 'getaiapi'

// All available models (filtered by your API keys)
const all = listModels()

// Filter by category
const videoModels = listModels({ category: 'text-to-video' })

// Filter by provider
const falModels = listModels({ provider: 'fal-ai' })

// Search by name
const fluxModels = listModels({ query: 'flux' })

// Get specific model details
const model = getModel('flux-schnell')
// => { canonical_name, aliases, category, modality, providers }

Replace SDK-specific code in minutes

No more memorizing provider endpoints or parsing provider-specific response formats.

Before — Direct fal.ai SDK
import { fal } from '@fal-ai/client'

const result = await fal.subscribe(
  'fal-ai/kling-video/v3/pro/image-to-video',
  {
    input: {
      image_url: imageUrl,
      prompt: prompt,
      duration: '5',
      cfg_scale: 0.5,
      negative_prompt: 'blurry'
    }
  }
)

// Parse provider-specific response...
const url = result.data?.video?.url
After — getaiapi
import { generate } from 'getaiapi'

const result = await generate({
  model: 'kling-v3-pro',
  image: imageUrl,
  prompt: prompt,
  options: {
    duration: '5',
    cfg_scale: 0.5,
    negative_prompt: 'blurry'
  }
})

// Unified response — always the same shape
const url = result.outputs[0].url

Typed errors for every scenario

All errors extend GetAIApiError with specific classes so you can handle each case precisely.

error-handling.ts
import {
  generate,
  AuthError,
  ModelNotFoundError,
  ProviderError,
  RateLimitError
} from 'getaiapi'

try {
  const result = await generate({
    model: 'flux-schnell',
    prompt: 'a cat'
  })
} catch (err) {
  if (err instanceof AuthError) {
    // err.envVar, err.provider
    console.error(`Set ${err.envVar}`)
  }
  if (err instanceof ModelNotFoundError) {
    // Includes "did you mean?" suggestions
    console.error(err.message)
  }
  if (err instanceof RateLimitError) {
    // HTTP 429 — retry later
  }
}
Error Class When it's thrown
AuthError Missing or invalid API key for the provider
ModelNotFoundError Model name could not be resolved (includes suggestions)
ValidationError Invalid input parameters
ProviderError Provider returned an error response
TimeoutError Generation exceeded timeout
RateLimitError Provider returned HTTP 429

Three providers, one interface

Access the full catalog of models from each provider with your existing API keys.

fal-ai
1,199
models available
FAL_KEY
Replicate
687
models available
REPLICATE_API_TOKEN
WaveSpeed
43
models available
WAVESPEED_API_KEY

16 model categories

From image generation to speech synthesis, every major AI modality is covered.

Text to Image 828
Text to Video 308
Image Editing 213
Image to Video 178
Text to Audio 76
Image Upscaling 59
Model Training 50
Image to Image 43
Segmentation 34
Image to 3D 31
Audio to Text 25
Background Removal 24
Text to 3D 19
Video to Audio 18
Video Upscaling 15
Moderation 8

Start building in seconds

Install the package, set your API keys, and call generate(). It's that simple.

$ npm install getaiapi