pub struct ModelList {
pub data: Vec<Model>,
pub first_id: Option<String>,
pub last_id: Option<String>,
pub has_more: bool,
}Expand description
Response from the List Models API.
Fields§
§data: Vec<Model>List of available models
first_id: Option<String>First ID in the data list (for pagination)
last_id: Option<String>Last ID in the data list (for pagination)
has_more: boolIndicates if there are more results in the requested page direction
Implementations§
Source§impl ModelList
impl ModelList
Sourcepub fn builder() -> ModelListBuilder
pub fn builder() -> ModelListBuilder
Creates a builder for listing models.
§Example
let credentials = Credentials::from_env();
let models = ModelList::builder()
.credentials(credentials)
.limit(10u32)
.create()
.await?;Examples found in repository?
examples/models.rs (line 10)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5 // Load credentials from environment variables
6 let credentials = Credentials::from_env();
7
8 // List all available models
9 println!("Listing all available models:");
10 let models = ModelList::builder()
11 .credentials(credentials.clone())
12 // Add the limit to the request if desired
13 // .limit(5u32)
14 .create()
15 .await?;
16
17 println!("Available models:");
18 for model in &models.data {
19 println!("- {} ({})", model.display_name, model.id);
20 }
21
22 // Get details for a specific model
23 if let Some(first_model) = models.data.first() {
24 println!("\nGetting details for model: {}", first_model.id);
25 let model_details = Model::builder(&first_model.id)
26 .credentials(credentials)
27 .create()
28 .await?;
29
30 println!("Model details:");
31 println!(" ID: {}", model_details.id);
32 println!(" Name: {}", model_details.display_name);
33 println!(" Created at: {}", model_details.created_at);
34 println!(" Type: {}", model_details.model_type);
35 }
36
37 Ok(())
38}Sourcepub async fn create(request: ModelListRequest) -> ApiResponseOrError<Self>
pub async fn create(request: ModelListRequest) -> ApiResponseOrError<Self>
Lists available models with the given request parameters.
§Example
let credentials = Credentials::from_env();
let request = ModelListRequest {
before_id: None,
after_id: None,
limit: Some(20),
credentials: Some(credentials),
};
let models = ModelList::create(request).await?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModelList
impl<'de> Deserialize<'de> for ModelList
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ModelList
impl StructuralPartialEq for ModelList
Auto Trait Implementations§
impl Freeze for ModelList
impl RefUnwindSafe for ModelList
impl Send for ModelList
impl Sync for ModelList
impl Unpin for ModelList
impl UnwindSafe for ModelList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.