The folks at OpenRouter has an API for listing AI models: https://openrouter.ai/docs/api/api-reference/models/get-mode...
This has been solid and I use this for my Open Source project RightModel: https://rightmodel.dev
This has been solid and I use this for my Open Source project RightModel: https://rightmodel.dev