chenhg5/cc-connect · error
gemini stt: request: %w
Error message
gemini stt: request: %w
What it means
Thrown by GeminiSTT.Transcribe in core/speech.go when the HTTP request to the Gemini API fails at the transport level (g.Client.Do returned an error). This covers DNS failures, connection refused/reset, TLS errors, and context cancellation/timeouts — no HTTP response was received.
Source
Thrown at core/speech.go:267
},
}
jsonData, err := json.Marshal(reqBody)
if err != nil {
return "", fmt.Errorf("gemini stt: marshal request: %w", err)
}
apiURL := fmt.Sprintf("%s/models/%s:generateContent", g.BaseURL, url.PathEscape(g.Model))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, apiURL, bytes.NewReader(jsonData))
if err != nil {
return "", fmt.Errorf("gemini stt: create request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-goog-api-key", g.APIKey)
resp, err := g.Client.Do(req)
if err != nil {
return "", fmt.Errorf("gemini stt: request: %w", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("gemini stt: read response: %w", err)
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("gemini stt API %d: %s", resp.StatusCode, string(body))
}
var result struct {
Candidates []struct {
Content struct {
Parts []struct {
Text string `json:"text"`
} `json:"parts"`View on GitHub (pinned to 4000b2338a)
Solutions
- Check network connectivity and that generativelanguage.googleapis.com is reachable (curl the endpoint).
- Inspect the wrapped error: context deadline exceeded -> increase HTTP timeout or reduce audio size; connection refused/blocked -> fix firewall/proxy or use a reachable region.
- Configure HTTP(S)_PROXY correctly if behind a corporate proxy.
- Retry transient network errors with backoff.
- If TLS errors, update the system CA bundle or fix proxy interception.
Defensive patterns
Strategy: retry
Validate before calling
conn, err := net.DialTimeout("tcp", "generativelanguage.googleapis.com:443", 5*time.Second)
if err != nil { return fmt.Errorf("gemini endpoint unreachable: %w", err) }
conn.Close() Try / catch
var text string
var lastErr error
for i := 0; i < 3; i++ {
text, lastErr = stt.Transcribe(ctx, audio)
if lastErr == nil { break }
if errors.Is(lastErr, context.DeadlineExceeded) { break } // don't retry timeouts
time.Sleep(time.Duration(1<<i) * time.Second)
} Prevention
- Set a generous HTTP client timeout for large audio uploads.
- Verify firewall/proxy allows generativelanguage.googleapis.com:443.
- Configure HTTPS_PROXY explicitly in restricted networks.
- Check connectivity at startup via a doctor/health check.
- Respect ctx cancellation and surface timeouts clearly to the user.
When it happens
Trigger: g.Client.Do(req) errors: no network connectivity, DNS resolution failure, server unreachable/firewall blocking, TLS certificate problems, or the request context (ctx) is cancelled or times out mid-request.
Common situations: Machine offline or behind a restrictive firewall/proxy; generativelanguage.googleapis.com blocked (e.g. in some regions); long audio uploads exceeding the HTTP client timeout; user cancels the operation; corporate MITM proxy with untrusted cert.
Related errors
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f517607ebfaf2365.
Report an issue: GitHub.