Skip to content

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

Merged
omeraplak merged 2 commits intoVoltAgent:mainfrom
octo-patch:fix/minimax-provider-openai-compatible
Mar 30, 2026
Merged

fix: use OpenAI-compatible adapter for MiniMax provider#1167
omeraplak merged 2 commits intoVoltAgent:mainfrom
octo-patch:fix/minimax-provider-openai-compatible

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

@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. Adds a changeset for a patch release and 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).
  • Dependencies

    • Add changeset for a patch release of @voltagent/core.

Written for commit e82dfe9. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added MiniMax provider with two regional variants (global and China) and deterministic provider lookup.
  • Documentation

    • Updated MiniMax docs: new default models, expanded model tables with context sizes/descriptions, and clarified endpoint routing for each region.
  • Bug Fix

    • Switched MiniMax to use an OpenAI-compatible integration for improved compatibility.
  • Tests

    • Added tests validating MiniMax registration, configuration, regional endpoints, API key handling, and model resolution.
  • Chores

    • Added a changeset for a patch release.

…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
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: e82dfe9

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

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 302d0f24-6b51-4b28-af85-1534c0ce7773

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/tall-birds-invite.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/tall-birds-invite.md

📝 Walkthrough

Walkthrough

Adds MiniMax provider support (standard and China variants) using the OpenAI-compatible adapter, updates the provider registry to prefer EXTRA entries, adds a Vitest suite validating MiniMax resolution and env behavior, and updates provider docs and a changeset. Global registry cache resets are handled in tests.

Changes

Cohort / File(s) Summary
MiniMax Provider Tests
packages/core/src/registries/model-provider-registry-minimax.spec.ts
New Vitest spec that mocks adapters, captures createOpenAICompatible calls, clears global registry cache and process.env, and verifies registration, base URL selection (default, China, and env override), API key requirement, multi-variant resolution, and that Anthropic adapter is not invoked.
Provider Registry Configuration
packages/core/src/registries/model-provider-registry.ts
Added minimax and minimax-cn entries to EXTRA_PROVIDER_REGISTRY using the OpenAI-compatible adapter; changed static registry construction so EXTRA entries are prepended and adjusted map insertion order so EXTRA definitions win on ID collisions.
Provider Documentation
website/models-docs/providers/minimax.md, website/models-docs/providers/minimax-cn.md
Rewrote docs to use OpenAI-compatible integration and updated default models, API endpoints (OpenAI-compatible paths), and expanded model listings with context sizes and descriptions; removed auto-generated file comment.
Changeset
.changeset/tall-birds-invite.md
Added patch changeset noting the switch to the OpenAI-compatible adapter for MiniMax.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client
  participant Registry as ModelProviderRegistry
  participant Adapter as OpenAI-Compatible Adapter
  participant Anthropic as Anthropic Adapter (not used)
  participant Env as Env / process.env

  Client->>Registry: resolveLanguageModel("minimax/Model")
  Registry->>Env: read MINIMAX_API_KEY, MINIMAX_BASE_URL, provider ID
  Registry->>Adapter: createOpenAICompatible(config { name, baseURL, apiKey })
  Adapter-->>Registry: returns LanguageModel / ChatModel instance
  Registry-->>Client: resolved model instance
  Note right of Anthropic: Anthropic adapter should not be invoked
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped to the registry, small and spry,

MiniMax now speaks OpenAI, oh my!
Tests chase the keys and URLs with glee,
China and global both in harmony.
A joyful nibble, release ready—whee!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: switching MiniMax provider to use OpenAI-compatible adapter instead of the incorrect Anthropic adapter.
Description check ✅ Passed The description covers all required template sections: it explains the current buggy behavior, describes the fix with specific changes, includes test coverage details, and provides before/after code examples. All key aspects of the PR are well documented.
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

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@omeraplak omeraplak merged commit 195155b into VoltAgent:main Mar 30, 2026
20 of 23 checks passed
@omeraplak
Copy link
Copy Markdown
Member

Hey @octo-patch ,
Thank you so much!

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.

2 participants