Expand description
An async Rust client for the MiniMax APIs.
Everything goes through MinimaxClient, which owns a reqwest::Client
internally. Keep one instance alive for the lifetime of your program so
connections are reused; cloning it is cheap and shares the same pool.
§Capabilities
| Area | Methods |
|---|---|
| Speech | tts_stream, tts_synthesize |
| Music | generate_lyrics, generate_music, stream_music, stream_music_with_lyrics |
| Covers | cover_preprocess, generate_cover, cover_generate_with_lyrics |
| Images | image_generation |
| Voices | get_voices, voice_design, delete_voice |
| Cloning | upload_file, voice_clone |
§Quick start
use futures_util::StreamExt;
use minimax_client::{types::TtsRequest, MinimaxClient};
let client = MinimaxClient::from_env()?;
let request = TtsRequest {
text: "Hello, world!".into(),
..Default::default()
};
let mut stream = client.tts_stream(&request);
while let Some(chunk) = stream.next().await {
let pcm = chunk?; // raw PCM i16 little-endian at 32 kHz
println!("received {} bytes", pcm.len());
}§Streaming behavior
The streaming methods spawn a background Tokio task, so they must be called from within a runtime and the request begins before the stream is first polled. Chunks are buffered in an unbounded queue, which keeps the HTTP connection draining even when the consumer falls behind; if you cannot keep up with real time, write chunks to disk rather than holding them in memory. Dropping the stream stops the background task at the next chunk boundary.
§Error handling
Every method returns Result<T, Error>. Error distinguishes
transport failures from MiniMax’s own base_resp codes, and offers
is_auth_error,
is_rate_limited, and
is_retryable so you can branch without matching on
numeric codes:
match client.tts_synthesize(&request).await {
Ok(result) => println!("{} bytes", result.audio_bytes.len()),
Err(e) if e.is_rate_limited() => println!("slow down: {e}"),
Err(e) if e.is_auth_error() => println!("check your API key: {e}"),
Err(e) => println!("failed: {e}"),
}§TLS
The rustls-tls feature is enabled by default. To link against the
platform’s TLS stack instead, disable default features and enable
native-tls.
Re-exports§
Modules§
Structs§
- Lyrics
With Music Stream - Lyrics paired with the audio stream that sings them.
- Minimax
Client - An async client for the MiniMax APIs.
Constants§
- API_
KEY_ ENV - The environment variable read by
MinimaxClient::from_env. - BASE_
URL_ CHINA - The mainland China endpoint.
- BASE_
URL_ GLOBAL - The global endpoint.
- BASE_
URL_ US_ WEST - The western United States endpoint.
- DEFAULT_
BASE_ URL - The default MiniMax base URL, matching the official OpenAPI specification.