langfuse_client_base/models/create_model_request.rs
1/*
2 * server
3 *
4 * ## Real-time data The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion). ## 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
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<chrono::DateTime<chrono::FixedOffset>>>,
30 #[serde(rename = "unit")]
31 pub unit: 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 #[serde(rename = "tokenizerId", skip_serializing_if = "Option::is_none")]
65 pub tokenizer_id: Option<models::ModelTokenizerId>,
66 /// Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.
67 #[serde(
68 rename = "tokenizerConfig",
69 default,
70 with = "::serde_with::rust::double_option",
71 skip_serializing_if = "Option::is_none"
72 )]
73 pub tokenizer_config: Option<Option<serde_json::Value>>,
74}
75
76impl CreateModelRequest {
77 pub fn new(
78 model_name: String,
79 match_pattern: String,
80 unit: models::ModelUsageUnit,
81 ) -> CreateModelRequest {
82 CreateModelRequest {
83 model_name,
84 match_pattern,
85 start_date: None,
86 unit,
87 input_price: None,
88 output_price: None,
89 total_price: None,
90 pricing_tiers: None,
91 tokenizer_id: None,
92 tokenizer_config: None,
93 }
94 }
95}