async_openai/assistants/
assistants_.rs1use crate::{
2 config::Config,
3 error::OpenAIError,
4 types::assistants::{
5 AssistantObject, CreateAssistantRequest, DeleteAssistantResponse, ListAssistantsResponse,
6 ModifyAssistantRequest,
7 },
8 Client, RequestOptions,
9};
10
11#[deprecated(
15 note = "Assistants API is deprecated and will be removed in August 2026. Use the Responses API."
16)]
17pub struct Assistants<'c, C: Config> {
18 client: &'c Client<C>,
19 pub(crate) request_options: RequestOptions,
20}
21
22impl<'c, C: Config> Assistants<'c, C> {
23 pub fn new(client: &'c Client<C>) -> Self {
24 Self {
25 client,
26 request_options: RequestOptions::new(),
27 }
28 }
29
30 #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
32 pub async fn create(
33 &self,
34 request: CreateAssistantRequest,
35 ) -> Result<AssistantObject, OpenAIError> {
36 self.client
37 .post("/assistants", request, &self.request_options)
38 .await
39 }
40
41 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
43 pub async fn retrieve(&self, assistant_id: &str) -> Result<AssistantObject, OpenAIError> {
44 self.client
45 .get(
46 &format!("/assistants/{assistant_id}"),
47 &self.request_options,
48 )
49 .await
50 }
51
52 #[crate::byot(T0 = std::fmt::Display, T1 = serde::Serialize, R = serde::de::DeserializeOwned)]
54 pub async fn update(
55 &self,
56 assistant_id: &str,
57 request: ModifyAssistantRequest,
58 ) -> Result<AssistantObject, OpenAIError> {
59 self.client
60 .post(
61 &format!("/assistants/{assistant_id}"),
62 request,
63 &self.request_options,
64 )
65 .await
66 }
67
68 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
70 pub async fn delete(&self, assistant_id: &str) -> Result<DeleteAssistantResponse, OpenAIError> {
71 self.client
72 .delete(
73 &format!("/assistants/{assistant_id}"),
74 &self.request_options,
75 )
76 .await
77 }
78
79 #[crate::byot(R = serde::de::DeserializeOwned)]
81 pub async fn list(&self) -> Result<ListAssistantsResponse, OpenAIError> {
82 self.client.get("/assistants", &self.request_options).await
83 }
84}