pub struct ModelsClient<'a, T = ()> { /* private fields */ }Expand description
Client for models API.
Implementations§
Source§impl<T: Default + Send + Sync> ModelsClient<'_, T>
impl<T: Default + Send + Sync> ModelsClient<'_, T>
Sourcepub async fn list(&self) -> Result<ListModelsResponse>
pub async fn list(&self) -> Result<ListModelsResponse>
List all available models.
§Example
ⓘ
use openai_ergonomic::Client;
let client = Client::from_env()?;
let models = client.models().list().await?;
println!("Available models: {}", models.data.len());Examples found in repository?
examples/models.rs (line 76)
74async fn fetch_models_from_api(client: &Client) -> Result<()> {
75 // Example of using the ergonomic API to list models
76 let response = client.models().list().await?;
77
78 println!("Fetched {} models from API:", response.data.len());
79 for model in response.data.iter().take(10) {
80 println!(" - {} (owned by: {})", model.id, model.owned_by);
81 }
82 println!();
83
84 // Example of getting a specific model
85 if !response.data.is_empty() {
86 let model_id = &response.data[0].id;
87 let model = client.models().get(model_id).await?;
88 println!("Model details for {}:", model.id);
89 println!(" Owned by: {}", model.owned_by);
90 println!(" Created: {}", model.created);
91 println!();
92 }
93
94 Ok(())
95}Sourcepub async fn get(&self, model_id: impl Into<String>) -> Result<Model>
pub async fn get(&self, model_id: impl Into<String>) -> Result<Model>
Retrieve information about a specific model.
§Example
ⓘ
use openai_ergonomic::Client;
let client = Client::from_env()?;
let model = client.models().get("gpt-4").await?;
println!("Model ID: {}", model.id);Examples found in repository?
examples/models.rs (line 87)
74async fn fetch_models_from_api(client: &Client) -> Result<()> {
75 // Example of using the ergonomic API to list models
76 let response = client.models().list().await?;
77
78 println!("Fetched {} models from API:", response.data.len());
79 for model in response.data.iter().take(10) {
80 println!(" - {} (owned by: {})", model.id, model.owned_by);
81 }
82 println!();
83
84 // Example of getting a specific model
85 if !response.data.is_empty() {
86 let model_id = &response.data[0].id;
87 let model = client.models().get(model_id).await?;
88 println!("Model details for {}:", model.id);
89 println!(" Owned by: {}", model.owned_by);
90 println!(" Created: {}", model.created);
91 println!();
92 }
93
94 Ok(())
95}Sourcepub async fn retrieve(&self, builder: ModelRetrievalBuilder) -> Result<Model>
pub async fn retrieve(&self, builder: ModelRetrievalBuilder) -> Result<Model>
Retrieve information about a model using a builder.
Sourcepub async fn remove(
&self,
builder: ModelDeleteBuilder,
) -> Result<DeleteModelResponse>
pub async fn remove( &self, builder: ModelDeleteBuilder, ) -> Result<DeleteModelResponse>
Delete a fine-tuned model using a builder.
Trait Implementations§
Source§impl<'a, T: Clone> Clone for ModelsClient<'a, T>
impl<'a, T: Clone> Clone for ModelsClient<'a, T>
Source§fn clone(&self) -> ModelsClient<'a, T>
fn clone(&self) -> ModelsClient<'a, T>
Returns a duplicate 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<'a, T: Debug> Debug for ModelsClient<'a, T>
impl<'a, T: Debug> Debug for ModelsClient<'a, T>
impl<'a, T: Copy> Copy for ModelsClient<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ModelsClient<'a, T>
impl<'a, T = ()> !RefUnwindSafe for ModelsClient<'a, T>
impl<'a, T> Send for ModelsClient<'a, T>
impl<'a, T> Sync for ModelsClient<'a, T>
impl<'a, T> Unpin for ModelsClient<'a, T>
impl<'a, T = ()> !UnwindSafe for ModelsClient<'a, T>
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