Appearance
Model Catalog Sync
The AI module keeps a local model catalog that mirrors the public Vercel AI Gateway model inventory and its provider endpoint metadata.
Controller Surface
GET /modelsPOST /models/refreshGET /models/refresh/statusGET /models/:ownerId/:modelKey
These routes are implemented in source but are not live yet because the module is not mounted.
Refresh Workflow
POST /models/refresh starts an asynchronous refresh job and returns 202 Accepted.
The job performs the following steps:
- Fetch the full model list from
https://ai-gateway.vercel.sh/v1/models. - Upsert each model's base metadata locally.
- For every discovered model, fetch endpoint details from
.../models/:modelId/endpoints. - Persist provider capabilities, architecture, and sync outcome.
- Mark locally known models as
REMOVEDwhen they no longer appear in the upstream catalog.
The sync loop deliberately waits 200 ms between models.
Read Behavior
GET /modelsreturns all locally stored models.GET /models/:ownerId/:modelKeyreconstructs the model id asownerId/modelKey.GET /models/refresh/statusmerges runtime progress counters with persisted counters and returns the list of model ids that are currently inSYNCEDstate.
Sync Statuses
Models move through these states:
PENDINGIN_PROGRESSSYNCEDFAILEDREMOVED
Failures store the last sync error string on the entity.
Data Captured Per Model
- descriptive metadata such as
owner,name,description, andtype - capacity metadata such as
contextWindowandmaxTokens - base model pricing and tiered pricing
- provider endpoint data, including per-provider pricing, status, latency, and supported parameters
- architecture modalities and last sync timestamp
Current Caveat
The in-memory refreshPromise guard only prevents overlapping refreshes inside one process. It does not coordinate across multiple API instances, so horizontally scaled deployments can still trigger concurrent refresh jobs.
Structured Error Contract
| Code | HTTP | Meaning |
|---|---|---|
AI.MODELS_SYNC_ALREADY_IN_PROGRESS | 409 | A refresh job is already running in this process. |
AI.MODEL_NOT_FOUND | 404 | The requested stored model id does not exist. |
AI.FAIL_TO_FETCH_VERCEL_AI_GATEWAY_MODELS | 500 | Upstream model-list fetch failed. |
AI.FAIL_TO_FETCH_VERCEL_AI_GATEWAY_MODEL_ENDPOINTS | 500 | Upstream endpoint-details fetch failed. |