Skip to content

fix(minimax): map native speech status codes and document TTS - #640

Merged
SantiagoDePolonia merged 4 commits into
mainfrom
feat/native-tts-minimax
Aug 4, 2026
Merged

fix(minimax): map native speech status codes and document TTS#640
SantiagoDePolonia merged 4 commits into
mainfrom
feat/native-tts-minimax

Conversation

@SantiagoDePolonia

@SantiagoDePolonia SantiagoDePolonia commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Reason: Follow-up to #621 — surface MiniMax speech failures with their real meaning and document the new native TTS support.

Summary

  • Map t2a_v2 base_resp.status_code values to real errors instead of a blanket 502: rate limits (1002/1039) → 429, authentication (1004) → 401, insufficient balance (1008) → 402, sensitive input / invalid parameters (1026/2013) → 400. Unknown codes remain provider errors, now with the native code in the message.
  • Add a MiniMax provider guide (docs/providers/minimax.mdx): setup with both regional endpoints, temperature clamping, the /v1/audio/speecht2a_v2 translation (native voice IDs, formats, speed range), the MINIMAX_MODELS routability note for speech models, and the unsupported list (instructions, transcription, realtime).
  • Correct the Audio API page: MiniMax TTS is natively adapted (the page previously listed MiniMax as generically OpenAI-compatible for audio, which was never the case), and note the existing Xiaomi/Cohere native translations.

Provider-specific behavior

  • MiniMax reports failures as HTTP 200 with a non-zero base_resp.status_code; clients now see 400/401/402/429 for caller mistakes rather than opaque 502s.
  • Not verified against the live API (no MiniMax key available): whether t2a_v2 needs a GroupId query param on international keys, and current speech model IDs.

Checks

  • go test ./internal/...
  • golangci-lint run ./internal/providers/minimax/...
  • Pre-commit suite (race tests, perf guard, mint validate)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added MiniMax provider documentation covering setup, configuration, speech options, model routing, and supported features.
    • Documented native audio translation support for Xiaomi MiMo, Cohere, and MiniMax alongside OpenAI-compatible providers.
    • Added MiniMax to the provider documentation navigation.
  • Bug Fixes

    • MiniMax speech errors now provide clearer classifications for rate limits, authentication, billing, invalid requests, and other failures instead of a generic error.

SantiagoDePolonia and others added 2 commits August 3, 2026 15:31
MiniMax reports t2a_v2 failures as HTTP 200 with a non-zero
base_resp.status_code. Relaying every one as a 502 masked caller
mistakes, so map the common codes: rate limits (1002/1039) to 429,
authentication (1004) to 401, insufficient balance (1008) to 402, and
sensitive input / invalid parameters (1026/2013) to 400. Unknown codes
still surface as provider errors, now with the native code in the
message.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add a MiniMax provider page covering setup, temperature clamping, the
/v1/audio/speech translation to t2a_v2 (voice IDs, formats, speed
range, MINIMAX_MODELS routability), error mapping, and unsupported
features. Correct the Audio API page: MiniMax TTS is now natively
adapted, and Xiaomi/Cohere translations already were.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:08
@mintlify

mintlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
gomodel 🟢 Ready View Preview Aug 3, 2026, 2:10 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8b5d7054-f818-42be-8c90-d1435550ac68

📥 Commits

Reviewing files that changed from the base of the PR and between b051dd7 and 40de5ea.

📒 Files selected for processing (1)
  • internal/providers/minimax/audio_test.go

📝 Walkthrough

Walkthrough

The PR adds MiniMax provider documentation and navigation. It maps MiniMax native speech status codes to typed gateway errors and adds table-driven tests for twelve status codes.

Changes

MiniMax audio integration

Layer / File(s) Summary
Native speech status mapping
internal/providers/minimax/audio.go, internal/providers/minimax/audio_test.go
MiniMax status codes now map to rate-limit, authentication, payment-required, invalid-request, or gateway errors. Tests verify twelve status codes, typed errors, provider identity, native codes, and messages.
Audio provider documentation
docs/providers/minimax.mdx, docs/providers/overview.mdx, docs/docs.json, docs/advanced/audio-api.mdx
The documentation describes MiniMax configuration, native speech translation, supported options, limitations, error handling, and navigation links.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: copilot, octo-patch

Poem

