Hey @keshav-writes-code, welcome to the community - great to see you’re building with Svelte!
Some suggestions:
Without AI Gateway, if you want a dynamic models list, providers will usually have an API endpoint which lists all their models (examples from OpenAI and Anthropic). If you’re using SvelteKit, you could create an API route that fetches these lists server-side and normalizes them into a format your frontend can consume.
That said, this approach can require managing API keys for each provider, not all providers expose a models endpoint, and it may not scale well if you support many providers.
You can also get a list of models through the /models endpoint (ai-gateway.vercel.sh/v1/models). You can browse models via the website for a more human-friendly way to see the models, and then query the models endpoint directly through REST - some more details here, with some code examples of usage. This endpoint follows the OpenAI models API format and requires no authentication / API key.
The AI SDK works well with Svelte / SvelteKit projects, some more information on getting started here if needed.
Another thing worth mentioning is the AI SDK Provider Registry. While it doesn’t dynamically fetch available models, it provides a clean way to define and manage a set of supported providers and models in one place.
This could be useful if you want a single source of truth for which models your app supports, and then derive your frontend model selector from that registry.
If there’s anything blocking you from using the AI Gateway or if you have feedback, feel free to share!