Skip to main content

quantum_sdk/
models.rs

1use serde::Deserialize;
2
3use crate::client::Client;
4use crate::error::Result;
5
6/// Describes an available model.
7#[derive(Debug, Clone, Deserialize)]
8pub struct ModelInfo {
9    /// Model identifier used in API requests.
10    pub id: String,
11
12    /// Upstream provider (e.g. "anthropic", "xai", "openai").
13    pub provider: String,
14
15    /// Human-readable model name.
16    pub display_name: String,
17
18    /// Cost per million input tokens in USD.
19    pub input_per_million: f64,
20
21    /// Cost per million output tokens in USD.
22    pub output_per_million: f64,
23}
24
25/// Pricing details for a model.
26#[derive(Debug, Clone, Deserialize)]
27pub struct PricingInfo {
28    /// Model identifier.
29    pub id: String,
30
31    /// Upstream provider.
32    pub provider: String,
33
34    /// Human-readable model name.
35    pub display_name: String,
36
37    /// Cost per million input tokens in USD.
38    pub input_per_million: f64,
39
40    /// Cost per million output tokens in USD.
41    pub output_per_million: f64,
42}
43
44#[derive(Deserialize)]
45struct ModelsResponse {
46    models: Vec<ModelInfo>,
47}
48
49#[derive(Deserialize)]
50struct PricingResponse {
51    pricing: Vec<PricingInfo>,
52}
53
54impl Client {
55    /// Returns all available models with provider and pricing information.
56    pub async fn list_models(&self) -> Result<Vec<ModelInfo>> {
57        let (resp, _meta) = self.get_json::<ModelsResponse>("/qai/v1/models").await?;
58        Ok(resp.models)
59    }
60
61    /// Returns the complete pricing table for all models.
62    pub async fn get_pricing(&self) -> Result<Vec<PricingInfo>> {
63        let (resp, _meta) = self.get_json::<PricingResponse>("/qai/v1/pricing").await?;
64        Ok(resp.pricing)
65    }
66}