A rabbit checked each speech reply,
While MiniMax codes went hopping by.
The docs now show the route,
Tests check each status out,
And typed errors safely fly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the MiniMax speech status mapping fix and related TTS documentation update.
Description check ✅ Passed The description explains the changes, rationale, provider-specific behavior, validation steps, and known verification limits.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/native-tts-minimax

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/providers/minimax/audio_test.go`:
- Around line 181-188: Extend the error-message assertions in the relevant audio
test to verify that gatewayErr.Message also contains
strconv.Itoa(tt.nativeStatus). Keep the existing statusMsg assertion and
status/type checks unchanged.

In `@internal/providers/minimax/audio.go`:
- Around line 156-157: Update the invalid-request branch for statuses 1026 and
2013 in the MiniMax status-mapping function to set the returned GatewayError’s
Provider to "minimax" before returning it. Extend
TestCreateSpeech_MapsNativeStatusCodes to assert this provider attribution while
preserving the existing typed invalid-request error.
- Around line 150-157: Update speechStatusError to handle MiniMax audio codes
2049 and 20132 explicitly: map 2049 to the existing authentication error path
and 20132 to the existing invalid-request error path, preserving the provider
name and message conventions used by neighboring cases instead of falling
through to the default 502 branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 30e2cd43-9393-48ab-9b6b-ebf6dc5fd088

📥 Commits

Reviewing files that changed from the base of the PR and between b10ee6b and e4dc0a9.

📒 Files selected for processing (6)
  • docs/advanced/audio-api.mdx
  • docs/docs.json
  • docs/providers/minimax.mdx
  • docs/providers/overview.mdx
  • internal/providers/minimax/audio.go
  • internal/providers/minimax/audio_test.go

Comment thread internal/providers/minimax/audio_test.go
Comment thread internal/providers/minimax/audio.go Outdated
Comment thread internal/providers/minimax/audio.go Outdated
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

Not safe to merge until MiniMax invalid-request errors retain their provider attribution.

The affected MiniMax request path and the handled-error logging behavior were executed with statuses 1026 and 2013, reproducing the missing provider field. The error classification remains correct, but operational logs lose the upstream source for these failures.

Files Needing Attention: internal/providers/minimax/audio.go needs to set the provider on invalid-request errors for native statuses 1026 and 2013.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex produced a proof for a posted P2 finding and wired up a focused MiniMax native-status reproduction test, including its source and related status outputs.
  • T-Rex gathered and reviewed outputs showing the MiniMax native status output with an empty provider and a structured log contrast with and without the MiniMax provider to validate provider-related behavior.
  • T-Rex executed the contract-validation suite, running TestReviewNativeInvalidRequestProvider, TestReviewProviderAttributionLogContrast, and TestCreateSpeech_MapsNativeStatusCodes, and all tests completed with exit code 0.
  • T-Rex notes that review-authored tests were removed from source after execution, with exact sources and command outputs preserved in the uploaded artifacts.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (1)

  1. General comment

    P2 MiniMax native invalid-request mappings omit provider attribution

    • Bug
      • For native MiniMax speech base_resp.status_code 1026 and 2013, speechStatusError returns a GatewayError with an empty Provider. The real CreateSpeech path confirms this for both codes. Consequently, Go JSON serialization omits provider due to omitempty, GatewayError.Error() has no [minimax] prefix, and logHandledError omits the structured provider attribute. The public OpenAI-compatible API envelope is unaffected because ToJSON() does not expose provider regardless of its value.
    • Cause
      • internal/providers/minimax/audio.go:157 calls core.NewInvalidRequestError(message, nil), whose core constructor initializes no Provider, unlike adjacent MiniMax mappings and ParseProviderError 4xx mappings.
    • Fix
      • At internal/providers/minimax/audio.go:157, construct the invalid-request error, assign Provider = "minimax", and return it: err := core.NewInvalidRequestError(message, nil); err.Provider = "minimax"; return err. A small provider-aware invalid-request helper would also make this less error-prone if desired.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "docs(minimax): document native TTS and a..." | Re-trigger Greptile

Comment thread internal/providers/minimax/audio.go Outdated
case 1008: // insufficient balance
return core.NewProviderError("minimax", http.StatusPaymentRequired, message, nil)
case 1026, 2013: // sensitive input content / invalid request parameters
return core.NewInvalidRequestError(message, nil)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Invalid requests lose provider attribution

Native MiniMax status codes 1026 and 2013 are returned through NewInvalidRequestError, whose Provider field is empty. The actual CreateSpeech path returns an empty provider for both statuses, so the handled-error log omits the provider attribute and internal error serialization omits MiniMax attribution. Set Provider to "minimax" before returning this error, consistent with the adjacent status mappings.

Artifacts

Focused MiniMax native-status reproduction test source

  • Review-authored test source starts a local MiniMax-shaped HTTP server and invokes the actual CreateSpeech path for statuses 1026 and 2013, showing the provider-attribution path under test.

MiniMax native status output with empty provider

  • Executed MiniMax provider test output shows both native statuses 1026 and 2013 return `provider=""`, while public and struct serialization omit provider; the reported defect is reproduced.

Server log provider-attribution contrast test source

  • Review-authored server helper test source executes the actual structured logging helper with blank and MiniMax provider values to isolate the externally visible observability effect.

Structured log contrast with and without MiniMax provider

  • Executed server logging output shows the blank-Provider current case lacks a provider field and the MiniMax-attributed comparison emits `"provider":"minimax"`; logs are materially affected.

Existing MiniMax native status mapping regression output

  • Executed existing MiniMax native-status mapping test passes for all mapped statuses, confirming the focused mapping behavior remains executable after review cleanup.

View artifacts

T-Rex Ran code and verified through T-Rex

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b051dd7Provider = "minimax" is set on the invalid-request branch and asserted in the mapping test.

…bution

Handle more codes from MiniMax's official error table: invalid API key
(2049) joins 1004 as 401, invalid voice_id/samples (20132) and
invisible-character input (1042) join the 400 branch, and rate growth
limit (2045) plus usage limit (2056) join the 429 branch. Set
Provider on the invalid-request errors so structured logs keep MiniMax
attribution, and assert provider plus the native status code in the
mapping test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/providers/minimax/audio_test.go`:
- Around line 151-160: Extend the table-driven cases in the audio error mapping
test with one row for native status 2045 expecting core.ErrorTypeRateLimit and
one row for native status 1042 expecting core.ErrorTypeInvalidRequest. Match the
existing row structure and assert the corresponding HTTP status and
representative messages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a3f02afd-b282-4b4e-bcc5-4b798b85f47f

📥 Commits

Reviewing files that changed from the base of the PR and between e4dc0a9 and b051dd7.

📒 Files selected for processing (2)
  • internal/providers/minimax/audio.go
  • internal/providers/minimax/audio_test.go

Comment thread internal/providers/minimax/audio_test.go
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@SantiagoDePolonia
SantiagoDePolonia merged commit ca786dd into main Aug 4, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants