anthropic_async/resources/
models.rs1use crate::{
2 client::Client,
3 config::Config,
4 error::AnthropicError,
5 types::models::{Model, ModelListParams, ModelsListResponse},
6};
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}