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    /// Model category (e.g. "Text", "Image", "Audio", "Video", "Embedding").
19    #[serde(default)]
20    pub category: Option<String>,
21
22    /// Cost per million input tokens in USD (text models).
23    #[serde(default)]
24    pub input_per_million: f64,
25
26    /// Cost per million output tokens in USD (text models).
27    #[serde(default)]
28    pub output_per_million: f64,
29
30    /// Per-unit price for non-token models (image/audio/video).
31    #[serde(default)]
32    pub per_unit_price: Option<f64>,
33
34    /// Price unit description (e.g. "per image", "per second").
35    #[serde(default)]
36    pub price_unit: Option<String>,
37}
38
39/// Pricing details for a model.
40#[derive(Debug, Clone, Deserialize)]
41pub struct PricingInfo {
42    /// Model identifier.
43    pub id: String,
44
45    /// Upstream provider.
46    pub provider: String,
47
48    /// Human-readable model name.
49    pub display_name: String,
50
51    /// Cost per million input tokens in USD.
52    pub input_per_million: f64,
53
54    /// Cost per million output tokens in USD.
55    pub output_per_million: f64,
56}
57
58#[derive(Deserialize)]
59struct ModelsResponse {
60    models: Vec<ModelInfo>,
61}
62
63#[derive(Deserialize)]
64struct PricingResponse {
65    pricing: Vec<PricingInfo>,
66}
67
68impl Client {
69    /// Returns all available models with provider and pricing information.
70    pub async fn list_models(&self) -> Result<Vec<ModelInfo>> {
71        let (resp, _meta) = self.get_json::<ModelsResponse>("/qai/v1/models").await?;
72        Ok(resp.models)
73    }
74
75    /// Returns the complete pricing table for all models.
76    pub async fn get_pricing(&self) -> Result<Vec<PricingInfo>> {
77        let (resp, _meta) = self.get_json::<PricingResponse>("/qai/v1/pricing").await?;
78        Ok(resp.pricing)
79    }
80}