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::{Client, TtsRequestBuilder, TtsResponse};
52    pub use crate::types::{
53        styled_text, Audio, AudioFormat, ChatRequest, ChatResponse, Message, MessageContent, Model,
54        ResponseAudio, Role, StreamChunk, Tool, ToolChoice, TtsStyle, Voice, Thinking, ThinkingType,
55        UserLocation,
56    };
57}
58
59/// Schema helpers for creating tool parameter schemas.
60pub mod schema {
61    pub use crate::types::schema::*;
62}