fix: resolve model discovery to /v1/models regardless of baseUrl - #3
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: thibault <thibault.jaigu@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| return baseUrl.replace(/\/+$/, ""); | ||
| } | ||
|
|
||
| function modelsUrl(baseUrl) { |
There was a problem hiding this comment.
Can we please add unit-tests for both normalizeBaseUrl and modelsUrl?
There was a problem hiding this comment.
It would help to see the exact strings that are coming in and out here
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The new tests document the exact in/out strings. Highlights:
normalizeBaseUrl:
https://router.requesty.ai/→https://router.requesty.aihttps://router.requesty.ai/v1/→https://router.requesty.ai/v1
modelsUrl:
https://router.requesty.ai(Anthropic Messages config) →https://router.requesty.ai/v1/modelshttps://router.requesty.ai/v1(OpenAI Completions config) →https://router.requesty.ai/v1/modelshttps://router.requesty.ai/v2→https://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>
|
@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. |
Summary
Model discovery failed for the recommended Anthropic Messages config. The extension fetched
`${provider.baseUrl}/models`, but the Pi docs configureapi: "anthropic-messages"withbaseUrl: https://router.requesty.ai(deliberately without/v1, so Pi appends/v1/messagescorrectly). That made discovery hithttps://router.requesty.ai/models→ 404, so both startup discovery and/requesty-models-syncfailed for anyone following the docs.Fix: derive the models endpoint so it always targets
/v1/models, regardless of whetherbaseUrlincludes a version segment: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-syncwrites 592 models back tomodels.json, preservingbaseUrl/api. Both/v1and no-/v1base URLs resolve tohttps://router.requesty.ai/v1/models.Link to Devin session: https://app.devin.ai/sessions/d91233e460d344fd9b46cee67d79bb2f
Requested by: @Thibault00