chenhg5/cc-connect · error

minimax tts API error %d: %s

Error message

minimax tts API error %d: %s

What it means

MiniMax T2A v2 returns business-level errors inside a 200 OK SSE stream via base_resp.status_code/status_msg. This error surfaces those: the HTTP transport succeeded but MiniMax itself rejected the request (e.g. invalid key, bad model name, quota exhaustion). The JSON chunk is decoded and its non-zero status code and message are propagated.

Source

Thrown at core/tts.go:384

		data := strings.TrimSpace(strings.TrimPrefix(line, "data:"))
		if data == "" {
			continue
		}
		var chunk struct {
			Data struct {
				Audio  string `json:"audio"`
				Status int    `json:"status"`
			} `json:"data"`
			BaseResp struct {
				StatusCode int    `json:"status_code"`
				StatusMsg  string `json:"status_msg"`
			} `json:"base_resp"`
		}
		if err := json.Unmarshal([]byte(data), &chunk); err != nil {
			continue
		}
		if chunk.BaseResp.StatusCode != 0 {
			return nil, "", fmt.Errorf("minimax tts API error %d: %s", chunk.BaseResp.StatusCode, chunk.BaseResp.StatusMsg)
		}
		// MiniMax T2A v2 stream protocol: status=1 carries incremental audio
		// chunks; the final status=2 chunk re-sends the full audio as a
		// trailer for non-stream clients. Appending the trailer doubles the
		// audio length and makes the spoken text play twice, so skip it.
		if chunk.Data.Status == 2 {
			break
		}
		if chunk.Data.Audio != "" {
			audioBytes, err := hex.DecodeString(chunk.Data.Audio)
			if err != nil {
				return nil, "", fmt.Errorf("minimax tts: decode audio hex: %w", err)
			}
			audioBuf.Write(audioBytes)
		}
	}
	if err := scanner.Err(); err != nil {
		return nil, "", fmt.Errorf("minimax tts: read SSE stream: %w", err)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Parse the code and message in the error: 1004/invalid key → replace the API key in config.toml; quota messages → top up the MiniMax account.
  2. Verify model and voice parameters against current MiniMax T2A v2 docs (names change between API versions).
  3. Check account balance/quota in the MiniMax console.
  4. If the error persists with valid credentials, confirm the base_url matches the API version that accepts your request shape.
Defensive patterns

Strategy: try-catch

Validate before calling

if cfg.APIKey == "" || cfg.Model == "" || cfg.VoiceID == "" { return errors.New("minimax tts: missing key/model/voice config") }

Try / catch

if err != nil {
    // error text: "minimax tts API error %d: %s"
    if strings.Contains(err.Error(), "API error 1004") {
        // invalid api key — reconfigure
    } else if strings.Contains(err.Error(), "quota") || strings.Contains(err.Error(), "balance") {
        // top up account / switch provider
    }
}

Prevention

When it happens

Trigger: A data: SSE chunk carries base_resp.status_code != 0 — invalid API key (1004), insufficient balance, unsupported model/voice, request param rejection.

Common situations: Wrong api_key in config.toml; MiniMax account out of credits; model name or voice_id typo; free-tier quota exhausted mid-session.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/07080292f11e6c54. Report an issue: GitHub.