1use std::time::Duration;
4
5use reqwest::Client;
6pub use serde::{Deserialize, Serialize};
8
9use crate::{config::ApiConfig, Error, Result};
10
11pub mod client;
12pub mod types;
13pub mod usage_tracker;
14
15pub use client::{AnthropicApiClient, ApiClient};
16pub use types::*;
17pub use usage_tracker::LocalUsageTracker;
18
19#[derive(Debug, Clone)]
21pub struct HttpClient {
22 client: Client,
23 config: ApiConfig,
24}
25
26impl HttpClient {
27 pub fn new(config: ApiConfig) -> Result<Self> {
29 let client = Client::builder()
30 .timeout(Duration::from_secs(config.timeout_seconds))
31 .build()
32 .map_err(Error::Http)?;
33
34 Ok(Self { client, config })
35 }
36
37 pub fn client(&self) -> &Client {
39 &self.client
40 }
41
42 pub fn config(&self) -> &ApiConfig {
44 &self.config
45 }
46}