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 +52 -40
- package/dist/chunk-34X3VRM3.js +72083 -0
- package/dist/chunk-34X3VRM3.js.map +1 -0
- package/dist/cli.js +38 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +82 -39
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/dist/chunk-LHDSEV4H.js +0 -1479
- package/dist/chunk-LHDSEV4H.js.map +0 -1
- package/dist/chunk-P7XV6JOH.js +0 -1046
- package/dist/chunk-P7XV6JOH.js.map +0 -1
- package/dist/v2/index.d.ts +0 -125
- package/dist/v2/index.js +0 -368
- package/dist/v2/index.js.map +0 -1
- package/registry/.gitkeep +0 -0
- package/registry/catalog.json +0 -4108
- package/registry/categories.json +0 -27
- package/registry/registry.json +0 -56128
- package/registry/v2/registry.json +0 -70024
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
|
|
9
|
-
A unified TypeScript library that wraps 1,
|
|
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,
|
|
190
|
+
import { listModels, resolveModel, deriveCategory } from 'getaiapi'
|
|
191
191
|
|
|
192
|
-
// List all
|
|
192
|
+
// List all models
|
|
193
193
|
const all = listModels()
|
|
194
194
|
|
|
195
|
-
// Filter by
|
|
196
|
-
const imageModels = listModels({
|
|
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
|
-
//
|
|
205
|
-
const model =
|
|
206
|
-
// => { canonical_name, aliases,
|
|
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
|
-
##
|
|
212
|
+
## Modality
|
|
210
213
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
|
220
|
-
|
|
221
|
-
|
|
|
222
|
-
|
|
|
223
|
-
|
|
|
224
|
-
|
|
|
225
|
-
|
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
|
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
|
|
307
|
+
Returns all models in the registry. Accepts optional filters:
|
|
311
308
|
|
|
312
|
-
- `
|
|
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
|
-
### `
|
|
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
|
-
|
|
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)
|