pub struct Client { /* private fields */ }Expand description
A client for interacting with the DeepSeek API.
§Example
#[tokio::main]
async fn main() {
use deepseek_api::ClientBuilder;
let api_key = "your_api_key".to_string();
let client = ClientBuilder::new(api_key).build().unwrap();
// Get available models
let models = client.models().await.unwrap();
// Get user balance
let balance = client.balance().await.unwrap();
// Create a chat completion
let chat = client.chat();
}§Fields
client- The underlying HTTP client.host- The base URL for the DeepSeek API.
Implementations§
Source§impl Client
impl Client
pub fn chat(&self) -> ChatCompletions
Sourcepub async fn models(&self) -> Result<ModelResp>
pub async fn models(&self) -> Result<ModelResp>
Retrieves the list of available models from the DeepSeek API.
This method sends a GET request to the /models endpoint of the DeepSeek API
and returns a Result containing a ModelResp on success.
§Errors
This function will return an error if the request fails or if the response
cannot be deserialized into a ModelResp.
§Example
#[tokio::main]
async fn main() {
use deepseek_api::ClientBuilder;
let api_key = "your_api_key".to_string();
let client = ClientBuilder::new(api_key).build().unwrap();
let models = client.models().await.unwrap();
println!("{:?}", models);
}For more information, see the DeepSeek API documentation.
Sourcepub async fn balance(&self) -> Result<BalanceResp>
pub async fn balance(&self) -> Result<BalanceResp>
Retrieves the balance information of the user from the DeepSeek API.
This method sends a GET request to the /user/balance endpoint of the DeepSeek API
and returns a Result containing a BalanceResp on success.
§Errors
This function will return an error if the request fails or if the response
cannot be deserialized into a BalanceResp.
§Example
#[tokio::main]
async fn main() {
use deepseek_api::ClientBuilder;
let api_key = "your_api_key".to_string();
let client = ClientBuilder::new(api_key).build().unwrap();
let balance = client.balance().await.unwrap();
println!("{:?}", balance);
}For more information, see the DeepSeek API documentation.