Skip to main content

edgequake_sdk/resources/
models.rs

1//! Models resource.
2//!
3//! WHY: Models endpoints verified against routes.rs.
4
5use crate::client::EdgeQuakeClient;
6use crate::error::Result;
7use crate::types::operations::*;
8
9pub struct ModelsResource<'a> {
10    pub(crate) client: &'a EdgeQuakeClient,
11}
12
13impl<'a> ModelsResource<'a> {
14    /// `GET /api/v1/models` — returns provider catalog.
15    pub async fn list(&self) -> Result<ProviderCatalog> {
16        self.client.get("/api/v1/models").await
17    }
18
19    /// `GET /api/v1/models/health` — returns bare array of provider health.
20    pub async fn providers_health(&self) -> Result<Vec<ProviderHealthInfo>> {
21        self.client.get("/api/v1/models/health").await
22    }
23
24    /// `GET /api/v1/settings/provider/status`
25    pub async fn current_provider(&self) -> Result<ProviderStatus> {
26        self.client.get("/api/v1/settings/provider/status").await
27    }
28
29    /// `PUT /api/v1/settings/provider`
30    pub async fn set_provider(&self, provider: &str) -> Result<ProviderStatus> {
31        let body = serde_json::json!({ "provider": provider });
32        self.client
33            .put("/api/v1/settings/provider", Some(&body))
34            .await
35    }
36
37    /// `GET /api/v1/models/llm` — List LLM models only.
38    pub async fn list_llm(&self) -> Result<serde_json::Value> {
39        self.client.get("/api/v1/models/llm").await
40    }
41
42    /// `GET /api/v1/models/embedding` — List embedding models only.
43    pub async fn list_embedding(&self) -> Result<serde_json::Value> {
44        self.client.get("/api/v1/models/embedding").await
45    }
46
47    /// `GET /api/v1/models/{provider}` — Get models for a specific provider.
48    pub async fn get_provider(&self, provider: &str) -> Result<serde_json::Value> {
49        self.client
50            .get(&format!("/api/v1/models/{provider}"))
51            .await
52    }
53
54    /// `GET /api/v1/models/{provider}/{model}` — Get specific model details.
55    pub async fn get_model(
56        &self,
57        provider: &str,
58        model: &str,
59    ) -> Result<serde_json::Value> {
60        self.client
61            .get(&format!("/api/v1/models/{provider}/{model}"))
62            .await
63    }
64}