Skip to main content

mimo_api/
lib.rs

1//! # MiMo API - Xiaomi MiMo API Client for Rust
2//!
3//! A Rust client library for Xiaomi MiMo Open Platform API, compatible with OpenAI API format.
4//!
5//! ## Features
6//!
7//! - Chat completions (streaming and non-streaming)
8//! - Function calling / Tool use
9//! - Web search integration
10//! - Multi-modal input (image, audio, video)
11//! - Text-to-speech synthesis
12//! - Structured output
13//! - Deep thinking mode
14//!
15//! ## Example
16//!
17//! ```rust,no_run
18//! use mimo_api::{Client, Message, ChatRequest};
19//!
20//! #[tokio::main]
21//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
22//!     // Create client from environment variable XIAOMI_API_KEY
23//!     let client = Client::from_env()?;
24//!     
25//!     // Create a chat request
26//!     let request = ChatRequest::new("mimo-v2-flash")
27//!         .message(Message::user("Hello, introduce yourself!"));
28//!     
29//!     // Send the request
30//!     let response = client.chat(request).await?;
31//!     
32//!     println!("{}", response.choices[0].message.content);
33//!     Ok(())
34//! }
35//! ```
36//!
37//! ## Environment Variables
38//!
39//! - `XIAOMI_API_KEY`: Your Xiaomi MiMo API key (required)
40
41pub mod client;
42pub mod error;
43pub mod types;
44
45pub use client::Client;
46pub use error::{Error, Result};
47pub use types::*;
48
49/// Re-export commonly used types
50pub mod prelude {
51    pub use crate::client::{
52        Client, StreamingTtsRequestBuilder, StreamingTtsResponse, TtsRequestBuilder, TtsResponse,
53    };
54    pub use crate::types::{
55        Audio, AudioFormat, ChatRequest, ChatResponse, Message, MessageContent, Model,
56        ResponseAudio, Role, StreamChunk, Thinking, ThinkingType, Tool, ToolChoice, TtsStyle,
57        UserLocation, Voice, styled_text,
58    };
59}
60
61pub use client::{StreamingTtsRequestBuilder, StreamingTtsResponse};
62
63/// Schema helpers for creating tool parameter schemas.
64pub mod schema {
65    pub use crate::types::schema::*;
66}