pub struct Model {
pub id: String,
pub display_name: String,
pub created_at: String,
pub model_type: String,
}Expand description
A model available through the Anthropic API.
Fields§
§id: StringUnique model identifier
display_name: StringA human-readable name for the model
created_at: StringRFC 3339 datetime string representing the time at which the model was released
model_type: StringObject type (always “model” for Models)
Implementations§
Source§impl Model
impl Model
Sourcepub fn builder(model_id: impl Into<String>) -> ModelBuilder
pub fn builder(model_id: impl Into<String>) -> ModelBuilder
Creates a builder for getting a specific model.
§Example
let credentials = Credentials::from_env();
let model = Model::builder("claude-3-7-sonnet-20250219")
.credentials(credentials)
.create()
.await?;Examples found in repository?
examples/models.rs (line 25)
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: ModelRequest) -> ApiResponseOrError<Self>
pub async fn create(request: ModelRequest) -> ApiResponseOrError<Self>
Gets information about a specific model.
§Example
let credentials = Credentials::from_env();
let request = ModelRequest {
model_id: "claude-3-7-sonnet-20250219".to_string(),
credentials: Some(credentials),
};
let model = Model::create(request).await?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for Model
impl<'de> Deserialize<'de> for Model
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 Model
impl StructuralPartialEq for Model
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnwindSafe for Model
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.