langfuse_client_base/models/pricing_tier_input.rs
1/*
2 * langfuse
3 *
4 * ## Authentication Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings: - username: Langfuse Public Key - password: Langfuse Secret Key ## Exports - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// PricingTierInput : Input schema for creating a pricing tier. The tier ID will be automatically generated server-side. When creating a model with pricing tiers: - Exactly one tier must have isDefault=true (the fallback tier) - The default tier must have priority=0 and conditions=[] - All tier names and priorities must be unique within the model - Each tier must define at least one price See PricingTier for detailed information about how tiers work and why they're useful.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct PricingTierInput {
17 /// Name of the pricing tier for display and identification purposes. Must be unique within the model. Common patterns: \"Standard\", \"High Volume Tier\", \"Extended Context\"
18 #[serde(rename = "name")]
19 pub name: String,
20 /// Whether this is the default tier. Exactly one tier per model must be marked as default. Requirements for default tier: - Must have isDefault=true - Must have priority=0 - Must have empty conditions array (conditions=[]) The default tier acts as a fallback when no conditional tiers match.
21 #[serde(rename = "isDefault")]
22 pub is_default: bool,
23 /// Priority for tier matching evaluation. Lower numbers = higher priority (evaluated first). Must be unique within the model. The default tier must have priority=0. Conditional tiers should use priority 1, 2, 3, etc. based on their specificity.
24 #[serde(rename = "priority")]
25 pub priority: i32,
26 /// Array of conditions that must ALL be met for this tier to match (AND logic). The default tier must have an empty array (conditions=[]). Conditional tiers should define one or more conditions that specify when this tier's pricing applies. Each condition specifies a regex pattern, operator, and threshold value for matching against usage details.
27 #[serde(rename = "conditions")]
28 pub conditions: Vec<models::PricingTierCondition>,
29 /// Prices (USD) by usage type for this tier. At least one price must be defined. Common usage types: \"input\", \"output\", \"total\", \"request\", \"image\" Prices are in USD per unit (e.g., per token). Example: {\"input\": 0.000003, \"output\": 0.000015} represents $3 per million input tokens and $15 per million output tokens.
30 #[serde(rename = "prices")]
31 pub prices: std::collections::HashMap<String, f64>,
32}
33
34impl PricingTierInput {
35 /// Input schema for creating a pricing tier. The tier ID will be automatically generated server-side. When creating a model with pricing tiers: - Exactly one tier must have isDefault=true (the fallback tier) - The default tier must have priority=0 and conditions=[] - All tier names and priorities must be unique within the model - Each tier must define at least one price See PricingTier for detailed information about how tiers work and why they're useful.
36 pub fn new(
37 name: String,
38 is_default: bool,
39 priority: i32,
40 conditions: Vec<models::PricingTierCondition>,
41 prices: std::collections::HashMap<String, f64>,
42 ) -> PricingTierInput {
43 PricingTierInput {
44 name,
45 is_default,
46 priority,
47 conditions,
48 prices,
49 }
50 }
51}