Skip to content

feat: refresh model list for API-key providers at the managed endpoint - #1824

Merged
liruifengv merged 8 commits into
mainfrom
feat/apikey-managed-provider-model-refresh
Jul 17, 2026
Merged

feat: refresh model list for API-key providers at the managed endpoint#1824
liruifengv merged 8 commits into
mainfrom
feat/apikey-managed-provider-model-refresh

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

None — the problem is explained below.

Problem

Hand-configured type = "kimi" providers that authenticate with a distributed API key against the Kimi Code managed endpoint never get their model list refreshed. Today only the OAuth login flow (managed:kimi-code with an OAuth ref), the two open-platform providers (moonshot-cn / moonshot-ai), and api.json custom registries participate in the startup and periodic catalog refresh, so users running on distributed keys are stuck with a stale, hand-written model list — new models never appear, and removed models never go away.

What changed

  • The provider-model refresh orchestrator now covers hand-written type: kimi providers whose base_url matches the managed Kimi Code endpoint exactly (parsed URL, lowercase origin, trailing slashes tolerated, KIMI_CODE_BASE_URL override respected). The credential is resolved the same way the runtime resolves it — inline api_key first, then KIMI_API_KEY from the provider's env table — and used as the Bearer token on {base_url}/models.
  • Only model aliases are merged. The user-owned provider record (credentials and hand-written extras), services, and default selections are never rewritten, and aliases the user named outside the provider prefix are preserved. A hand-written managed:kimi-code without an OAuth ref is covered as well, sharing the OAuth branch's kimi-code/ alias prefix so the two shapes merge cleanly if the user later logs in.
  • Strict endpoint matching keeps proxies and gateways with an untrusted /models schema out of automatic refresh. Auth failures (expired/revoked key) are reported per provider without touching the config; an empty model list is a no-op. default_provider pointing at a refreshed provider is written back so the remove-then-set persistence sequence cannot silently drop it.
  • Auth-error wording on the managed /models fetch now distinguishes API keys from OAuth credentials instead of always blaming "OAuth credentials".
  • Docs (EN/ZH) updated; changeset included.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc6b81f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@dc6b81f
npx https://pkg.pr.new/@moonshot-ai/kimi-code@dc6b81f

commit: dc6b81f

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 268dd4450f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/oauth/src/refreshProviderModels.ts
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba4cd73399

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core-v2/src/app/modelCatalog/modelCatalogService.ts Outdated
@liruifengv
liruifengv merged commit bfecd01 into main Jul 17, 2026
14 checks passed
@liruifengv
liruifengv deleted the feat/apikey-managed-provider-model-refresh branch July 17, 2026 09:18
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 17, 2026
MoonshotAI#1824)

* feat: refresh model list for API-key providers at the managed endpoint

* docs: simplify changeset wording

* docs: add kimi-code/k3 to the default config example

* fix: clear stale default model when a refresh drops its alias

* fix: clear refresh defaults via replace; set(undefined) cannot delete

* docs: drop the auto model refresh paragraph from providers page

* docs: simplify changeset wording
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 17, 2026
MoonshotAI#1824)

* feat: refresh model list for API-key providers at the managed endpoint

* docs: simplify changeset wording

* docs: add kimi-code/k3 to the default config example

* fix: clear stale default model when a refresh drops its alias

* fix: clear refresh defaults via replace; set(undefined) cannot delete

* docs: drop the auto model refresh paragraph from providers page

* docs: simplify changeset wording
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
MoonshotAI#1824)

* feat: refresh model list for API-key providers at the managed endpoint

* docs: simplify changeset wording

* docs: add kimi-code/k3 to the default config example

* fix: clear stale default model when a refresh drops its alias

* fix: clear refresh defaults via replace; set(undefined) cannot delete

* docs: drop the auto model refresh paragraph from providers page

* docs: simplify changeset wording
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.

1 participant