Skip to content

feat: support fetching models from API provider#5520

Closed
sammcj wants to merge 2 commits intoblock:mainfrom
sammcj:fetch_models
Closed

feat: support fetching models from API provider#5520
sammcj wants to merge 2 commits intoblock:mainfrom
sammcj:fetch_models

Conversation

@sammcj
Copy link
Contributor

@sammcj sammcj commented Nov 1, 2025

This pull request adds support for automatically fetching available models from custom AI providers in both the CLI and desktop UI, improving the user experience when configuring providers. The changes include a new API endpoint for fetching models, updates to the CLI workflow to attempt model fetching before manual entry, and enhancements to the desktop UI to allow users to fetch and select models interactively.

Backend changes (API and CLI):

  • Added a new POST endpoint /config/providers/fetch-models in the server (fetch_custom_provider_models) that takes provider details and returns available models, handling authentication and error cases. [1] [2] [3] [4] [5]
  • Implemented try_fetch_custom_provider_models in the CLI to fetch models from providers using the new endpoint, supporting retries with API keys and improved error handling.
  • Updated the CLI add_provider flow to try fetching models automatically before falling back to manual entry, and to prompt for API keys only if needed. [1] [2]

Frontend changes (Desktop UI):

  • Added UI logic to fetch models from the backend when configuring a custom provider, with error handling, loading state, and fallback to manual entry if fetching fails. [1] [2]
  • Enhanced the custom provider form to display fetched models in a multi-select dropdown, allowing users to select or manually enter models.
  • Improved styling for multi-select dropdowns in the UI for better clarity and usability. [1] [2]

@sammcj sammcj marked this pull request as ready for review November 1, 2025 01:34
Signed-off-by: Sam <sammcj@users.noreply.github.com>
Signed-off-by: Sam <sammcj@users.noreply.github.com>
Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would be a great feature, but I think it can be done easier if we just add it to the existing route

"/config/providers/fetch-models",
post(fetch_custom_provider_models),
)
.route("/config/providers/{name}/models", get(get_provider_models))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a new handler for this? we have /config/providers/{name}/models here that fetches the models for a particular provider. to make this work I think all you need to do is either assume that the custom models have model fetch in the same location as openai (which should be straightforward), or add a field to custom providers where the user can specify the path to fetch the models (which would be more general)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting models for custom providers used to work in older versions already, something changed in that area with the custom provider rewrite.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point

@angiejones angiejones requested a review from Copilot November 2, 2025 18:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity for 23 days.

What happens next?

  • If no further activity occurs, this PR will be automatically closed in 7 days
  • To keep this PR active, simply add a comment, push new commits, or add the keep-open label
  • If you believe this PR was marked as stale in error, please comment and we'll review it

Thank you for your contribution! 🚀

@github-actions github-actions bot added the stale label Nov 28, 2025
@DOsinga
Copy link
Collaborator

DOsinga commented Dec 4, 2025

closing for being stale. I'll base something on this to fix the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments