feat: add MiniMax as first-class LLM provider - #231
Conversation
Add MiniMax (MiniMax-M2.7 / MiniMax-M2.7-highspeed) as a built-in LLM provider alongside OpenRouter. Changes include: - Provider presets system in utils/ai.ts with auto-configured base URL and default model per provider - Temperature clamping for MiniMax (requires (0, 1] range) - Conditional OpenRouter-specific providerOptions (only applied when AI_PROVIDER=openrouter) - Updated .env.template with MiniMax configuration example - Updated README with provider preset table and MiniMax setup guide - 22 unit + integration tests covering presets, temperature clamping, and endpoint compatibility Usage: set AI_PROVIDER=minimax and AI_API_KEY to switch providers.
|
Someone is attempting to deploy a commit to the Plastic Labs Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis pull request adds support for the MiniMax LLM provider alongside the existing Openrouter default. Changes include a new provider preset system with base URLs and model defaults, temperature clamping logic specific to MiniMax constraints, updated documentation, and comprehensive test coverage for provider selection and temperature handling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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)
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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
utils/ai.ts (1)
136-148: Deduplicate repeated OpenRouterproviderOptionsblock.The same
openrouter.orderobject is repeated in four places; centralizing it will reduce drift.♻️ Suggested refactor
+const OPENROUTER_PROVIDER_OPTIONS = + AI_PROVIDER === 'openrouter' + ? { + providerOptions: { + openrouter: { + order: ['DeepInfra', 'Hyperbolic', 'Fireworks', 'Together', 'Lambda'], + }, + }, + } + : {}; // in each AI call: - ...(AI_PROVIDER === 'openrouter' && { - providerOptions: { - openrouter: { - order: [ - 'DeepInfra', - 'Hyperbolic', - 'Fireworks', - 'Together', - 'Lambda', - ], - }, - }, - }), + ...OPENROUTER_PROVIDER_OPTIONS,Also applies to: 183-195, 236-248, 282-294
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@utils/ai.ts` around lines 136 - 148, Extract the repeated openrouter order array into a single constant (e.g. OPENROUTER_ORDER) and replace each duplicated providerOptions block with a reference to that constant; specifically, where the code checks AI_PROVIDER === 'openrouter' and constructs providerOptions.openrouter.order, use order: OPENROUTER_ORDER instead of inlining the array (this ensures the blocks in the AI configuration that currently repeat the same array are centralized and reused).tests/provider.test.ts (1)
77-82: You can remove the duplicate 0.01 edge-case test.Line 81 already validates
0.01; the separate test at Lines 84-86 is redundant.Also applies to: 84-86
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/provider.test.ts` around lines 77 - 82, Remove the redundant edge-case assertion for clampTemperature('minimax', 0.01): there is already an assertion checking 0.01 in the "keeps valid minimax temperatures unchanged" test, so delete the duplicate expect(clampTemperature('minimax', 0.01)).toBe(0.01) in the other test block to avoid duplicated coverage of the same edge case while keeping the rest of the tests intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Line 86: Update the README text for the AI_BASE_URL description to use the
compound adjective form "OpenAI-compatible" instead of "OpenAI compatible";
locate the line containing the `AI_BASE_URL` entry and change the phrase to "An
OpenAI-compatible API endpoint for LLM inference" to ensure correctness and
consistency.
In `@tests/provider.integration.test.ts`:
- Line 24: Remove the redundant "undefined ||" prefix from the test constants
(e.g., the const baseURL assignment and the other consts flagged on lines 31,
38, 39) so the expressions read directly as fallback chains (for example: use
preset?.baseURL || 'https://openrouter.ai/api/v1' instead of undefined ||
preset?.baseURL || ...); update the const declarations where the pattern appears
(search for "undefined ||" in tests/provider.integration.test.ts) to simplify
the expressions and improve clarity.
---
Nitpick comments:
In `@tests/provider.test.ts`:
- Around line 77-82: Remove the redundant edge-case assertion for
clampTemperature('minimax', 0.01): there is already an assertion checking 0.01
in the "keeps valid minimax temperatures unchanged" test, so delete the
duplicate expect(clampTemperature('minimax', 0.01)).toBe(0.01) in the other test
block to avoid duplicated coverage of the same edge case while keeping the rest
of the tests intact.
In `@utils/ai.ts`:
- Around line 136-148: Extract the repeated openrouter order array into a single
constant (e.g. OPENROUTER_ORDER) and replace each duplicated providerOptions
block with a reference to that constant; specifically, where the code checks
AI_PROVIDER === 'openrouter' and constructs providerOptions.openrouter.order,
use order: OPENROUTER_ORDER instead of inlining the array (this ensures the
blocks in the AI configuration that currently repeat the same array are
centralized and reused).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4c1c0433-405f-484c-bbc0-d0875d596a8e
📒 Files selected for processing (5)
.env.templateREADME.mdtests/provider.integration.test.tstests/provider.test.tsutils/ai.ts
| - `AI_API_KEY` — The API key for the inference provider | ||
| - `AI_PROVIDER` — The name of the LLM inference provider | ||
| - `AI_PROVIDER` — The name of the LLM inference provider (e.g. `openrouter`, `minimax`) | ||
| - `AI_BASE_URL` — An OpenAI compatible API endpoint for LLM inference |
There was a problem hiding this comment.
Hyphenate “OpenAI-compatible” for correctness and consistency.
Line 86 should use the compound adjective form.
✏️ Proposed doc fix
-- `AI_BASE_URL` — An OpenAI compatible API endpoint for LLM inference
+- `AI_BASE_URL` — An OpenAI-compatible API endpoint for LLM inference🧰 Tools
🪛 LanguageTool
[grammar] ~86-~86: Use a hyphen to join words.
Context: ..., minimax) - AI_BASE_URL — An OpenAI compatible API endpoint for LLM inferenc...
(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` at line 86, Update the README text for the AI_BASE_URL description
to use the compound adjective form "OpenAI-compatible" instead of "OpenAI
compatible"; locate the line containing the `AI_BASE_URL` entry and change the
phrase to "An OpenAI-compatible API endpoint for LLM inference" to ensure
correctness and consistency.
| // AI_BASE_URL is not set. | ||
| const provider = 'minimax'; | ||
| const preset = PROVIDER_PRESETS[provider]; | ||
| const baseURL = undefined || preset?.baseURL || 'https://openrouter.ai/api/v1'; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify no constant-left `undefined ||` remains in this test file.
rg -nP 'undefined\s*\|\|' tests/provider.integration.test.ts
# Expected result after fix: no matchesRepository: plastic-labs/tutor-gpt
Length of output: 389
🏁 Script executed:
# Search for ESLint configuration files
fd -e '.eslintrc*' -e 'eslint.config.*' -type fRepository: plastic-labs/tutor-gpt
Length of output: 236
🏁 Script executed:
# Check package.json for lint scripts and dependencies
cat package.json | grep -A 20 '"scripts"' | head -30Repository: plastic-labs/tutor-gpt
Length of output: 927
🏁 Script executed:
# View the full test file to see context around the flagged lines
wc -l tests/provider.integration.test.tsRepository: plastic-labs/tutor-gpt
Length of output: 103
🏁 Script executed:
# Find ESLint configuration properly
find . -maxdepth 2 -name '.eslintrc*' -o -name 'eslint.config.*' 2>/dev/nullRepository: plastic-labs/tutor-gpt
Length of output: 85
🏁 Script executed:
# View the test file around the flagged lines
cat -n tests/provider.integration.test.tsRepository: plastic-labs/tutor-gpt
Length of output: 4290
🏁 Script executed:
# Check the ESLint configuration
cat eslint.config.mjsRepository: plastic-labs/tutor-gpt
Length of output: 806
Remove unnecessary undefined || expressions.
Lines 24, 31, 38, and 39 contain undefined || ... patterns that serve no purpose and reduce code clarity. While the no-constant-binary-expression rule would flag these, they don't impact CI since the test directory is excluded from linting. Simplify by removing the undefined || prefix.
Proposed fix
- const baseURL = undefined || preset?.baseURL || 'https://openrouter.ai/api/v1';
+ const baseURL = preset?.baseURL || 'https://openrouter.ai/api/v1';- const model = undefined || preset?.defaultModel || 'gpt-3.5-turbo';
+ const model = preset?.defaultModel || 'gpt-3.5-turbo';Also applies to: 31-31, 38-39
🧰 Tools
🪛 ESLint
[error] 24-24: Unexpected constant truthiness on the left-hand side of a || expression.
(no-constant-binary-expression)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/provider.integration.test.ts` at line 24, Remove the redundant
"undefined ||" prefix from the test constants (e.g., the const baseURL
assignment and the other consts flagged on lines 31, 38, 39) so the expressions
read directly as fallback chains (for example: use preset?.baseURL ||
'https://openrouter.ai/api/v1' instead of undefined || preset?.baseURL || ...);
update the const declarations where the pattern appears (search for "undefined
||" in tests/provider.integration.test.ts) to simplify the expressions and
improve clarity.
Summary
Motivation
Tutor-GPT currently defaults to OpenRouter, but the architecture already uses @ai-sdk/openai-compatible with configurable env vars. This PR adds MiniMax as a recognized provider preset so users can switch to MiniMax-M2.7 (1M context, latest reasoning model) by simply setting AI_PROVIDER=minimax and AI_API_KEY.
Changes
Usage
Test plan
Summary by CodeRabbit
Release Notes
New Features
Documentation