pub struct ModelListBuilder { /* private fields */ }Expand description
Builder for ModelListRequest.
Implementations§
Source§impl ModelListBuilder
impl ModelListBuilder
Sourcepub fn before_id<VALUE: Into<String>>(self, value: VALUE) -> Self
pub fn before_id<VALUE: Into<String>>(self, value: VALUE) -> Self
ID of the object to use as a cursor for pagination (previous page)
Sourcepub fn after_id<VALUE: Into<String>>(self, value: VALUE) -> Self
pub fn after_id<VALUE: Into<String>>(self, value: VALUE) -> Self
ID of the object to use as a cursor for pagination (next page)
Sourcepub fn limit<VALUE: Into<u32>>(self, value: VALUE) -> Self
pub fn limit<VALUE: Into<u32>>(self, value: VALUE) -> Self
Number of items to return per page (1-1000)
Sourcepub fn credentials<VALUE: Into<Credentials>>(self, value: VALUE) -> Self
pub fn credentials<VALUE: Into<Credentials>>(self, value: VALUE) -> Self
Credentials for authentication (not serialized)
Examples found in repository?
examples/models.rs (line 11)
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 fn build(self) -> Result<ModelListRequest, ModelListBuilderError>
pub fn build(self) -> Result<ModelListRequest, ModelListBuilderError>
Source§impl ModelListBuilder
impl ModelListBuilder
Sourcepub async fn create(self) -> ApiResponseOrError<ModelList>
pub async fn create(self) -> ApiResponseOrError<ModelList>
Creates a new model list request and returns the response.
This is a convenience method that builds the request from the builder and sends it to the Models API.
§Example
let credentials = Credentials::from_env();
let models = ModelList::builder()
.credentials(credentials)
.limit(10u32)
.create()
.await?;Examples found in repository?
examples/models.rs (line 14)
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}Trait Implementations§
Source§impl Clone for ModelListBuilder
impl Clone for ModelListBuilder
Source§fn clone(&self) -> ModelListBuilder
fn clone(&self) -> ModelListBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelListBuilder
impl Debug for ModelListBuilder
Source§impl Default for ModelListBuilder
impl Default for ModelListBuilder
Source§impl PartialEq for ModelListBuilder
impl PartialEq for ModelListBuilder
impl StructuralPartialEq for ModelListBuilder
Auto Trait Implementations§
impl Freeze for ModelListBuilder
impl RefUnwindSafe for ModelListBuilder
impl Send for ModelListBuilder
impl Sync for ModelListBuilder
impl Unpin for ModelListBuilder
impl UnwindSafe for ModelListBuilder
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