Skip to content

Replace hardcoded model lists with dynamic gateway fetch#48

Merged
ctate merged 8 commits into
mainfrom
ctate/add-models
May 3, 2026
Merged

Replace hardcoded model lists with dynamic gateway fetch#48
ctate merged 8 commits into
mainfrom
ctate/add-models

Conversation

@ctate
Copy link
Copy Markdown
Collaborator

@ctate ctate commented May 3, 2026

Summary

  • Fetches models from the raw AI Gateway API (/v1/models) instead of maintaining static fallback arrays, so the model list never goes stale
  • Uses the image-generation tag from the gateway to dynamically detect language models that generate images (e.g. Gemini), routing them through generateText instead of generateImage
  • Short-name expansion (e.g. flux-2-probfl/flux-2-pro) now resolves against the live model list

Fetch the raw AI Gateway API directly to get model type and tags,
eliminating all static FALLBACK_*_MODELS arrays. Language models
with the "image-generation" tag (e.g. Gemini image models) are now
automatically detected and routed through generateText instead of
generateImage. Short-name expansion also uses the live model list.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-cli Ready Ready Preview, Comment May 3, 2026 8:46pm

Remove references to built-in fallback lists and update gateway
unreachable behavior in docs. Update landing page copy to reflect
live model discovery.
Comment thread packages/ai-cli/src/commands/image.ts Outdated
When piping an image via stdin to a language-based image model (e.g.
Gemini), the image data was silently discarded. Now uses the messages
format to include both image and text content.
- Cache gateway fetch with module-level promise (single fetch per process)
- Add 5s timeout to gateway fetch via AbortSignal
- Add creator (from owned_by), capabilities, and pricing to ModelEntry
- Rename --provider flag to --creator (aligns with AI Gateway's
  creator/model-name convention, reserves "provider" for future
  multi-provider support)
- Deduplicate --json output: flat array where each model appears once
  with all capabilities
- Fix image.ts prompt assertion to only use ! in safe else branch
- Remove no-op ?? undefined in model parsing
… up types

- Don't permanently cache failed gateway fetches so retries are possible
- Remove no-op ternary in groupByCreator call
- Only send Google-specific providerOptions when the model creator is Google
- Narrow resolveModels signature to Pick<ModelEntry, "id">[] and remove as-never casts in tests
@ctate ctate merged commit 70323f0 into main May 3, 2026
9 checks passed
@ctate ctate mentioned this pull request May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant