fix(setup): use /v1/models API only and support Cohere response shape#6
Closed
siddharthsambharia-portkey wants to merge 1 commit into
Closed
fix(setup): use /v1/models API only and support Cohere response shape#6siddharthsambharia-portkey wants to merge 1 commit into
siddharthsambharia-portkey wants to merge 1 commit into
Conversation
- Updated `fetchModels` to support additional model properties (name, endpoints) for better compatibility with various providers. - Improved `testGatewayConnection` to require a model parameter, ensuring proper validation. - Refactored `doSetup` to streamline model selection and user guidance, removing outdated fallback suggestions and enhancing error messages. - Added tests for new model parsing logic in `fetchModels` to ensure correct functionality.
There was a problem hiding this comment.
Pull request overview
This PR updates the Portkey CLI setup/verification flow to rely exclusively on the /v1/models catalog endpoint, including support for provider-native model list shapes (notably Cohere), and removes hardcoded model suggestions so the picker reflects only what the API returns.
Changes:
- Extend
fetchModels()to parse both{ data: [...] }and{ models: [{ name, endpoints }] }shapes and surface a non-chat “hint” derived fromendpoints. - Remove hardcoded model defaults from the interactive setup model picker and display non-chat models with an inline badge (e.g.
· embed). - Make
portkey verifyrequire an explicitly configured model (no hardcoded fallback).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/api.test.js |
Adds coverage for Cohere-style /v1/models response parsing and endpoints → hint mapping. |
src/api.js |
Updates model catalog parsing logic and adds a required model parameter to the gateway connectivity test helper. |
src/commands/claude-code/setup.js |
Removes curated model defaults and updates the model selection UX to use only catalog results + inline hints. |
src/commands/claude-code/verify.js |
Removes the hardcoded test model and requires a configured model before verifying. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const existing = readExistingConfig(); | ||
| const gateway = process.env.ANTHROPIC_BASE_URL || existing.gateway || PORTKEY_GATEWAY; | ||
| const testModel = existing.model || "claude-haiku-4-20250514"; | ||
| const testModel = existing.model; |
| if (targetAgent === "codex" && mode === "config" && !String(model || "").trim()) { | ||
| if (args.yes) { | ||
| model = args.model || "gpt-4o"; | ||
| model = args.model || ""; |
Comment on lines
450
to
453
| const manualFirst = !permDenied && catalogUnavailable && merged.length > 0; | ||
| const skipSelect = | ||
| permDenied || (catalogUnavailable && merged.length === 0); | ||
| permDenied || (catalogUnavailable && merged.length === 0) || merged.length === 0; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ data: [{ id }] }and provider-native{ models: [{ name, endpoints }] }responses fromGET /v1/models(fixes Cohere showing “no models” while curl works).MODEL_DEFAULTSmerged into the setup picker — the list now reflects only what the catalog API returns.embed-v4.0 · embed) so embed/transcribe rows stay visible but are clearly not for chat.portkey verifyrequires a configured model instead of a hardcoded fallback.Test plan
@cohere-*) → “Found 20 models”, embed rows show· embed/v1/modelsresponse → manual model ID entrynpm testpassesMade with Cursor