Skip to content

fix: resolve model discovery to /v1/models regardless of baseUrl - #3

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1784455859-models-endpoint
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1784455859-models-endpoint

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Model discovery failed for the recommended Anthropic Messages config. The extension fetched `${provider.baseUrl}/models`, but the Pi docs configure api: "anthropic-messages" with baseUrl: https://router.requesty.ai (deliberately without /v1, so Pi appends /v1/messages correctly). That made discovery hit https://router.requesty.ai/models404, so both startup discovery and /requesty-models-sync failed for anyone following the docs.

Fix: derive the models endpoint so it always targets /v1/models, regardless of whether baseUrl includes a version segment:

function modelsUrl(baseUrl) {
  const base = normalizeBaseUrl(baseUrl);
  return /\/v\d+$/.test(base) ? `${base}/models` : `${base}/v1/models`;
}
// discoverModels now fetches modelsUrl(provider.baseUrl)

This keeps the existing OpenAI-completions config (baseUrl: .../v1) working while fixing the Anthropic-messages config (baseUrl: ... root).

Testing

Verified live against router.requesty.ai: /v1/models → 200 (592 models), /models → 404. Ran the actual extension module with the docs' anthropic-messages config: startup registers 592 models and /requesty-models-sync writes 592 models back to models.json, preserving baseUrl/api. Both /v1 and no-/v1 base URLs resolve to https://router.requesty.ai/v1/models.

Link to Devin session: https://app.devin.ai/sessions/d91233e460d344fd9b46cee67d79bb2f
Requested by: @Thibault00

Co-Authored-By: thibault <thibault.jaigu@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Comment thread requesty.js Outdated
return baseUrl.replace(/\/+$/, "");
}

function modelsUrl(baseUrl) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we please add unit-tests for both normalizeBaseUrl and modelsUrl?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would help to see the exact strings that are coming in and out here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added unit tests for both normalizeBaseUrl and modelsUrl in requesty.test.js (both functions are now exported), plus a npm test script using Node's built-in test runner (node --test). Both tests pass.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The new tests document the exact in/out strings. Highlights:

normalizeBaseUrl:

  • https://router.requesty.ai/https://router.requesty.ai
  • https://router.requesty.ai/v1/https://router.requesty.ai/v1

modelsUrl:

  • https://router.requesty.ai (Anthropic Messages config) → https://router.requesty.ai/v1/models
  • https://router.requesty.ai/v1 (OpenAI Completions config) → https://router.requesty.ai/v1/models
  • https://router.requesty.ai/v2https://router.requesty.ai/v2/models

So regardless of whether the configured baseUrl includes a version segment, discovery always resolves to a single /v1/models (no /v1/v1/models and no bare /models).

Co-Authored-By: thibault <thibault.jaigu@gmail.com>
@tobru

tobru commented Aug 21, 2026

Copy link
Copy Markdown

@requesty-ditti Any chance to get this merged? I'd love to use Pi with Requesty instead of with OpenRouter, but this is holding me back right now.

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.

2 participants