anthropic_async/resources/
models.rs1use crate::client::Client;
2use crate::config::Config;
3use crate::error::AnthropicError;
4use crate::types::models::Model;
5use crate::types::models::ModelListParams;
6use crate::types::models::ModelsListResponse;
7
8pub struct Models<'c, C: Config> {
12 client: &'c Client<C>,
13}
14
15impl<'c, C: Config> Models<'c, C> {
16 pub const fn new(client: &'c Client<C>) -> Self {
18 Self { client }
19 }
20
21 pub async fn list(
27 &self,
28 params: &ModelListParams,
29 ) -> Result<ModelsListResponse, AnthropicError> {
30 self.client.get_with_query("/v1/models", params).await
31 }
32
33 pub async fn get(&self, model_id: &str) -> Result<Model, AnthropicError> {
39 self.client.get(&format!("/v1/models/{model_id}")).await
40 }
41}
42
43impl<C: Config> crate::Client<C> {
44 #[must_use]
46 pub const fn models(&self) -> Models<'_, C> {
47 Models::new(self)
48 }
49}