async_openai_alt/
model.rs1use 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 pub async fn list(&self) -> Result<ListModelResponse, OpenAIError> {
23 self.client.get("/models").await
24 }
25
26 pub async fn retrieve(&self, id: &str) -> Result<Model, OpenAIError> {
29 self.client.get(format!("/models/{id}").as_str()).await
30 }
31
32 pub async fn delete(&self, model: &str) -> Result<DeleteModelResponse, OpenAIError> {
34 self.client
35 .delete(format!("/models/{model}").as_str())
36 .await
37 }
38}