langfuse-client-base 0.12.0

Auto-generated Langfuse API client from OpenAPI specification
Documentation
/*
 * langfuse
 *
 * ## 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
 *
 * The version of the OpenAPI document:
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateModelRequest {
    /// 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
    #[serde(rename = "modelName")]
    pub model_name: String,
    /// 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$`
    #[serde(rename = "matchPattern")]
    pub match_pattern: String,
    /// Apply only to generations which are newer than this ISO date.
    #[serde(
        rename = "startDate",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub start_date: Option<Option<String>>,
    #[serde(rename = "unit", skip_serializing_if = "Option::is_none")]
    pub unit: Option<models::ModelUsageUnit>,
    /// Deprecated. Use 'pricingTiers' instead. Price (USD) per input unit. Creates a default tier if pricingTiers not provided.
    #[serde(
        rename = "inputPrice",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input_price: Option<Option<f64>>,
    /// Deprecated. Use 'pricingTiers' instead. Price (USD) per output unit. Creates a default tier if pricingTiers not provided.
    #[serde(
        rename = "outputPrice",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output_price: Option<Option<f64>>,
    /// 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.
    #[serde(
        rename = "totalPrice",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub total_price: Option<Option<f64>>,
    /// 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\".
    #[serde(
        rename = "pricingTiers",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub pricing_tiers: Option<Option<Vec<models::PricingTierInput>>>,
    /// Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.
    #[serde(
        rename = "tokenizerId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub tokenizer_id: Option<Option<String>>,
    /// Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.
    #[serde(
        rename = "tokenizerConfig",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub tokenizer_config: Option<Option<serde_json::Value>>,
}

impl CreateModelRequest {
    pub fn new(model_name: String, match_pattern: String) -> CreateModelRequest {
        CreateModelRequest {
            model_name,
            match_pattern,
            start_date: None,
            unit: None,
            input_price: None,
            output_price: None,
            total_price: None,
            pricing_tiers: None,
            tokenizer_id: None,
            tokenizer_config: None,
        }
    }
}