Skip to content

feat(provider): add API key providers - #1789

Merged
zerob13 merged 1 commit into
devfrom
codex/add-basic-api-providers
Jun 20, 2026
Merged

feat(provider): add API key providers#1789
zerob13 merged 1 commit into
devfrom
codex/add-basic-api-providers

Conversation

@zerob13

@zerob13 zerob13 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add built-in API-key providers for NVIDIA, Hugging Face, Moonshot AI global, StepFun, Upstage, Alibaba Token Plan global/CN, and MiniMax Global.
  • Register the new providers against existing OpenAI-compatible or Anthropic-compatible runtime definitions with provider-db model metadata.
  • Add provider-db refresh allowlist entries, provider-db aliasing for MiniMax Global, icon mappings, SDD docs, and focused tests.

UI Layout

BEFORE:

Provider settings
├─ Existing built-in providers
├─ MiniMax (existing)
└─ Custom provider entry

AFTER:

Provider settings
├─ Existing built-in providers
├─ NVIDIA
├─ Hugging Face
├─ Moonshot AI
├─ StepFun
├─ Upstage
├─ Alibaba Token Plan
├─ Alibaba Token Plan (China)
├─ MiniMax (existing)
├─ MiniMax Global
└─ Custom provider entry

Tests

  • pnpm run format
  • pnpm exec vitest run test/main/presenter/configPresenter/defaultProviders.test.ts test/main/shared/providerDbCatalog.test.ts test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts test/renderer/components/ModelIcon.test.ts
  • pnpm run i18n
  • pnpm run lint
  • pnpm run typecheck

Summary by CodeRabbit

  • New Features

    • Added built-in support for 8 new AI providers with API key authentication: NVIDIA, Hugging Face, Moonshot AI, StepFun, Upstage, Alibaba Token Plan (China and Global), and MiniMax Global. All are configured as disabled by default.
  • Documentation

    • Added specification and implementation documentation for the Basic API Key Providers feature.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Eight new built-in API-key providers (NVIDIA, Hugging Face, Moonshot AI, StepFun, Upstage, Alibaba Token Plan global/CN, MiniMax global) are registered across DEFAULT_PROVIDERS, PROVIDER_ID_REGISTRY, the provider-db allowlist, ModelIcon icon map, and PROVIDER_ID_ALIASES. SDD documents and focused Vitest test suites are added covering all registration surfaces.

Changes

Basic API Key Providers Batch

Layer / File(s) Summary
SDD artifacts
docs/features/basic-api-key-providers/spec.md, docs/features/basic-api-key-providers/plan.md, docs/features/basic-api-key-providers/tasks.md
Adds spec, plan, and tasks documents defining scope, provider mapping table, acceptance criteria, implementation checklist, and validation commands.
Provider-db allowlist and ID alias
src/shared/providerDbCatalog.ts, src/main/presenter/configPresenter/providerId.ts
Expands PROVIDER_DB_BACKED_PROVIDER_IDS with all eight new provider IDs and adds minimax-global → minimax to PROVIDER_ID_ALIASES.
DEFAULT_PROVIDERS config entries
src/main/presenter/configPresenter/providers.ts
Inserts disabled built-in config entries for all eight providers with apiType, baseUrl, and websites metadata; removes the old commented-out nvidia block.
PROVIDER_ID_REGISTRY runtime definitions
src/main/presenter/llmProviderPresenter/providerRegistry.ts
Adds AiSdkProviderDefinition entries for all eight providers with modelSource: 'provider-db', checkStrategy: 'generate-text', credentialStrategy: 'api-key', and provider-specific providerDbSourceId/checkModelId. MiniMax global uses the Anthropic-compatible runtime/preset.
ModelIcon mappings
src/renderer/src/components/icons/ModelIcon.vue
Imports nvidiaColorIcon and huggingfaceColorIcon; adds nvidia, huggingface, alibaba-token-plan, alibaba-token-plan-cn, alibaba, and minimax-global entries to the icons registry.
Focused tests
test/main/presenter/configPresenter/defaultProviders.test.ts, test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts, test/main/shared/providerDbCatalog.test.ts, test/renderer/components/ModelIcon.test.ts
Verifies disabled config entries, isProviderDbBackedProvider results, resolveAiSdkProviderDefinition runtime classification, AiSdkProvider.fetchModels() field mapping, AiSdkProvider.check() invocation, and icon src rendering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ThinkInAIXYZ/deepchat#1046: Both PRs modify ModelIcon.vue icon resolution mappings, adding provider→icon entries that touch overlapping registry blocks.
  • ThinkInAIXYZ/deepchat#1481: Both PRs extend the same provider registration plumbing — DEFAULT_PROVIDERS, PROVIDER_ID_REGISTRY, and ModelIcon.vue icon mappings — to register new built-in provider IDs.
  • ThinkInAIXYZ/deepchat#1556: Both PRs add "token plan" provider IDs backed by provider-db using the same DEFAULT_PROVIDERS and providerRegistry.ts extension pattern.

