Skip to content

fix: use OpenAI-compatible adapter for MiniMax provider#1167

Open
octo-patch wants to merge 1 commit intoVoltAgent:mainfrom
octo-patch:fix/minimax-provider-openai-compatible
Open

fix: use OpenAI-compatible adapter for MiniMax provider#1167
octo-patch wants to merge 1 commit intoVoltAgent:mainfrom
octo-patch:fix/minimax-provider-openai-compatible

Conversation

@octo-patch
Copy link

@octo-patch octo-patch commented Mar 20, 2026

Summary

The auto-generated model provider registry incorrectly configures MiniMax to use @ai-sdk/anthropic with an invalid /anthropic/v1 base URL. MiniMax actually provides an OpenAI-compatible API at https://api.minimax.io/v1.

This PR fixes the MiniMax provider configuration by adding correct entries to EXTRA_PROVIDER_REGISTRY that override the auto-generated ones, ensuring MiniMax works out-of-the-box with the correct adapter.

Changes

  • Provider fix: Add MiniMax and MiniMax-CN entries to EXTRA_PROVIDER_REGISTRY using @ai-sdk/openai-compatible adapter with correct API URLs
  • Registry ordering: Reorder STATIC_PROVIDER_REGISTRY so EXTRA entries take precedence over auto-generated ones
  • Map fix: Reconstruct STATIC_PROVIDER_MAP so EXTRA entries override auto-generated ones in config lookups
  • Documentation: Update provider docs with correct package, base URL, and complete model list (M2.7, M2.5 + highspeed variants)
  • Tests: 8 unit tests covering adapter selection, base URL resolution, API key validation, and model variant support

Before (broken)

npm: "@ai-sdk/anthropic"              // Wrong adapter
api: "https://api.minimax.io/anthropic/v1"  // Invalid URL

After (fixed)

npm: "@ai-sdk/openai-compatible"      // Correct adapter
api: "https://api.minimax.io/v1"       // Valid OpenAI-compatible URL

Test plan

  • All 8 new MiniMax provider tests pass
  • Existing tests unaffected
  • Manual verification with MINIMAX_API_KEY set

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.

  • Bug Fixes
    • Switch MiniMax and MiniMax-CN to @ai-sdk/openai-compatible with https://api.minimax.io/v1 and https://api.minimaxi.com/v1.
    • Reorder provider registry and map so EXTRA_PROVIDER_REGISTRY overrides auto-generated entries.
    • Validate MINIMAX_API_KEY and support MINIMAX_BASE_URL override.
    • Add 8 tests for adapter selection, base URL resolution, and model variants; update docs with correct package and models (M2.7, M2.7-highspeed, M2.5, M2.5-highspeed, M2.1, M2).

Written for commit 9e16ee9. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Integrated MiniMax provider with dual regional variants: global endpoint and China-specific endpoint support.
  • Documentation

    • Updated MiniMax provider documentation with new default model versions, expanded model availability tables including context sizes and descriptions, and clarified API endpoint routing for both regional variants.
  • Tests

    • Added comprehensive test suite for MiniMax provider registration, configuration validation, and model resolution.

…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>
@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

⚠️ No Changeset found

Latest commit: 9e16ee9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

Introduces 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

Cohort / File(s) Summary
MiniMax Provider Tests
packages/core/src/registries/model-provider-registry-minimax.spec.ts
New Vitest spec file (170 lines) validating MiniMax provider registration: tests provider list inclusion, base URL resolution (default and China-specific), API key requirement, environment variable overrides, multiple model variant resolution, and verification that Anthropic adapter is not invoked.
Provider Registry Configuration
packages/core/src/registries/model-provider-registry.ts
Added MiniMax and MiniMax-CN provider entries to EXTRA_PROVIDER_REGISTRY with OpenAI-compatible adapter configuration. Updated STATIC_PROVIDER_REGISTRY construction to prepend extra providers ahead of auto-generated entries, and adjusted STATIC_PROVIDER_MAP insertion order to ensure EXTRA definitions take precedence.
Provider Documentation
website/models-docs/providers/minimax.md, website/models-docs/providers/minimax-cn.md
Updated default models, changed provider package from @ai-sdk/anthropic to @ai-sdk/openai-compatible, updated API endpoints to OpenAI-compatible paths, expanded model listings from simple lists to detailed tables with context sizes and descriptions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hop hop! MiniMax joins the warren,
OpenAI-compatible, no need to tarry-on!
From China to the world, models spread with care,
Registry rebuilt with tests beyond compare!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: use OpenAI-compatible adapter for MiniMax provider' clearly and concisely summarizes the main change: switching MiniMax from an incorrect Anthropic adapter to the correct OpenAI-compatible adapter.
Description check ✅ Passed The description comprehensively covers all required template sections including current behavior, new behavior, clear explanation of the fix, changes, test plan, and notes for reviewers with proper detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 20, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/registries/model-provider-registry-minimax.spec.ts (1)

46-56: Consider adding vi.resetModules() for complete module isolation.

The dynamic imports (await import(...)) help with fresh instances, but without vi.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

📥 Commits

Reviewing files that changed from the base of the PR and between 545a90a and 9e16ee9.

📒 Files selected for processing (4)
  • packages/core/src/registries/model-provider-registry-minimax.spec.ts
  • packages/core/src/registries/model-provider-registry.ts
  • website/models-docs/providers/minimax-cn.md
  • website/models-docs/providers/minimax.md

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