Fetching available AI providers and models in Svelte using Vercel AI SDK

Goal

My goal is to build a model selector component for a Svelte project.

Requirements

  • I don’t want to use the Vercel AI Gateway.
  • I want to support all model providers like OpenAI, Claude, Google, etc.

I want to get a list of available providers and models so that I can show them in the frontend. How can I do so?

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.

Alternatively, AI SDK provides getAvailableModels, a method to programatically discover models.

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!

Hope that helps :slight_smile:

thanks soo much man, never seen someone put this much effort in thier replies

so, quering https://ai-gateway.vercel.sh/v1/models worked but i was wondering, is there a limit to how many request can i make?