chenhg5/cc-connect · error

mimo tts: request: %w

Error message

mimo tts: request: %w

What it means

This error wraps m.Client.Do(req) failing for the MiMo TTS call to /chat/completions — the HTTP round-trip itself failed, so no response exists. Causes include DNS failure, connection refused, TLS errors, and context cancellation or deadline exceeded in flight.

Source

Thrown at core/tts.go:484

		},
	}
	jsonData, err := json.Marshal(reqBody)
	if err != nil {
		return nil, "", fmt.Errorf("mimo tts: marshal request: %w", err)
	}

	url := strings.TrimRight(m.BaseURL, "/") + "/chat/completions"
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(jsonData))
	if err != nil {
		return nil, "", fmt.Errorf("mimo tts: create request: %w", err)
	}
	// MiMo authenticates via "api-key" header, not "Authorization: Bearer".
	req.Header.Set("api-key", m.APIKey)
	req.Header.Set("Content-Type", "application/json")

	resp, err := m.Client.Do(req)
	if err != nil {
		return nil, "", fmt.Errorf("mimo tts: request: %w", err)
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, "", fmt.Errorf("mimo tts: read response: %w", err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, "", fmt.Errorf("mimo tts API %d: %s", resp.StatusCode, body)
	}

	var result struct {
		Choices []struct {
			Message struct {
				Audio struct {
					Data string `json:"data"`
				} `json:"audio"`
			} `json:"message"`

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Test connectivity to the MiMo host directly (curl -v) from the same host.
  2. Unwrap the error: context.DeadlineExceeded → raise the timeout; connection refused → fix base_url or wait for service recovery.
  3. Set/verify HTTPS_PROXY if the environment requires a proxy for egress.
  4. Retry with backoff for transient network failures.
Defensive patterns

Strategy: retry

Validate before calling

if u, err := url.Parse(cfg.BaseURL); err != nil || u.Host == "" { return fmt.Errorf("invalid mimo base_url") }

Try / catch

if err != nil && strings.Contains(err.Error(), "mimo tts: request:") {
    if errors.Is(err, context.DeadlineExceeded) {
        // extend timeout
    } else if isConnectionRefused(err) {
        // endpoint down: check base_url / wait for recovery
    }
}

Prevention

When it happens

Trigger: MiMo endpoint unreachable (wrong host, service down); DNS failure; TLS handshake problem; ctx deadline exceeded during the request; network interruption.

Common situations: No outbound internet in container/CI; misconfigured mimo base_url in config.toml; proxy required but not set; client timeout too short for WAV synthesis.

Related errors


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