# Implementation Plan: MiniMax Provider Integration (minimax_provider_20260306)

> **Reference:** [Spec](./spec.md)

## Phase 1: Provider Registration
Focus: Add minimax to PROVIDERS lists and credentials

- [x] Task 1.1: Add "minimax" to PROVIDERS list [b79c1fc]
    - WHERE: src/gui_2.py line 28
    - WHAT: Add "minimax" to PROVIDERS list
    - HOW: Edit the list

- [x] Task 1.2: Add "minimax" to app_controller.py PROVIDERS [b79c1fc]
    - WHERE: src/app_controller.py line 117
    - WHAT: Add "minimax" to PROVIDERS list

- [x] Task 1.3: Add minimax credentials template [b79c1fc]
    - WHERE: src/ai_client.py (credentials template section)
    - WHAT: Add minimax API key section to credentials template
    - HOW:
      ```toml
      [minimax]
      api_key = "your-key"
      ```

## Phase 2: Client Implementation
Focus: Implement MiniMax client and model listing

- [x] Task 2.1: Add client globals [b79c1fc]
    - WHERE: src/ai_client.py (around line 73)
    - WHAT: Add _minimax_client, _minimax_history, _minimax_history_lock

- [x] Task 2.2: Implement _list_minimax_models [b79c1fc]
    - WHERE: src/ai_client.py
    - WHAT: Return list of available models
    - HOW:
      ```python
      def _list_minimax_models(api_key: str) -> list[str]:
          return ["MiniMax-M2.5", "MiniMax-M2.5-highspeed", "MiniMax-M2.1", "MiniMax-M2.1-highspeed", "MiniMax-M2"]
      ```

- [x] Task 2.3: Implement _classify_minimax_error
    - WHERE: src/ai_client.py
    - WHAT: Map MiniMax errors to ProviderError

- [x] Task 2.4: Implement _ensure_minimax_client
    - WHERE: src/ai_client.py
    - WHAT: Initialize OpenAI client with MiniMax base URL

## Phase 3: Send Implementation
Focus: Implement _send_minimax function

- [x] Task 3.1: Implement _send_minimax
    - WHERE: src/ai_client.py (after _send_deepseek)
    - WHAT: Send chat completion request to MiniMax API
    - HOW:
      - Use OpenAI SDK with base_url="https://api.minimax.chat/v1"
      - Support streaming and non-streaming
      - Handle tool calls
      - Manage conversation history

- [x] Task 3.2: Add minimax to list_models routing
    - WHERE: src/ai_client.py list_models function
    - WHAT: Add elif provider == "minimax": return _list_minimax_models()

## Phase 4: Integration
Focus: Wire minimax into the send function

- [x] Task 4.1: Add minimax to set_provider
    - WHERE: src/ai_client.py set_provider function
    - WHAT: Validate minimax model

- [x] Task 4.2: Add minimax to send routing
    - WHERE: src/ai_client.py send function (around line 1607)
    - WHAT: Add elif for minimax to call _send_minimax

- [x] Task 4.3: Add minimax to reset_session
    - WHERE: src/ai_client.py reset_session function
    - WHAT: Clear minimax history

- [x] Task 4.4: Add minimax to history bleeding
    - WHERE: src/ai_client.py _add_bleed_derived
    - WHAT: Handle minimax history

## Phase 5: Testing
Focus: Verify integration works

- [x] Task 5.1: Write unit tests for minimax integration
    - WHERE: tests/test_minimax_provider.py
    - WHAT: Test model listing, error classification

- [x] Task 5.2: Manual verification
    - WHAT: Test provider switching in GUI
