1use crate::{
2 config::Config,
3 error::OpenAIError,
4 types::{DeleteModelResponse, ListModelResponse, Model},
5 Client,
6};
7
8pub struct Models<'c, C: Config> {
12 client: &'c Client<C>,
13}
14
15impl<'c, C: Config> Models<'c, C> {
16 pub fn new(client: &'c Client<C>) -> Self {
17 Self { client }
18 }
19
20 #[crate::byot(R = serde::de::DeserializeOwned)]
23 pub async fn list(&self) -> Result<ListModelResponse, OpenAIError> {
24 self.client.get("/models").await
25 }
26
27 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
30 pub async fn retrieve(&self, id: &str) -> Result<Model, OpenAIError> {
31 self.client.get(format!("/models/{id}").as_str()).await
32 }
33
34 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
36 pub async fn delete(&self, model: &str) -> Result<DeleteModelResponse, OpenAIError> {
37 self.client
38 .delete(format!("/models/{model}").as_str())
39 .await
40 }
41}