getaiapi 1.0.0-alpha.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
8
8
 
9
- A unified TypeScript library that wraps 1,876+ AI models across 4 providers into a single `generate()` function. One input shape. One output shape. Any model.
9
+ A unified TypeScript library that wraps 1,940+ AI models across 4 providers into a single `generate()` function. One input shape. One output shape. Any model.
10
10
 
11
11
  ## Install
12
12
 
@@ -187,13 +187,13 @@ Models are automatically filtered to only show providers where you have a valid
187
187
  ## Model Discovery
188
188
 
189
189
  ```typescript
190
- import { listModels, getModel } from 'getaiapi'
190
+ import { listModels, resolveModel, deriveCategory } from 'getaiapi'
191
191
 
192
- // List all available models (filtered by your API keys)
192
+ // List all models
193
193
  const all = listModels()
194
194
 
195
- // Filter by category
196
- const imageModels = listModels({ category: 'text-to-image' })
195
+ // Filter by input/output modality
196
+ const imageModels = listModels({ input: 'text', output: 'image' })
197
197
 
198
198
  // Filter by provider
199
199
  const falModels = listModels({ provider: 'fal-ai' })
@@ -201,37 +201,35 @@ const falModels = listModels({ provider: 'fal-ai' })
201
201
  // Search by name
202
202
  const fluxModels = listModels({ query: 'flux' })
203
203
 
204
- // Get details for a specific model
205
- const model = getModel('flux-schnell')
206
- // => { canonical_name, aliases, category, modality, providers }
204
+ // Resolve a specific model
205
+ const model = resolveModel('flux-schnell')
206
+ // => { canonical_name, aliases, modality, providers }
207
+
208
+ // Derive a display label from modality
209
+ deriveCategory(model) // => "text-to-image"
207
210
  ```
208
211
 
209
- ## Supported Categories
212
+ ## Modality
210
213
 
211
- | Category | Input | Output | Models |
212
- |---|---|---|---|
213
- | `text-to-image` | text | image | 281 |
214
- | `image-edit` | image + text | image | 238 |
215
- | `image-to-video` | image + text | video | 211 |
216
- | `text-to-video` | text | video | 202 |
217
- | `image-to-image` | image + text | image | 176 |
218
- | `video-to-video` | video | video | 152 |
219
- | `text-to-audio` | text | audio | 127 |
220
- | `text-generation` | text | text | 95 |
221
- | `upscale-image` | image | image | 63 |
222
- | `image-to-text` | image | text | 54 |
223
- | `training` | images | model | 50 |
224
- | `image-to-3d` | image | 3d | 40 |
225
- | `segmentation` | image/video | segmentation | 37 |
226
- | `remove-background` | image/video | image/video | 31 |
227
- | `audio-to-text` | audio | text | 31 |
228
- | `upscale-video` | video | video | 20 |
229
- | `text-to-3d` | text | 3d | 16 |
230
- | `video-to-text` | video | text | 14 |
231
- | `video-to-audio` | video | audio | 14 |
232
- | `moderation` | text/image/video | text | 13 |
233
- | `doc-to-text` | file | text | 8 |
234
- | `audio-to-video` | audio | video | 3 |
214
+ Models declare their input and output types via `modality`. There are no fixed categories — modality is the source of truth.
215
+
216
+ **Input types:** `text`, `image`, `audio`, `video`
217
+
218
+ **Output types:** `image`, `video`, `audio`, `text`, `3d`, `segmentation`
219
+
220
+ Common combinations across 1,940+ models:
221
+
222
+ | Inputs | Outputs | Example |
223
+ |---|---|---|
224
+ | text | image | `flux-schnell`, `ideogram-v3` |
225
+ | text | video | `veo3.1`, `sora-2` |
226
+ | image, text | image | `gpt-image-1.5-edit`, `flux-2-pro-edit` |
227
+ | image, text | video | `kling-video-v3-pro`, `seedance-v1.5-pro` |
228
+ | text | audio | `elevenlabs-v3`, `minimax-music-v2` |
229
+ | text | text | `claude-sonnet-4-6`, `gpt-4o` |
230
+ | image | image | `topaz-upscale-image`, `birefnet-v2` |
231
+ | image | 3d | `trellis-image-to-3d` |
232
+ | audio | text | `whisper` |
235
233
 
236
234
  ## Providers
237
235
 
@@ -242,9 +240,7 @@ const model = getModel('flux-schnell')
242
240
  | WaveSpeed | 66 | `WAVESPEED_API_KEY` | Native fetch |
243
241
  | OpenRouter | 10 | `OPENROUTER_API_KEY` | Native fetch |
244
242
 
245
- Zero external dependencies -- all provider communication uses native `fetch`.
246
-
247
- See the full [Model Directory](docs/MODELS.md) for all 1,876 models with provider availability.
243
+ Zero external dependencies -- all provider communication uses native `fetch`. Works in Node.js, Vercel Edge, Cloudflare Workers, Deno, Bun, and any ESM runtime -- no `fs` or special bundler config needed.
248
244
 
249
245
  ## API Reference
250
246
 
@@ -257,6 +253,7 @@ The core function. Resolves the model, maps parameters, calls the provider, and
257
253
  ```typescript
258
254
  interface GenerateRequest {
259
255
  model: string // required - model name
256
+ provider?: ProviderName // preferred provider (optional)
260
257
  prompt?: string // text prompt
261
258
  image?: string | File // input image (URL or File)
262
259
  images?: (string | File)[] // multiple reference images
@@ -307,15 +304,20 @@ interface OutputItem {
307
304
 
308
305
  ### `listModels(filters?: ListModelsFilters): ModelEntry[]`
309
306
 
310
- Returns all models the caller has API keys for. Accepts optional filters:
307
+ Returns all models in the registry. Accepts optional filters:
311
308
 
312
- - `category` -- filter by model category (e.g. `'text-to-image'`)
309
+ - `input` -- filter by input modality (e.g. `'text'`, `'image'`, `'audio'`, `'video'`)
310
+ - `output` -- filter by output modality (e.g. `'image'`, `'video'`, `'text'`, `'3d'`)
313
311
  - `provider` -- filter by provider (e.g. `'fal-ai'`)
314
312
  - `query` -- search canonical names and aliases
315
313
 
316
- ### `getModel(name: string): ModelEntry`
314
+ ### `resolveModel(name: string): ModelEntry`
315
+
316
+ Resolves a model by name. Accepts canonical names, aliases, and normalized variants. Throws if no match is found.
317
317
 
318
- Resolves a model by name. Accepts canonical names, aliases, and normalized variants. Throws `ModelNotFoundError` if no match is found.
318
+ ### `deriveCategory(model: ModelEntry): string`
319
+
320
+ Derives a display category label from a model's modality (e.g. `"text-to-image"`).
319
321
 
320
322
  ## R2 Storage (Asset Uploads)
321
323
 
@@ -515,6 +517,16 @@ try {
515
517
  }
516
518
  ```
517
519
 
520
+ ## Migrating from v0.x
521
+
522
+ v1.0.0 replaces the category-based architecture with a modality-first design. Key changes:
523
+
524
+ - `getModel()` is now `resolveModel()`
525
+ - `listModels({ category: '...' })` is now `listModels({ input: '...', output: '...' })`
526
+ - No more `readFileSync` -- works in edge runtimes without any bundler config
527
+
528
+ See the full [Migration Guide](docs/MIGRATION.md) for details.
529
+
518
530
  ## Documentation
519
531
 
520
532
  Full documentation available at [interactive10.com/getaiapi.html](https://www.interactive10.com/getaiapi.html)