fromModelsDev
fromModelsDev() is the quickest way to get a Model[] for use with find() and recommend(). It fetches and parses the full models.dev catalog (3,700+ models, 100+ providers), or parses pre-fetched data if you manage caching yourself. See Data Sources for why models.dev and how to bring your own data.
Signature
Section titled “Signature”function fromModelsDev(prefetchedData?: ModelsDevData): Promise<Model[]>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
prefetchedData | ModelsDevData | Optional. Pre-fetched API response to parse without fetching. |
Returns
Section titled “Returns”Promise<Model[]>: parsed model array ready for find() and recommend().
Behavior
Section titled “Behavior”fromModelsDev(): Fetches fromhttps://models.dev/api.jsonand returns parsed models. Uses the platformfetchAPI (Node 18+).fromModelsDev(data): Parses the provided data without fetching. Useful for caching, offline use, or testing.
Internally uses parseModelsDevData() to handle snake_case to camelCase conversion, openRouterId derivation, sdk resolution, and missing optional fields. Use parseModelsDevData() directly if you need just the parser without the fetch.
import { fromModelsDev } from "pickai";
// Fetch live dataconst models = await fromModelsDev();
// Use pre-fetched dataimport { readFileSync } from "fs";import type { ModelsDevData } from "pickai";
const cached: ModelsDevData = JSON.parse(readFileSync("api.json", "utf-8"));const models = await fromModelsDev(cached);