langfuse_client_base/models/create_model_request.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 - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
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#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct CreateModelRequest {
16 /// Name of the model definition. If multiple with the same name exist, they are applied in the following order: (1) custom over built-in, (2) newest according to startTime where model.startTime<observation.startTime
17 #[serde(rename = "modelName")]
18 pub model_name: String,
19 /// Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$`
20 #[serde(rename = "matchPattern")]
21 pub match_pattern: String,
22 /// Apply only to generations which are newer than this ISO date.
23 #[serde(
24 rename = "startDate",
25 default,
26 with = "::serde_with::rust::double_option",
27 skip_serializing_if = "Option::is_none"
28 )]
29 pub start_date: Option<Option<String>>,
30 #[serde(rename = "unit", skip_serializing_if = "Option::is_none")]
31 pub unit: Option<models::ModelUsageUnit>,
32 /// Deprecated. Use 'pricingTiers' instead. Price (USD) per input unit. Creates a default tier if pricingTiers not provided.
33 #[serde(
34 rename = "inputPrice",
35 default,
36 with = "::serde_with::rust::double_option",
37 skip_serializing_if = "Option::is_none"
38 )]
39 pub input_price: Option<Option<f64>>,
40 /// Deprecated. Use 'pricingTiers' instead. Price (USD) per output unit. Creates a default tier if pricingTiers not provided.
41 #[serde(
42 rename = "outputPrice",
43 default,
44 with = "::serde_with::rust::double_option",
45 skip_serializing_if = "Option::is_none"
46 )]
47 pub output_price: Option<Option<f64>>,
48 /// Deprecated. Use 'pricingTiers' instead. Price (USD) per total units. Cannot be set if input or output price is set. Creates a default tier if pricingTiers not provided.
49 #[serde(
50 rename = "totalPrice",
51 default,
52 with = "::serde_with::rust::double_option",
53 skip_serializing_if = "Option::is_none"
54 )]
55 pub total_price: Option<Option<f64>>,
56 /// Optional. Array of pricing tiers for this model. Use pricing tiers for all models - both those with threshold-based pricing variations and those with simple flat pricing: - For models with standard flat pricing: Create a single default tier with your prices (e.g., one tier with isDefault=true, priority=0, conditions=[], and your standard prices) - For models with threshold-based pricing: Create a default tier plus additional conditional tiers (e.g., default tier for standard usage + high-volume tier for usage above certain thresholds) Requirements: - Cannot be provided with flat prices (inputPrice/outputPrice/totalPrice) - use one approach or the other - Must include exactly one default tier with isDefault=true, priority=0, and conditions=[] - All tier names and priorities must be unique within the model - Each tier must define at least one price If omitted, you must provide flat prices instead (inputPrice/outputPrice/totalPrice), which will automatically create a single default tier named \"Standard\".
57 #[serde(
58 rename = "pricingTiers",
59 default,
60 with = "::serde_with::rust::double_option",
61 skip_serializing_if = "Option::is_none"
62 )]
63 pub pricing_tiers: Option<Option<Vec<models::PricingTierInput>>>,
64 /// Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.
65 #[serde(
66 rename = "tokenizerId",
67 default,
68 with = "::serde_with::rust::double_option",
69 skip_serializing_if = "Option::is_none"
70 )]
71 pub tokenizer_id: Option<Option<String>>,
72 /// Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.
73 #[serde(
74 rename = "tokenizerConfig",
75 default,
76 with = "::serde_with::rust::double_option",
77 skip_serializing_if = "Option::is_none"
78 )]
79 pub tokenizer_config: Option<Option<serde_json::Value>>,
80}
81
82impl CreateModelRequest {
83 pub fn new(model_name: String, match_pattern: String) -> CreateModelRequest {
84 CreateModelRequest {
85 model_name,
86 match_pattern,
87 start_date: None,
88 unit: None,
89 input_price: None,
90 output_price: None,
91 total_price: None,
92 pricing_tiers: None,
93 tokenizer_id: None,
94 tokenizer_config: None,
95 }
96 }
97}