#!/usr/bin/env bash # shellcheck disable=SC2034 # variables consumed by lib/common.sh # mxclaude — launch Claude Code on MiniMax's Anthropic-compatible API. # # Uses the official MiniMax Anthropic-compatible endpoint: # - China (default): https://api.minimaxi.com/anthropic # - International: https://api.minimax.io/anthropic (set MINIMAX_BASE_URL) # # MiniMax-M3 is a 1M-context flagship model optimized for agentic reasoning, # tool use, and coding tasks. Requires a Coding Plan (Token Plan) API key. # # Reads MINIMAX_API_KEY from the environment first, then falls back to # ~/.zshrc / ~/.bashrc / ~/.bash_profile / ~/.profile if not already exported. # # Quick start (no install needed): # chmod +x mxclaude # ./mxclaude # # Optional — make it globally available: # sudo mv mxclaude /usr/local/bin/ && sudo chmod +x /usr/local/bin/mxclaude # # Use: # mxclaude # start on MiniMax-M3 (1M context, flagship) # mxclaude fast # start on MiniMax-M2.5 (cheaper / faster) # mxclaude long # request 1M context window (M3 native support) # mxclaude effort max # set reasoning effort (low|medium|high|xhigh|max) # mxclaude update # git pull latest from this repo # mxclaude --help # any remaining flag is forwarded to claude # # Optional env overrides: # MINIMAX_MODEL=MiniMax-M3 # main model # MINIMAX_FLASH_MODEL=MiniMax-M2.5 # flash / haiku / subagent tier # MINIMAX_BASE_URL=https://.../anthropic # custom Anthropic-compatible base URL # MINIMAX_CTX=1048576 # max context tokens (defaults to 1M with `long`) # MINIMAX_OUTPUT=8000 # cap output tokens # MINIMAX_EFFORT=max # CLAUDE_CODE_EFFORT_LEVEL # # In-session switch: # /model MiniMax-M2.5 # switch to the fast tier # /model MiniMax-M3 # switch back to flagship # # Get your API key: https://platform.minimaxi.com # set -euo pipefail # Resolve symlink to find the real script directory. _SELF="$0" if [ -L "$_SELF" ]; then _LINK="$(readlink "$_SELF")" case "$_LINK" in /*) _SELF="$_LINK" ;; *) _SELF="$(cd "$(dirname "$_SELF")" && pwd)/$_LINK" ;; esac fi SELF_DIR="$(cd "$(dirname "$_SELF")" && pwd)" if [ -f "$SELF_DIR/lib/common.sh" ]; then source "$SELF_DIR/lib/common.sh" elif [ -f "$SELF_DIR/../lib/common.sh" ]; then source "$SELF_DIR/../lib/common.sh" else echo "mxclaude: cannot find lib/common.sh. Reinstall or cd to repo." >&2; exit 1; fi check_version "mxclaude" "$@" PRO_MODEL="${MINIMAX_MODEL:-MiniMax-M3}" FLASH_MODEL="${MINIMAX_FLASH_MODEL:-MiniMax-M2.5}" if [ $# -gt 0 ] && [ "$1" = "update" ]; then do_update "mxclaude" "MXCLAUDE_HOME" fi API_KEY="$(resolve_api_key "MINIMAX_API_KEY")" if [ -z "$API_KEY" ]; then echo "❌ MINIMAX_API_KEY not found." >&2 echo " Add one line to ~/.zshrc or ~/.bashrc:" >&2 echo " export MINIMAX_API_KEY=your_minimax_api_key" >&2 echo " Get your key at: https://platform.minimaxi.com" >&2 exit 1 fi BASE_URL="${MINIMAX_BASE_URL:-https://api.minimaxi.com/anthropic}" LONG_CTX=0 EFFORT="${MINIMAX_EFFORT:-}" MAIN_MODEL="$PRO_MODEL" while [ $# -gt 0 ]; do case "$1" in fast|flash) MAIN_MODEL="$FLASH_MODEL"; shift ;; long) LONG_CTX=1; shift ;; effort) case "${2:-}" in low|medium|high|xhigh|max) EFFORT="$2"; shift 2 ;; *) echo "mxclaude: invalid effort level '${2:-}'. Use: low medium high xhigh max" >&2; exit 1 ;; esac ;; --) shift; break ;; *) break ;; esac done if [ "$MAIN_MODEL" = "$PRO_MODEL" ]; then OTHER_MODEL="$FLASH_MODEL" OTHER_DESC="MiniMax M2.5 — fast / cheap tier" else OTHER_MODEL="$PRO_MODEL" OTHER_DESC="MiniMax M3 — full reasoning" fi export_anthropic_base export CLAUDE_CODE_SUBAGENT_MODEL="$FLASH_MODEL" set_custom_model "$OTHER_MODEL" "$MAIN_MODEL" "$OTHER_DESC" CTX="${MINIMAX_CTX:-}" OUTPUT_CAP="${MINIMAX_OUTPUT:-}" apply_context_and_effort show_banner_and_launch "MiniMax" "$@"