fix: use OpenAI-compatible adapter for MiniMax provider#1167
fix: use OpenAI-compatible adapter for MiniMax provider#1167octo-patch wants to merge 1 commit intoVoltAgent:mainfrom
Conversation
…thropic The auto-generated registry incorrectly configured MiniMax to use @ai-sdk/anthropic with an invalid /anthropic/v1 base URL. MiniMax provides an OpenAI-compatible API at https://api.minimax.io/v1. Changes: - Add MiniMax and MiniMax-CN entries to EXTRA_PROVIDER_REGISTRY with correct @ai-sdk/openai-compatible adapter and API URLs - Reorder STATIC_PROVIDER_REGISTRY so EXTRA entries take precedence over auto-generated ones in provider registration - Fix STATIC_PROVIDER_MAP construction to ensure EXTRA entries override auto-generated entries in config lookups - Update provider documentation with correct package, base URL, and complete model list (M2.7, M2.5 + highspeed variants) - Add 8 unit tests verifying correct adapter selection, base URL resolution, API key handling, and model variant support Signed-off-by: octopus <octopus@github.com>
|
📝 WalkthroughWalkthroughIntroduces MiniMax provider support (standard and China variants) using the OpenAI-compatible adapter, including comprehensive test coverage and updated documentation. Migrates from Anthropic-compatible to OpenAI-compatible integration, updates provider registry construction order, and adds model listings with context sizes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="website/models-docs/providers/minimax.md">
<violation number="1" location="website/models-docs/providers/minimax.md:9">
P2: Manual edits in an auto-generated provider doc (and removal of the generated-file warning) create doc drift and overwrite risk when the generation script runs.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -2,12 +2,12 @@ | |||
| title: MiniMax | |||
There was a problem hiding this comment.
P2: Manual edits in an auto-generated provider doc (and removal of the generated-file warning) create doc drift and overwrite risk when the generation script runs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At website/models-docs/providers/minimax.md, line 9:
<comment>Manual edits in an auto-generated provider doc (and removal of the generated-file warning) create doc drift and overwrite risk when the generation script runs.</comment>
<file context>
@@ -2,12 +2,12 @@
Use `minimax/<model>` with VoltAgent's model router.
+MiniMax provides an OpenAI-compatible API at `https://api.minimax.io/v1`. For users in China, use the `minimax-cn` provider which routes to `https://api.minimaxi.com/v1`.
+
## Quick start
</file context>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/registries/model-provider-registry-minimax.spec.ts (1)
46-56: Consider addingvi.resetModules()for complete module isolation.The dynamic imports (
await import(...)) help with fresh instances, but withoutvi.resetModules(), cached module state may persist across tests. This could cause flaky behavior depending on test execution order.♻️ Suggested improvement
beforeEach(() => { + vi.resetModules(); createOpenAICompatibleCalls = []; createAnthropicCalls = []; (globalThis as Record<string, unknown>).___voltagent_model_provider_registry = undefined; process.env = { ...originalEnv }; });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/registries/model-provider-registry-minimax.spec.ts` around lines 46 - 56, Add a call to vi.resetModules() in the test setup to fully isolate module state between tests; for example, invoke vi.resetModules() in the beforeEach (alongside resetting createOpenAICompatibleCalls, createAnthropicCalls, globalThis.___voltagent_model_provider_registry and process.env) so dynamic imports (used elsewhere in the spec) get a fresh module instance and cached state does not leak across tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/core/src/registries/model-provider-registry-minimax.spec.ts`:
- Around line 46-56: Add a call to vi.resetModules() in the test setup to fully
isolate module state between tests; for example, invoke vi.resetModules() in the
beforeEach (alongside resetting createOpenAICompatibleCalls,
createAnthropicCalls, globalThis.___voltagent_model_provider_registry and
process.env) so dynamic imports (used elsewhere in the spec) get a fresh module
instance and cached state does not leak across tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f3820547-45b2-42c6-9e8a-9d579ef52218
📒 Files selected for processing (4)
packages/core/src/registries/model-provider-registry-minimax.spec.tspackages/core/src/registries/model-provider-registry.tswebsite/models-docs/providers/minimax-cn.mdwebsite/models-docs/providers/minimax.md
Summary
The auto-generated model provider registry incorrectly configures MiniMax to use
@ai-sdk/anthropicwith an invalid/anthropic/v1base URL. MiniMax actually provides an OpenAI-compatible API athttps://api.minimax.io/v1.This PR fixes the MiniMax provider configuration by adding correct entries to
EXTRA_PROVIDER_REGISTRYthat override the auto-generated ones, ensuring MiniMax works out-of-the-box with the correct adapter.Changes
EXTRA_PROVIDER_REGISTRYusing@ai-sdk/openai-compatibleadapter with correct API URLsSTATIC_PROVIDER_REGISTRYsoEXTRAentries take precedence over auto-generated onesSTATIC_PROVIDER_MAPsoEXTRAentries override auto-generated ones in config lookupsBefore (broken)
After (fixed)
Test plan
Summary by cubic
Fixes the MiniMax provider to use the OpenAI-compatible adapter and valid base URLs so it works out of the box. Also updates registry precedence, docs, and tests.
@ai-sdk/openai-compatiblewithhttps://api.minimax.io/v1andhttps://api.minimaxi.com/v1.EXTRA_PROVIDER_REGISTRYoverrides auto-generated entries.MINIMAX_API_KEYand supportMINIMAX_BASE_URLoverride.Written for commit 9e16ee9. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation
Tests