fal-list-models
Retrieve a paginated list of available models from fal.ai to manage model discovery without overloading.
Instructions
List all available models from fal.ai with optional pagination parameters. Avoid listing all models at once as it may be too many models to process.. Use the limit and page parameters to paginate the results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| page | No |
Implementation Reference
- src/tools/index.ts:19-34 (handler)The tool registration and handler function for 'fal-list-models'. Calls client.listModels() with optional limit/page, then returns the result as text.
server.tool( 'fal-list-models', 'List all available models from fal.ai with optional pagination parameters. Avoid listing all models at once as it may be too many models to process.. Use the limit and page parameters to paginate the results.', { limit: z.number().optional(), page: z.number().optional(), }, async ({ limit, page }) => { const result = (await client.listModels({ limit, page })) as | { models?: FalModel[]; data?: FalModel[] } | FalModel[] | unknown; const list = Array.isArray(result) ? result : ((result as any)?.models ?? (result as any)?.data ?? result); return { content: [{ type: 'text', text: toText(list) }] }; }, - src/tools/index.ts:22-24 (schema)Input schema for 'fal-list-models' using Zod: optional 'limit' and 'page' number parameters.
{ limit: z.number().optional(), page: z.number().optional(), - src/tools/index.ts:19-35 (registration)Tool registered via server.tool() with name 'fal-list-models' and description about pagination.
server.tool( 'fal-list-models', 'List all available models from fal.ai with optional pagination parameters. Avoid listing all models at once as it may be too many models to process.. Use the limit and page parameters to paginate the results.', { limit: z.number().optional(), page: z.number().optional(), }, async ({ limit, page }) => { const result = (await client.listModels({ limit, page })) as | { models?: FalModel[]; data?: FalModel[] } | FalModel[] | unknown; const list = Array.isArray(result) ? result : ((result as any)?.models ?? (result as any)?.data ?? result); return { content: [{ type: 'text', text: toText(list) }] }; }, ); - src/services/fal-client.ts:26-31 (helper)The FalClient.listModels() method that makes the actual HTTP GET request to https://fal.ai/api/models with optional limit/page query params.
async listModels(params?: { limit?: number; page?: number }): Promise<FalModel[]> { const url = new URL(`${this.BASE_URL}/models`); if (params?.limit != null) url.searchParams.set('limit', String(params.limit)); if (params?.page != null) url.searchParams.set('page', String(params.page)); return this._getJson(url.toString()) as Promise<FalModel[]>; } - src/types/model.ts:1-35 (helper)The FalModel Zod schema and TypeScript type used as return type for listModels().
import { z } from 'zod'; export const FalModelSchema = z.object({ id: z.string(), modelId: z.string(), isFavorited: z.boolean(), title: z.string(), category: z.string(), tags: z.array(z.string()), shortDescription: z.string(), thumbnailUrl: z.string(), modelUrl: z.string(), githubUrl: z.string(), licenseType: z.string(), date: z.string(), group: z.object({ key: z.string(), label: z.string(), }), machineType: z.string().nullable(), examples: z.array(z.string()), highlighted: z.boolean(), authSkippable: z.boolean(), unlisted: z.boolean(), deprecated: z.boolean(), resultComparison: z.boolean(), hidePricing: z.boolean(), private: z.boolean(), removed: z.boolean(), adminOnly: z.boolean(), kind: z.string(), trainingEndpoints: z.array(z.unknown()), }); export type FalModel = z.infer<typeof FalModelSchema>;