Config: add MiniMax direct API authentication option

Makes apiKey optional in ModelProviderConfig so MiniMax can use auth
profiles or environment variables (MINIMAX_API_KEY) instead of requiring
explicit config.

Changes:
- src/config/types.ts: apiKey changed from required to optional
- src/config/zod-schema.ts: use z.string().min(1).optional() for validation
- src/commands/configure.ts: add minimax-api auth choice in wizard
- src/commands/onboard-auth.ts: MiniMax provider omits apiKey (uses env/auth)
- patches/@mariozechner__pi-ai@0.42.1.patch: map minimax → MINIMAX_API_KEY

Auth Resolution Order (unchanged):
1. Auth profiles (highest priority)
2. Environment variables (MINIMAX_API_KEY, etc.)
3. Custom provider apiKey from models.json (lowest priority)
This commit is contained in:
mneves75
2026-01-10 10:57:09 -03:00
parent 0258c746bc
commit 3e2e3eb023
6 changed files with 69 additions and 3 deletions

View File

@@ -70,6 +70,7 @@ import { healthCommand } from "./health.js";
import { formatHealthCheckFailure } from "./health-format.js";
import {
applyAuthProfileConfig,
applyMinimaxApiConfig,
applyMinimaxConfig,
applyMinimaxHostedConfig,
applyOpencodeZenConfig,
@@ -369,6 +370,7 @@ async function promptAuthConfig(
| "gemini-api-key"
| "apiKey"
| "minimax-cloud"
| "minimax-api"
| "minimax"
| "opencode-zen"
| "skip";
@@ -788,6 +790,21 @@ async function promptAuthConfig(
next = applyMinimaxHostedConfig(next);
} else if (authChoice === "minimax") {
next = applyMinimaxConfig(next);
} else if (authChoice === "minimax-api") {
const key = guardCancel(
await text({
message: "Enter MiniMax API key",
validate: (value) => (value?.trim() ? undefined : "Required"),
}),
runtime,
);
await setMinimaxApiKey(String(key).trim());
next = applyAuthProfileConfig(next, {
profileId: "minimax:default",
provider: "minimax",
mode: "api_key",
});
next = applyMinimaxApiConfig(next);
} else if (authChoice === "opencode-zen") {
note(
[

View File

@@ -336,7 +336,7 @@ export function applyMinimaxApiProviderConfig(
const providers = { ...cfg.models?.providers };
providers.minimax = {
baseUrl: MINIMAX_API_BASE_URL,
apiKey: "", // Resolved via MINIMAX_API_KEY env var or auth profile
// apiKey omitted: resolved via MINIMAX_API_KEY env var or auth profile by default.
api: "anthropic-messages",
models: [buildMinimaxApiModelDefinition(modelId)],
};