async_anthropic/
models.rs1use crate::{
2 errors::AnthropicError,
3 types::{GetModelResponse, ListModelsResponse},
4 Client,
5};
6
7pub const DEFAULT_MAX_TOKENS: i32 = 2048;
8
9#[derive(Debug, Clone)]
10pub struct Models<'c> {
11 client: &'c Client,
12}
13
14impl Models<'_> {
15 pub fn new(client: &Client) -> Models {
16 Models { client }
17 }
18
19 #[tracing::instrument(skip_all)]
20 pub async fn list(&self) -> Result<ListModelsResponse, AnthropicError> {
21 self.client.get("/v1/models").await
22 }
23
24 #[tracing::instrument(skip_all)]
25 pub async fn get(&self, model_id: impl AsRef<str>) -> Result<GetModelResponse, AnthropicError> {
26 self.client
27 .get(&format!("/v1/models/{}", model_id.as_ref()))
28 .await
29 }
30}