Poem

🐇 Hop, hop, eight new keys in a row,
NVIDIA, HuggingFace, join the show!
MiniMax goes global, Alibaba splits in two,
Stepfun and Upstage — the registry grew!
Icons mapped, allowlists blessed,
The bunny's provider batch passed every test! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding API key providers. It aligns well with the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-basic-api-providers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts (1)

99-102: ⚡ Quick win

Reset mock implementations between tests to avoid state leakage.

mockGetProvider.mockReturnValue(...) persists across tests with vi.clearAllMocks(). Use
vi.resetAllMocks() (or explicitly reset mockGetProvider) so each test starts from a clean implementation state.

Suggested change
  beforeEach(() => {
-    vi.clearAllMocks()
+    vi.resetAllMocks()
     mockRunAiSdkGenerateText.mockResolvedValue({ content: 'ok' })
+    mockGetProvider.mockReturnValue(null)
  })

Also applies to: 155-176

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts` around
lines 99 - 102, The beforeEach hook uses vi.clearAllMocks() which only clears
mock call history but does not reset mock implementations like
mockGetProvider.mockReturnValue(...), causing test state to leak between tests.
Replace vi.clearAllMocks() with vi.resetAllMocks() in the beforeEach block to
ensure both call history and mock implementations are reset between each test,
preventing state leakage. This same issue applies to other test blocks in the
file as well, so apply the change consistently wherever vi.clearAllMocks() is
used in a beforeEach or similar setup block.
test/renderer/components/ModelIcon.test.ts (1)

77-102: ⚡ Quick win

Add coverage for alibaba-token-plan-cn icon mapping.

This test covers alibaba-token-plan but not the newly added alibaba-token-plan-cn key. Adding that case would protect the full new mapping surface.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/renderer/components/ModelIcon.test.ts` around lines 77 - 102, The test
function 'resolves the basic API-key provider icons' is missing coverage for the
newly added 'alibaba-token-plan-cn' icon mapping. Add a new mount call for
ModelIcon with modelId set to 'alibaba-token-plan-cn' (similar to the existing
alibabaTokenPlan mount), and add a corresponding expect assertion to verify that
the resolved icon source matches the expected alibabaIcon URL. This ensures the
new mapping is properly tested alongside the existing 'alibaba-token-plan' case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/features/basic-api-key-providers/plan.md`:
- Around line 29-30: The documentation for the minimax-global provider in the
compatibility notes section contains an incorrect base URL. Update the URL from
`https://api.minimax.io/anthropic` to `https://api.minimax.io/anthropic/v1` to
match the actual implementation used in the config and tests. This will ensure
consistency between the documented and implemented behavior for the
minimax-global provider.

---

Nitpick comments:
In `@test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts`:
- Around line 99-102: The beforeEach hook uses vi.clearAllMocks() which only
clears mock call history but does not reset mock implementations like
mockGetProvider.mockReturnValue(...), causing test state to leak between tests.
Replace vi.clearAllMocks() with vi.resetAllMocks() in the beforeEach block to
ensure both call history and mock implementations are reset between each test,
preventing state leakage. This same issue applies to other test blocks in the
file as well, so apply the change consistently wherever vi.clearAllMocks() is
used in a beforeEach or similar setup block.

In `@test/renderer/components/ModelIcon.test.ts`:
- Around line 77-102: The test function 'resolves the basic API-key provider
icons' is missing coverage for the newly added 'alibaba-token-plan-cn' icon
mapping. Add a new mount call for ModelIcon with modelId set to
'alibaba-token-plan-cn' (similar to the existing alibabaTokenPlan mount), and
add a corresponding expect assertion to verify that the resolved icon source
matches the expected alibabaIcon URL. This ensures the new mapping is properly
tested alongside the existing 'alibaba-token-plan' case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a32b2b0b-40f6-45e1-9ac7-dd31d38ee62f

📥 Commits

Reviewing files that changed from the base of the PR and between 351af84 and deb4ed7.

📒 Files selected for processing (12)
  • docs/features/basic-api-key-providers/plan.md
  • docs/features/basic-api-key-providers/spec.md
  • docs/features/basic-api-key-providers/tasks.md
  • src/main/presenter/configPresenter/providerId.ts
  • src/main/presenter/configPresenter/providers.ts
  • src/main/presenter/llmProviderPresenter/providerRegistry.ts
  • src/renderer/src/components/icons/ModelIcon.vue
  • src/shared/providerDbCatalog.ts
  • test/main/presenter/configPresenter/defaultProviders.test.ts
  • test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts
  • test/main/shared/providerDbCatalog.test.ts
  • test/renderer/components/ModelIcon.test.ts

Comment thread docs/features/basic-api-key-providers/plan.md
@zerob13
zerob13 merged commit 9cb9b58 into dev Jun 20, 2026
3 checks passed
@zhangmo8
zhangmo8 deleted the codex/add-basic-api-providers branch June 20, 2026 02:38
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